renamed _timer to timer

This commit is contained in:
Manuel Friedli 2014-07-03 21:16:47 +02:00
parent 08cca0a915
commit ec9b44427c

View file

@ -58,7 +58,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
var start = function start() { var start = function start() {
if (!isOn(this)) { if (!isOn(this)) {
var uhr = this; var uhr = this;
this._timer = window.setInterval(function uhrTimer() { this.timer = window.setInterval(function uhrTimer() {
uhr.options.time = new Date(); uhr.options.time = new Date();
update(uhr); update(uhr);
}, 1000); }, 1000);
@ -68,8 +68,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}; };
var stop = function stop() { var stop = function stop() {
if (isOn(this)) { if (isOn(this)) {
window.clearInterval(this._timer); window.clearInterval(this.timer);
this._timer = null; this.timer = null;
update(this); update(this);
setCookie(this, 'uhr-status', 'off'); setCookie(this, 'uhr-status', 'off');
} }
@ -107,8 +107,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
if (time === null) { if (time === null) {
this.options.time = new Date(); this.options.time = new Date();
} else { } else {
if (this._timer !== null) { if (this.timer !== null) {
window.clearInterval(this._timer); window.clearInterval(this.timer);
} }
this.options.time = time; this.options.time = time;
} }
@ -118,6 +118,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// private interface methods // private interface methods
var create = function create() { var create = function create() {
this._id = uhrGlobals.id++; this._id = uhrGlobals.id++;
this.timer = null;
this._currentMinute = -1;
var userTime = this.options.time; var userTime = this.options.time;
if (this.options.time === undefined) { if (this.options.time === undefined) {
this.options.time = new Date(); this.options.time = new Date();
@ -265,7 +267,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// business logic // business logic
var isOn = function isOn(uhr) { var isOn = function isOn(uhr) {
return uhr._timer !== null; return uhr.timer !== null;
}; };
var update = function update(uhr) { var update = function update(uhr) {
if (isOn(uhr)) { if (isOn(uhr)) {
@ -349,11 +351,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
"theme": setTheme, "theme": setTheme,
"time": setTime, "time": setTime,
// constructor method // constructor method
"_create": create, "_create": create
// private variables
"_id": -1,
"_timer": null,
"_currentMinute": -1
}); });
$.fritteli.uhr.register = uhrGlobals.registerLanguage; $.fritteli.uhr.register = uhrGlobals.registerLanguage;
/** /**