Skip to content

Commit

Permalink
* added reset() for resetting common things
Browse files Browse the repository at this point in the history
  • Loading branch information
apg committed Jul 28, 2010
1 parent 236ad4e commit cf08e7b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions timer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* (c) 2010, Andrew Gwozdziewycz, GPL licensed, see LICENSE
*/

var Timer = function(time, e, b) {
this.length = time;
this.element = e;
Expand All @@ -8,8 +12,8 @@ var Timer = function(time, e, b) {
this._timeleft = time;
this._lasttick = null;

// private state
this.init();
this.reset();
};

Timer.c = {
Expand All @@ -36,6 +40,12 @@ Timer.prototype = {
});
this.displayTimeFor(this._timeleft);
},
'reset': function() {
this._interval = null;
this._status = Timer.c.STOPPED;
this._timeleft = this.length;
this._lasttick = null;
},
'onclick': function(e) {
if (this._status == Timer.c.STOPPED ||
this._status == Timer.c.PAUSED) {
Expand All @@ -46,6 +56,7 @@ Timer.prototype = {
}
},
'ondblclick': function(e) {
this.reset();
this.stop();
},
'ontick': function() {
Expand Down Expand Up @@ -111,7 +122,7 @@ Timer.prototype = {
jQuery(document).ready(function($) {
var hash = window.location.hash.substring(1);
var mins = parseInt(hash) > 0? parseInt(hash): 5;
new Timer(60 * mins, $('#timer'), $('#wrapper'));
new Timer(10 * mins, $('#timer'), $('#wrapper'));
$('#timer').fit({width: $(window).width(), height: $(window).height()});

$(window).resize(function() {
Expand Down

0 comments on commit cf08e7b

Please sign in to comment.