forked from zombieFox/nightTab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.js
More file actions
60 lines (55 loc) · 1.58 KB
/
Copy pathclock.js
File metadata and controls
60 lines (55 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var clock = (function() {
var clear = function() {
var clock = helper.e(".clock")
while (clock.lastChild) {
clock.removeChild(clock.lastChild);
};
};
var render = function() {
var time = helper.getDateTime();
if (time.minutes < 10) {
time.minutes = "0" + time.minutes;
};
if (time.seconds < 10) {
time.seconds = "0" + time.seconds;
};
// if (time.hours > 12) {
// time.hours = time.hours - 12;
// };
var hour = document.createElement("span");
hour.setAttribute("class", "clock-hour");
hour.textContent = time.hours;
var minutes = document.createElement("span");
minutes.setAttribute("class", "clock-minutes");
minutes.textContent = time.minutes;
var seconds = document.createElement("span");
seconds.setAttribute("class", "clock-seconds");
seconds.textContent = time.seconds;
var seperator1 = document.createElement("span");
seperator1.setAttribute("class", "clock-seperator");
seperator1.textContent = " : ";
var seperator2 = document.createElement("span");
seperator2.setAttribute("class", "clock-seperator");
seperator2.textContent = " : ";
var clock = helper.e(".clock");
clock.appendChild(hour);
clock.appendChild(seperator1);
clock.appendChild(minutes);
clock.appendChild(seperator2);
clock.appendChild(seconds);
};
var init = function() {
clear();
render();
window.setInterval(function() {
clear();
render();
}, 1000);
};
// exposed methods
return {
init: init,
render: render,
clear: clear
};
})();