mrchimp / tock

Timer Object/Class. Kickass!
MIT License
237 stars 33 forks source link

Updated start(), extended convenience methods, updated example and documentation #15

Closed ItsMeEricV closed 9 years ago

ItsMeEricV commented 10 years ago

Main purpose is to allow a user to arbitrarily start(time) the timer at any time and with more string formats. Added more convenience methods to convert milliseconds to a timecode String and to extend msToTime to accept additional formats. Updated HTML example and documentation to reflect new changes.

mrchimp commented 9 years ago

Thanks for the input! One small issue though...

Adding pause_time = false; to stop() breaks the pause button as pause() calls stop(). Clicking pause once still stops the clock but clicking it a second time does not make it continue. Removing that line doesn't appear to break anything though it does change the functionality slightly as it stops stop() from resetting the clock.

With your updated start() and that one line removed the pause functionality and stop/start basically work the same. Unless you had a specific reason for this I think that's a good thing. Pause just adds the ability to toggle the clock with a single function keeping the logic internal rather than making it a problem for the user (which would require them to understand what go is etc.). I'd rather have that and leave the problem of what "reset" should do up to them.

msToTimecode is a better name, and the time-ms functions are a definite improvement.

The only other thing I would change is a slight alteration to the readme to make it more clear. At first I thought your changed to start() meant that you could start the clock at a given time, e.g. "Start clock at 12:00 today". But that's only a minor thing.

Thanks again for the input. I'd like to hear your thoughts about the pause time thing before I merge your changes. Maybe you have a use-case in mind that I'm not thinking of.

ItsMeEricV commented 9 years ago

Good catch. The problem was that the return pause_time || final_time line in lap() would end up setting the clockface to the old pause_time if you hit stop after you hit pause. But at your suggestion I removed the offending line and added pause_time = lap() to stop() and everything works.

Also I simplified the time argument to start() so that the user can input any timeformat he/she wants (or milliseconds or 0) so that it "just works."