update
This commit is contained in:
parent
962caebbb7
commit
87bf53d076
1825 changed files with 94929 additions and 0 deletions
31
2-ui/5-widgets/2-widgets-structure/1-clock/solution.view/clock.js
Executable file
31
2-ui/5-widgets/2-widgets-structure/1-clock/solution.view/clock.js
Executable file
|
@ -0,0 +1,31 @@
|
|||
function Clock(options) {
|
||||
var elem = options.elem;
|
||||
|
||||
var timer;
|
||||
|
||||
function render() {
|
||||
var date = new Date();
|
||||
|
||||
var hours = date.getHours();
|
||||
if (hours < 10) hours = '0' + hours;
|
||||
$('.hour', elem).html(hours);
|
||||
|
||||
var min = date.getMinutes();
|
||||
if (min < 10) min = '0' + min;
|
||||
$('.min', elem).html(min);
|
||||
|
||||
var sec = date.getSeconds();
|
||||
if (sec < 10) sec = '0' + sec;
|
||||
$('.sec', elem).html(sec);
|
||||
}
|
||||
|
||||
this.stop = function() {
|
||||
clearInterval(timer);
|
||||
};
|
||||
|
||||
this.start = function() {
|
||||
render();
|
||||
timer = setInterval(render, 1000);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue