summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2014-12-01 07:56:21 +0900
committerSean Whitton <spwhitton@spwhitton.name>2014-12-01 07:56:21 +0900
commitb909c74c5511b9574a7d5d7e11d6d743df59859f (patch)
tree7f8fb3c1868f9bfa90a8decd1b25f63074feb155
parent6cce1a5ee80067332170d9c80638253e49c43cd2 (diff)
downloadschoolclock-b909c74c5511b9574a7d5d7e11d6d743df59859f.tar.gz
attempt to make a proper derived class from FlipClock.Factory. Options
don't seem to get passed
-rw-r--r--js/main.js41
1 files changed, 19 insertions, 22 deletions
diff --git a/js/main.js b/js/main.js
index ee03828..e5981dd 100644
--- a/js/main.js
+++ b/js/main.js
@@ -149,36 +149,34 @@ $.ionSound({
preload: true
});
-// function to make a FlipClock with a few additional features. Not
-// as neat a constructor as I would like because I don't fully
-// understand how jQuery works
-function MyFlipClock (jq, obj)
+function MyFlipClock (obj, options)
{
- var thisClock = new FlipClock(jq, obj);
-
- thisClock.go = $.proxy(function (seconds) {
+ options.autoStart = false;
+ FlipClock.Factory.call(this, obj, 0, options);
+ this.go = function (seconds) {
this.setTime(seconds);
this.start();
- }, thisClock);
- thisClock.reset = $.proxy(function () {
- thisClock.stop();
- thisClock.setTime(0);
- }, thisClock);
- thisClock.custom = $.proxy(function () {
+ };
+ this.reset = function () {
+ this.stop();
+ this.setTime(0);
+ };
+ this.custom = function () {
var minutes = parseInt(prompt('Number of minutes', '0'));
var seconds = parseInt(prompt('Number of seconds', '0'));
- thisClock.go(minutes * 60 + seconds);
- }, thisClock);
-
- return thisClock;
+ this.go(minutes * 60 + seconds);
+ };
}
+MyFlipClock.prototype = new FlipClock.Factory;
-var timeWastingClock = MyFlipClock($('.time-wasting-clock'), {
- autoStart:false,
+var timeWastingClock = new MyFlipClock($('.time-wasting-clock'), {
callbacks:{
interval:function () {
$.ionSound.play("button_tiny");
- var time = timeWastingClock.getTime().time;
+ if (timeWastingClock)
+ var time = timeWastingClock.getTime().time;
+ else
+ time = 0;
$.jStorage.set("time_wasted", time);
}
}
@@ -217,8 +215,7 @@ timeWastingClock.toggle = $.proxy(function () {
}
}, timeWastingClock);
-var activityClock = MyFlipClock($('.activity-countdown'), {
- autoStart:false,
+var activityClock = new MyFlipClock($('.activity-countdown'), {
countdown:true,
callbacks:{
stop:function () {