summaryrefslogtreecommitdiff
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js68
1 files changed, 62 insertions, 6 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 410a0e23..68e7979d 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -116,6 +116,48 @@ function pow(n, m) {
return Math.pow(n, m);
}
+function sqrt(n){
+ return Math.sqrt(n);
+}
+
+function sin(n){
+ return Math.sin(n);
+}
+
+function cos(n){
+ return Math.cos(n);
+}
+
+function log(n){
+ return Math.log(n);
+}
+
+function exp(n){
+ return Math.exp(n);
+}
+
+function asin(n){
+ return Math.asin(n);
+}
+function acos(n){
+ return Math.acos(n);
+}
+
+function atan(n){
+ return Math.atan(n);
+}
+
+function atan2(n, m){
+ return Math.atan2(n, m);
+}
+
+function floor(n){
+ return Math.floor(n);
+}
+
+function abs(n){
+ return Math.abs(n);
+}
// Time, represented as counts of microseconds since the epoch
@@ -837,10 +879,12 @@ function normalizeTable(table) {
for (script = table.firstChild; script && script != tbody; script = next) {
next = script.nextSibling;
- if (firstChild)
- tbody.insertBefore(script, firstChild);
- else
- tbody.appendChild(script);
+ if (script.tagName === "SCRIPT") {
+ if (firstChild)
+ tbody.insertBefore(script, firstChild);
+ else
+ tbody.appendChild(script);
+ }
}
return;
@@ -1662,10 +1706,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);
}
@@ -1755,8 +1800,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();