This commit is contained in:
Ilya Kantor 2016-08-05 16:53:08 +03:00
parent 4c531b5ae7
commit d4c714cbe1
261 changed files with 7370 additions and 546 deletions

View file

@ -0,0 +1,32 @@
function Clock(options) {
var template = options.template;
var timer;
function render() {
var date = new Date();
var hours = date.getHours();
if (hours < 10) hours = '0' + hours;
var min = date.getMinutes();
if (min < 10) min = '0' + min;
var sec = date.getSeconds();
if (sec < 10) sec = '0' + sec;
var output = template.replace('h', hours).replace('m', min).replace('s', sec);
console.log(output);
}
this.stop = function() {
clearInterval(timer);
};
this.start = function() {
render();
timer = setInterval(render, 1000);
}
}