summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spw+git@sdf.org>2014-11-12 15:41:33 +0900
committerSean Whitton <spw+git@sdf.org>2014-11-12 15:41:33 +0900
commit2294742ab94923e891ac7c1f66459eb48b938529 (patch)
treea713c2a188f01a6166cfa038f4479ccfae8d6f1b
parente20b509b1de6293adffdc2af9a5771dee71eb687 (diff)
downloadschoolclock-2294742ab94923e891ac7c1f66459eb48b938529.tar.gz
finish implementing buttons and hotkeys
-rw-r--r--js/main.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/js/main.js b/js/main.js
index b18d13b..f6a9e55 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1,9 +1,9 @@
/*
* TODO:
*
- * - make all buttons work
- * - add all hotkeys
- * - rework use of global variables
+ * - rework use of global variables and functions into OO idioms
+ * - initialise time wasting clock from storage in OO idiom rather
+ * than just stray function call
*/
$.ionSound({
@@ -94,7 +94,23 @@ function timeWastingClockReset()
}
}
+function activityClockReset()
+{
+ activityClock.stop();
+ activityClock.setTime(0);
+}
+
+function activityClockCustom()
+{
+ var minutes = prompt("Number of minutes", "0");
+ var seconds = prompt("Number of seconds");
+ activityClockGo(parseInt(minutes) * 60 + parseInt(seconds));
+}
+
$(document).bind('keydown', 's', timeWastingClockReset);
+$(document).bind('keydown', 'r', activityClockReset);
+$(document).bind('keydown', 'c', activityClockCustom);
+
$(document).bind('keydown', '0', function (){activityClockGo(30);});
$(document).bind('keydown', '1', function (){activityClockGo(60);});
$(document).bind('keydown', '9', function (){activityClockGo(90);});
@@ -113,6 +129,12 @@ $(document).ready(function(){
$('#timeWastingClockReset').button();
$('#timeWastingClockReset').click(timeWastingClockReset);
+ $('#activityClockReset').button();
+ $('#activityClockReset').click(activityClockReset);
+
+ $('#activityClockCustom').button();
+ $('#activityClockCustom').click(activityClockCustom);
+
$('#activityClock30s').button();
$('#activityClock30s').click(function (){activityClockGo(30);})