changeset 2097:9272476e2a1c

Client-side conversion of string to bool
author Adam Chlipala <adam@chlipala.net>
date Thu, 25 Dec 2014 18:32:27 -0500
parents 6b7749da1ddc
children b7cb53affc08
files lib/js/urweb.js src/settings.sml
diffstat 2 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/js/urweb.js	Wed Dec 24 12:35:20 2014 -0500
+++ b/lib/js/urweb.js	Thu Dec 25 18:32:27 2014 -0500
@@ -1261,6 +1261,8 @@
 
 function ts(x) { return x.toString() }
 function bs(b) { return (b ? "True" : "False") }
+function s2b(s) { return s == "True" ? true : s == "False" ? false : null; }
+function s2be(s) { return s == "True" ? true : s == "False" ? false : er("Illegal Boolean " ^ s); }
 
 function id(x) { return x; }
 function sub(s, i) { return s.charAt(i); }
--- a/src/settings.sml	Wed Dec 24 12:35:20 2014 -0500
+++ b/src/settings.sml	Thu Dec 25 18:32:27 2014 -0500
@@ -297,6 +297,8 @@
                           ("mouseEvent", "uw_mouseEvent"),
                           ("keyEvent", "uw_keyEvent"),
                           ("minTime", "0"),
+                          ("stringToBool_error", "s2be"),
+                          ("stringToBool", "s2b"),
 
                           ("islower", "isLower"),
                           ("isupper", "isUpper"),