Skip to content

Instantly share code, notes, and snippets.

@akoppela
Created July 6, 2011 09:36
Show Gist options
  • Save akoppela/1066913 to your computer and use it in GitHub Desktop.
Save akoppela/1066913 to your computer and use it in GitHub Desktop.
Gamepon.Widget.Timer = new Class({
options: {
actions: {
timer: {
enable: function() {
var time = this.element.get('html').split(':');
this.seconds = time[2].toInt() + (time[1] * 60).toInt() + (time[0] * 3600).toInt();
this.decrementTime.periodical(1000, this);
},
disable: function() {
}
}
}
},
decrementTime: function() {
this.seconds--;
var time = [];
time[0] = (this.seconds / 3600).toInt();
time[1] = ((this.seconds - time[0] * 3600) / 60).toInt();
if (time[1] < 10) time[1] = '0' + time[1];
time[2] = this.seconds - time[0] * 3600 - time[1] * 60;
if (time[2] < 10) time[2] = '0' + time[2];
this.element.set('html', time.join(':'));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment