UNPKG

soma.js

Version:

soma.js is a javascript framework created to build scalable and maintainable applications.

55 lines (46 loc) 1.5 kB
// Generated by CoffeeScript 1.6.2 (function() { (function(clock) { "use strict"; return clock.TimerModel = (function() { function TimerModel() { var i, l, tick, _this = this; this.callbacks = []; this.time = {}; i = 0; l = 0; tick = function() { var _results; _this.update(); i = 0; l = _this.callbacks.length; _results = []; while (i < l) { _this.callbacks[i](_this.time); _results.push(i++); } return _results; }; setInterval(tick, 1000); this.update(); } TimerModel.prototype.update = function() { this.time.now = new Date(); this.time.hours = this.time.now.getHours(); this.time.minutes = this.time.now.getMinutes(); this.time.seconds = this.time.now.getSeconds(); this.time.milliseconds = this.time.now.getMilliseconds(); this.time.day = this.time.now.getDay() + 1; this.time.date = this.time.now.getDate(); return this.time.month = this.time.now.getMonth() + 1; }; TimerModel.prototype.add = function(callback) { return this.callbacks.push(callback); }; TimerModel.prototype.remove = function(callback) { return this.callbacks.splice(this.callbacks.indexOf(callback, 1)); }; return TimerModel; })(); })(window.clock = window.clock || {}); }).call(this);