diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 68 | ||||
-rw-r--r-- | lib/ur/basis.urs | 15 | ||||
-rw-r--r-- | lib/ur/top.ur | 20 |
3 files changed, 90 insertions, 13 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(); diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 883cc5b1..1163daed 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -152,7 +152,20 @@ val float : int -> float val ceil : float -> int val trunc : float -> int val round : float -> int - +val floor : float -> int + +(** * Basic Math *) + +val sqrt : float -> float +val sin : float -> float +val cos : float -> float +val log : float -> float +val exp : float -> float +val asin : float -> float +val acos : float -> float +val atan : float -> float +val atan2 : float -> float -> float +val abs: float -> float (** * Time *) diff --git a/lib/ur/top.ur b/lib/ur/top.ur index e831b4f7..6c6c896c 100644 --- a/lib/ur/top.ur +++ b/lib/ur/top.ur @@ -225,15 +225,23 @@ fun query1' [t ::: Name] [fs ::: {Type}] [state ::: Type] (q : sql_query [] [] [ (f : $fs -> state -> state) (i : state) = query q (fn r s => return (f r.t s)) i +val rev = fn [a] => + let + fun rev' acc (ls : list a) = + case ls of + [] => acc + | x :: ls => rev' (x :: acc) ls + in + rev' [] + end + fun queryL [tables] [exps] [tables ~ exps] (q : sql_query [] [] tables exps) = - query q - (fn r ls => return (r :: ls)) - [] + ls <- query q (fn r ls => return (r :: ls)) []; + return (rev ls) fun queryL1 [t ::: Name] [fs ::: {Type}] (q : sql_query [] [] [t = fs] []) = - query q - (fn r ls => return (r.t :: ls)) - [] + ls <- query q (fn r ls => return (r.t :: ls)) []; + return (rev ls) fun queryI [tables ::: {{Type}}] [exps ::: {Type}] [tables ~ exps] (q : sql_query [] [] tables exps) |