-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
113 lines (98 loc) · 3.28 KB
/
main.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var yearsMercuryPassed = 0;
function startMercuryCounter() {
document.getElementById('mercury-counter').innerHTML = yearsMercuryPassed + " ";
yearsMercuryPassed++;
setTimeout(startMercuryCounter, 3000);
}
startMercuryCounter()
var yearsVenusPassed = 0;
function startVenusCounter() {
document.getElementById('venus-counter').innerHTML = yearsVenusPassed + " ";
yearsVenusPassed++;
setTimeout(startVenusCounter, 4800);
}
startVenusCounter()
var yearsEarthPassed = 0;
function startEarthCounter() {
document.getElementById('earth-counter').innerHTML = yearsEarthPassed + " ";
yearsEarthPassed++;
setTimeout(startEarthCounter, 7200);
}
startEarthCounter()
var yearsMarsPassed = 0;
function startMarsCounter() {
document.getElementById('mars-counter').innerHTML = yearsMarsPassed + " ";
yearsMarsPassed++;
setTimeout(startMarsCounter, 12000);
}
startMarsCounter()
var revolvedAsteroidBelt = 0;
function startAsteroidBeltCounter() {
document.getElementById('asteroid-belt-counter').innerHTML = revolvedAsteroidBelt + " ";
revolvedAsteroidBelt++;
setTimeout(startAsteroidBeltCounter, 15000);
}
startAsteroidBeltCounter()
var yearsJupiterPassed = 0;
function startJupiterCounter() {
document.getElementById('jupiter-counter').innerHTML = yearsJupiterPassed + " ";
yearsJupiterPassed++;
setTimeout(startJupiterCounter, 18000);
}
startJupiterCounter()
var yearsSaturnPassed = 0;
function startSaturnCounter() {
document.getElementById('saturn-counter').innerHTML = yearsSaturnPassed + " ";
yearsSaturnPassed++;
setTimeout(startSaturnCounter, 36000);
}
startSaturnCounter()
var yearsUranusPassed = 0;
function startUranusCounter() {
document.getElementById('uranus-counter').innerHTML = yearsUranusPassed + " ";
yearsUranusPassed++;
setTimeout(startUranusCounter, 42000);
}
startUranusCounter()
var yearsNeptunePassed = 0;
function startNeptuneCounter() {
document.getElementById('neptune-counter').innerHTML = yearsNeptunePassed + " ";
yearsNeptunePassed++;
setTimeout(startNeptuneCounter, 60000);
}
startNeptuneCounter()
var yearsPlutoPassed = 0;
function startPlutoCounter() {
document.getElementById('pluto-counter').innerHTML = yearsPlutoPassed + " ";
yearsPlutoPassed++;
setTimeout(startPlutoCounter, 120000);
}
startPlutoCounter()
setInterval(showTime, 1000);
function showTime() {
let time = new Date();
let month = time.toLocaleString('default', { month: 'long' });
let date = time.getDate();
let year = time.getFullYear();
let hour = time.getHours();
let min = time.getMinutes();
let sec = time.getSeconds();
let am_pm = "AM";
if(month.toString().length == 1) {
month = '0'+month;
}
if (hour > 12) {
hour -= 12;
am_pm = "PM";
}
if (hour == 0) {
hour = 12;
am_pm = "AM";
}
hour = hour < 10 ? "0" + hour : hour;
min = min < 10 ? "0" + min : min;
sec = sec < 10 ? "0" + sec : sec;
let currentTime = month + " " + date + "," + " " + year + " " + "•" + " " + hour + ":" + min + ":" + sec + " " + am_pm;
document.getElementById("clock").innerHTML = currentTime;
}
showTime();