function Countdowner(data){
};
Countdowner.prototype = {
injectTo: function(element) {
},
init: function(y,m,d) {
this.todat = new Date(y,m,d);
},
start: function() {
setInterval(this.redraw.bind(this), 1000);
},
stop: function() {
clearInterval(this.redraw);
},
redraw: function() {
this.fromdate = Date.now();
console.log('<--------------------------------------->');
this.resdate = (this.todat-this.fromdate);
this.remDays = Math.floor(this.resdate/1000/60/60/24);
this.resdate -= this.remDays*1000*60*60*24;
this.remHours = Math.floor(this.resdate/1000/60/60);
this.resdate -= this.remHours*1000*60*60;
this.remMin = Math.floor(this.resdate/1000/60);
this.resdate -=this.remMin*1000*60;
this.remSec = Math.floor(this.resdate/1000);
console.log('Days:'+this.remDays+' Hours:'+this.remHours+' Minutes:'+this.remMin+' Seconds:'+this.remSec);
}
};
var count1 = new Countdowner();
count1.init(2016, 0, 1);
count1.start();
|