aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@csail.mit.edu>2016-06-17 16:39:59 -0400
committerGravatar Adam Chlipala <adamc@csail.mit.edu>2016-06-17 16:39:59 -0400
commitf38ff008676993c9b690cccaad9ca25d56b90530 (patch)
tree71436e9f4e59c8618eaded77fb0625df94646cfc /lib/js
parent5ac04f029f2876284e8af10275bdd63e75fc90e7 (diff)
parentf050c7f1de1fe03e2253f408445a69e9402f60ee (diff)
Merge branch 'master' of ssh://github.com/urweb/urweb
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/urweb.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 96a12637..1f44a97b 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1704,10 +1704,11 @@ function newChannel() {
function listener() {
var uri = path_join(url_prefix, ".msgs");
var xhr = getXHR();
- var tid, orsc, onTimeout;
+ var tid, orsc, onTimeout, lastTick;
var connect = function () {
xhr.onreadystatechange = orsc;
+ lastTick = new Date().getTime();
tid = window.setTimeout(onTimeout, timeout * 500);
requestUri(xhr, uri, false, false);
}
@@ -1797,8 +1798,19 @@ function listener() {
};
onTimeout = function() {
+ var thisTick = new Date().getTime();
xhrFinished(xhr);
- connect();
+
+ if (thisTick - lastTick > timeout * 1000) {
+ if (confirm("The session for this page has expired. Please choose \"OK\" to reload.")) {
+ if (isPost)
+ history.back();
+ else
+ location.reload();
+ }
+ } else {
+ connect();
+ }
};
connect();