add .clear_timer method to this setTimeout wrapper
authorJason Etheridge <jason@esilibrary.com>
Thu, 7 Apr 2011 20:40:57 +0000 (16:40 -0400)
committerJason Etheridge <jason@esilibrary.com>
Thu, 7 Apr 2011 20:40:57 +0000 (16:40 -0400)
Open-ILS/xul/staff_client/chrome/content/util/exec.js

index 38f0ca3..18e7d1e 100644 (file)
@@ -22,10 +22,7 @@ util.exec.prototype = {
     'timer' : function(funcs,interval) {
         var obj = this;
 
-        if (obj._intervalId) {
-            obj.clear_timer();
-            window.removeEventListener('unload',obj.clear_timer,false); 
-        }
+        obj.clear_timer();
         var intervalId = window.setInterval(
             function() {
                 if (typeof obj.debug != 'undefined' && obj.debug) { dump('EXEC: ' + location.pathname + ': Running interval with id = ' + intervalId + '\n'); }
@@ -40,6 +37,13 @@ util.exec.prototype = {
         window.addEventListener('unload',obj.clear_timer,false); 
         return intervalId;
     },
+    'clear_timer' : function() {
+        var obj = this;
+        if (obj._intervalId) {
+            obj.clear_timer();
+            window.removeEventListener('unload',obj.clear_timer,false);
+        }
+    },
     // This executes a series of functions, but tries to give other events/functions a chance to
     // execute between each one.
     'chain' : function () {