Reputation: 10542
Hey all i have posted the code to the countdown counter i am using. It can be found on the JSFiddle page here: http://jsfiddle.net/QVwGt/
As you can see on that page, the timer start (in seconds) at 95 then it does 94, 93, 92, 91, 90, 85, 84, 83, 82, 81, 80, 75, 74... etc.
It should start with 59, 58, 57, all the way down to 00 then start back at 59 again. It used to do this when it has XXX days left, but now since its gone into 2 digit days, its started doing this and i've look through the code but am unable to find the source of the problem.
As far as it goes, even starting at 95, it does keep pace of the 59 second ticks (watching on the computers clock hand). But it doesn't look nice starting at 95 :o)
Any help would be great in solving this problem! :o)
Upvotes: 1
Views: 261
Reputation: 3824
digits[c].__max = ((c-1) % 2 == 0) ? 5: 9;
you commented out the right code here
digits[c].__max = (c % 2 == 0) ? 5: 9;
Basically, c is your iterator. So in this case, you're looking for the second digit to max at 9, and the first to max at 5. Remember, your iterator is 0 based, and you're thinking 1 based.
In other words, 0 % 2 == 0
and 1 % 2 != 0
but you were looking at it and seeing 1 % 2 != 0
and 2 % 2 == 0
It would be much clearer if it was written like this:
digits[c].__max = ((c + 1) % 2 == 0) ? 9: 5;
Upvotes: 3