Skip to content

Instantly share code, notes, and snippets.

@tolmasky
Created November 25, 2008 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolmasky/28722 to your computer and use it in GitHub Desktop.
Save tolmasky/28722 to your computer and use it in GitHub Desktop.
--- a/Foundation/CPTimer.j
+++ b/Foundation/CPTimer.j
@@ -243,13 +243,13 @@ var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functio
theFunction = nil;
if (typeof codeOrFunction === "string")
- theFunction = function() { new Function(codeOrFunction)(); CPTimersForTimeoutIDs[timeoutID] = nil; }
+ theFunction = function() { new Function(codeOrFunction)(); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
else
{
if (!functionArgs)
functionArgs = [];
- theFunction = function() { codeOrFunction.apply(window, functionArgs); CPTimersForTimeoutIDs[timeoutID] = nil; }
+ theFunction = function() { codeOrFunction.apply(window, functionArgs); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
}
CPTimersForTimeoutIDs[timeoutID] = [CPTimer scheduledTimerWithTimeInterval:aDelay / 1000 callback:theFunction repeats:shouldRepeat];
@@ -268,6 +268,8 @@ window.clearTimeout = function(aTimeoutID)
if (timer)
[timer invalidate];
+
+ CPTimersForTimeoutIDs[aTimeoutID] = nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment