diff options
Diffstat (limited to 'lib/js')
-rw-r--r-- | lib/js/urweb.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index fe996833..de956d3f 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -22,11 +22,19 @@ function union(ls1, ls2) { // Embedding closures in XML strings +function cs(f) { + return {closure: f}; +} + +function isWeird(v) { + return v.closure != null || v.cat1 != null; +} + function cat(s1, s2) { - if (s1.length && s2.length) - return s1 + s2; + if (isWeird(s1) || isWeird(s2)) + return {cat1: s1, cat2: s2}; else - return {_1: s1, _2: s2}; + return s1 + s2; } var closures = []; @@ -42,12 +50,12 @@ function cr(n) { } function flatten(tr) { - if (tr.length) - return tr; - else if (tr._1) - return cs(tr._1) + cs(tr._2); + if (tr.cat1 != null) + return flatten(tr.cat1) + flatten(tr.cat2); + else if (tr.closure != null) + return "cr(" + newClosure(tr.closure) + ")"; else - return "cr(" + newClosure(tr) + ")"; + return tr; } function clearClosures() { @@ -157,7 +165,7 @@ function dyn(s) { ls.data.dyns = remove(span, ls.data.dyns); } - x.innerHTML = v; + x.innerHTML = flatten(v); runScripts(x); if (--dynDepth == 0) @@ -412,3 +420,7 @@ function rv(chn, parse, k) { k(parse(msg))(null); } } + + +// App-specific code + |