Commit b774a1a9 authored by o's avatar o
Browse files

add a js timer to reload page to avoid stale sessions

parent c17108fa
......@@ -4,3 +4,4 @@
//= require sha256.min
//= require proofofwork
//= require base64
//= require reloadStale
pageLoadedTime = new Date();
lastInteraction = new Date();
function keyDownEvent() {
lastInteraction = new Date();
}
function reloadStaleSession() {
var cur = new Date();
var loaded = (cur.getTime() - pageLoadedTime.getTime()) / 1000;
var last = (cur.getTime() - lastInteraction.getTime()) / 1000;
if (loaded > 240 && last > 60)
location.reload();
}
document.addEventListener('keydown', keyDownEvent);
document.addEventListener('focus', reloadStaleSession);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment