summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/js/urweb.js10
-rw-r--r--src/settings.sml4
-rw-r--r--tests/csdebug.ur5
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 854ebe45..5f1566a3 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -338,6 +338,16 @@ function strftime(fmt, thisTime)
// Error handling
+function uw_debug(msg) {
+ try {
+ console.debug(msg);
+ } catch (e) {
+ alert("DEBUG: " + msg);
+ }
+
+ return 0;
+}
+
function whine(msg) {
alert(msg);
throw msg;
diff --git a/src/settings.sml b/src/settings.sml
index d66b33ef..f4022cf9 100644
--- a/src/settings.sml
+++ b/src/settings.sml
@@ -270,8 +270,8 @@ val jsFuncsBase = basisM [("alert", "alert"),
("lt_time", "lt"),
("le_time", "le"),
- ("debug", "alert"),
- ("naughtyDebug", "alert"),
+ ("debug", "uw_debug"),
+ ("naughtyDebug", "uw_debug"),
("floatFromInt", "float"),
("ceil", "ceil"),
diff --git a/tests/csdebug.ur b/tests/csdebug.ur
new file mode 100644
index 00000000..66ba0aea
--- /dev/null
+++ b/tests/csdebug.ur
@@ -0,0 +1,5 @@
+fun main () : transaction page =
+ n <- source 0;
+ return <xml><body>
+ <button onclick={n' <- get n; set n (n' + 1); debug ("Message: " ^ show n')}/>
+ </body></xml>