From b738b079fd71b9711ec34667f31ecc1c8414ef04 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 12 Nov 2014 07:01:56 +0900 Subject: time wasting clock can be started, stopped and reset --- index.html | 8 ++++---- js/main.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 84a880c..b01f038 100644 --- a/index.html +++ b/index.html @@ -51,10 +51,10 @@

- - + Start timer (Hotkey: j) + Reset timer (end of class)

Activity time


diff --git a/js/main.js b/js/main.js index 0a10a79..14ae473 100644 --- a/js/main.js +++ b/js/main.js @@ -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); + } + } + }); +}); + -- cgit v1.2.3