diff lib/js/urweb.js @ 1290:6791454653c5

Confirm boxes; proper event handler setting for ctags
author Adam Chlipala <adam@chlipala.net>
date Sun, 22 Aug 2010 19:45:07 -0400
parents 003df929ee08
children 0d8bd8ae8417
line wrap: on
line diff
--- a/lib/js/urweb.js	Sun Aug 22 13:43:46 2010 -0400
+++ b/lib/js/urweb.js	Sun Aug 22 19:45:07 2010 -0400
@@ -512,7 +512,18 @@
 
 function addOnChange(x, f) {
     var old = x.onchange;
-    x.onchange = function() { old(); f (); };
+    if (old == null)
+        x.onchange = f;
+    else
+        x.onchange = function() { old(); f(); };
+}
+
+function addOnKeyUp(x, f) {
+    var old = x.onkeyup;
+    if (old == null)
+        x.onkeyup = f;
+    else
+        x.onkeyup = function(x) { old(x); f(x); };
 }
 
 
@@ -893,7 +904,7 @@
 var uw_event = null;
 
 function kc() {
-    return window.event ? uw_event.keyCode : uw_event.which;
+    return window.event ? event.keyCode : (uw_event ? uw_event.keyCode : 0);
 }
 
 
@@ -1164,5 +1175,12 @@
 }
 
 
+// Wrappers
+
+function confrm(s) {
+    return confirm(s) ? true : false;
+}
+
+
 // App-specific code