diff options
author | Sean Whitton <spw+git@sdf.org> | 2014-11-12 14:48:26 +0900 |
---|---|---|
committer | Sean Whitton <spw+git@sdf.org> | 2014-11-12 14:48:26 +0900 |
commit | 89b061c0db3251dddc5a774e41631d9c875f4611 (patch) | |
tree | 1b880685c6e5766fead9549123070de4721ee543 | |
parent | 29a618e315bc3a60cde3caeee76d851b2fd5d261 (diff) | |
download | schoolclock-89b061c0db3251dddc5a774e41631d9c875f4611.tar.gz |
factor out and bind time wasting clock reset code
-rw-r--r-- | js/main.js | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -74,6 +74,26 @@ function activityClockGo($seconds) activityClock.start(); } +function timeWastingClockReset() +{ + if (timeWastingClock.getTime() != 0) + { + var $timeWastingClockResetConfirm = confirm("Are you sure?"); + if ($timeWastingClockResetConfirm) + { + if ($timeWastingClockRunning) + { + $('#timeWastingClockGo').html('Start <u>t</u>imer'); + timeWastingClock.stop(); + $timeWastingClockRunning = false; + } + timeWastingClock.setTime(0); + } + } +} + +$(document).bind('keydown', 's', timeWastingClockReset); + $(document).bind('keydown', '1', function (){activityClockGo(60);}); $(document).ready(function(){ @@ -84,22 +104,7 @@ $(document).ready(function(){ $('#timeWastingClockGo').click(timeWastingClockToggle); $('#timeWastingClockReset').button(); - $('#timeWastingClockReset').click(function() { - if (timeWastingClock.getTime() != 0) - { - var $timeWastingClockResetConfirm = confirm("Are you sure?"); - if ($timeWastingClockResetConfirm) - { - if ($timeWastingClockRunning) - { - $('#timeWastingClockGo').html('Start timer (Hotkey: j)'); - timeWastingClock.stop(); - $timeWastingClockRunning = false; - } - timeWastingClock.setTime(0); - } - } - }); + $('#timeWastingClockReset').click(timeWastingClockReset); $('#activityClock30s').button(); $('#activityClock30s').click(function (){activityClockGo(30);}) |