Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit 013882a

Browse files
committed
Added javascript code to detect when pages are shown because the user hit the back (or forward) button.
In this case we do a full reload so that we get the latest information (for example the labeled frame counts for videos).
1 parent 53ef4cb commit 013882a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

server/src/js/util.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ goog.provide('fmltc.Util');
2727
* @constructor
2828
*/
2929
fmltc.Util = function(pageBasename, preferences, limitData, modelTrainerData, trainingEnabled) {
30+
window.addEventListener('pageshow', function(event) {
31+
// event.persisted means the page is loading from a cache.
32+
var needToReload = false;
33+
if (event.persisted) {
34+
needToReload = true;
35+
} else {
36+
// Check if we got to this page from the back (or forward) button.
37+
var perfEntries = performance.getEntriesByType('navigation');
38+
if (perfEntries.length > 0 && perfEntries[0].type === 'back_forward') {
39+
needToReload = true;
40+
}
41+
}
42+
if (needToReload) {
43+
location.reload();
44+
}
45+
});
46+
3047
this.pageBasename = pageBasename;
3148
this.preferences = preferences;
3249
this.limitData = limitData;

0 commit comments

Comments
 (0)