Add a wrStoppTimer()
call at the beginning of wrStartTimer
:
var wrStartTimer = function() {
wrStoppTimer();
wrTimer = setInterval(function() {
wrChange(wrAutomaticDirection);
}, wrTime)
};
Also in the two click
functions you have:
wrStoppTimer();
wrStartTimer();
you can remove that wrStoppTimer()
call since wrStartTimer()
will call it for you now.
One other thing: if you define functions the way you're doing with var name = function() { ... }
you should put a semicolon after the closing }
as in the updated code above.