changeset 1385:449a12b82db7

Client-side redirects
author Adam Chlipala <adam@chlipala.net>
date Thu, 06 Jan 2011 14:25:42 -0500
parents 86d23010ea74
children 64724ef86149
files lib/js/urweb.js src/jscomp.sml
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Thu Jan 06 12:49:14 2011 -0500
+++ b/lib/js/urweb.js	Thu Jan 06 14:25:42 2011 -0500
@@ -715,6 +715,10 @@
     return parse(s);
 }
 
+function redirect(s) {
+    window.location = s;
+}
+
 function rc(prefix, uri, parse, k, needsSig) {
     uri = cat(prefix, uri);
     uri = flattenLocal(uri);
--- a/src/jscomp.sml	Thu Jan 06 12:49:14 2011 -0500
+++ b/src/jscomp.sml	Thu Jan 06 14:25:42 2011 -0500
@@ -875,7 +875,17 @@
                           | ENextval _ => unsupported "Nextval"
                           | ESetval _ => unsupported "Nextval"
                           | EReturnBlob _ => unsupported "EReturnBlob"
-                          | ERedirect _ => unsupported "ERedirect"
+
+                          | ERedirect (e, _) =>
+                            let
+                                val (e, st) = jsE inner (e, st)
+                            in
+                                (strcat [str "{c:\"f\",f:\"redirect\",a:cons(",
+                                         e,
+                                         str ",null)}"],
+                                 st)
+                            end
+
                           | EUnurlify (_, _, true) => unsupported "EUnurlify"
 
                           | EUnurlify (e, t, false) =>