diff options
author | Sean Whitton <spw@sdf.org> | 2014-11-12 07:01:56 +0900 |
---|---|---|
committer | Sean Whitton <spw@sdf.org> | 2014-11-12 07:01:56 +0900 |
commit | b738b079fd71b9711ec34667f31ecc1c8414ef04 (patch) | |
tree | 70bc55fe313a5ce7a28a62c93118017c520b697d | |
parent | a54fda74a315a408e46c5a09b1a18cf149bd74f9 (diff) | |
download | schoolclock-b738b079fd71b9711ec34667f31ecc1c8414ef04.tar.gz |
time wasting clock can be started, stopped and reset
-rw-r--r-- | index.html | 8 | ||||
-rw-r--r-- | js/main.js | 39 |
2 files changed, 43 insertions, 4 deletions
@@ -51,10 +51,10 @@ <div class="time-wasting-clock"></div> <br /> - <button type="button" class="btn btn-primary btn-lg - btn-block">Start timer (Hotkey: j)</button> - <button type="button" class="btn btn-default btn-lg - btn-block">Reset timer (end of class)</button> + <a id="timeWastingClockGo" class="btn btn-primary btn-lg + btn-block">Start timer (Hotkey: j)</a> + <a id="timeWastingClockReset" class="btn btn-default btn-lg + btn-block">Reset timer (end of class)</a> </div> <div class="col-md-6"> <h1>Activity time</h1><br /> @@ -2,7 +2,46 @@ var timeWastingClock = new FlipClock($('.time-wasting-clock'), { autoStart:false }); +var $timeWastingClockRunning = false; + var activityClock = new FlipClock($('.activity-countdown'), { autoStart:false, countdown:true }); + +$(document).ready(function(){ + $('#timeWastingClockGo').button(); + $('#timeWastingClockGo').click(function() { + if ($timeWastingClockRunning) + { + $(this).html('Start timer (Hotkey: j)'); + timeWastingClock.stop(); + $timeWastingClockRunning = false; + } + else + { + $(this).html('Stop timer (Hotkey: j)'); + timeWastingClock.start(); + $timeWastingClockRunning = true; + } + }); + + $('#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); + } + } + }); +}); + |