-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
120 lines (98 loc) · 3.19 KB
/
script.js
File metadata and controls
120 lines (98 loc) · 3.19 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
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
114
115
116
117
118
119
120
let daysElement = document.getElementById("days");
let hoursElement = document.getElementById("hours");
let minutesElement = document.getElementById("minutes");
let secondsElement = document.getElementById("seconds");
let audio = document.getElementById("canon");
let button = document.getElementById("play");
var link = document.querySelector("link[rel~='icon']");
let occasionEl = document.getElementById("occasion");
//! VARIABLES TO CHANGE
// icon at the top of the page
let icon = "./icon.png";
// appears on the screen after the times
let occasion = "UNTIL MADE BY GOOGLE";
// when to count down to
let date = "Oct 4, 2023 10:00:00";
// color of the numbers counting down
let numColor = "#e0b528";
// color of the words, 'IT IS CURRENTLY' and occasion
let wordsColor = "#2d7a26";
// color of the words, 'DAYS', 'HOURS' ECT.
let hoursColor = "#d13838";
// what music to play
let music = "./canon-in-d.mp3";
// background image or color
let backgroundImage = "#386ed1";
// background color of the middle
let middleBackground = "white";
// border radius
let borderRadius = 25;
// says when it comes
let whatToSay = "Go to https://GoogleStore.com/events !!";
//! END OF TO CHANGE
link.href = icon;
occasionEl.innerHTML = occasion;
occasionEl.style.color = wordsColor;
var countDownDate = new Date(date).getTime();
days.style.color = numColor;
hours.style.color = numColor;
minutes.style.color = numColor;
seconds.style.color = numColor;
document.getElementById("itis").style.color = wordsColor;
document.getElementsByClassName("main")[0].style.color = hoursColor;
document.getElementsByClassName("main")[0].style.backgroundColor =
middleBackground;
document.getElementsByClassName(
"main"
)[0].style.borderRadius = `${borderRadius}px`;
audio.href = music;
if (backgroundImage.startsWith("http")) {
document.getElementsByClassName(
"wrapper"
)[0].style.backgroundImage = `url('${backgroundImage}')`;
} else {
document.getElementsByClassName("wrapper")[0].style.background =
backgroundImage;
}
// button.addEventListener("click", () => {
// audio.play();
// button.style.display = "none";
// });
let main = function () {
let now = new Date().getTime();
let timeleft = countDownDate - now;
let days = Math.floor(timeleft / (1000 * 60 * 60 * 24));
let hours = Math.floor((timeleft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
// const nowHours = new Date().getHours();
// let hours = 24 - nowHours;
// hours -= 1;
// hours = hours < 0 ? 23 : hours;
let minutes = Math.floor((timeleft % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((timeleft % (1000 * 60)) / 1000);
updateDom({
days,
hours,
minutes,
seconds,
timeleft,
});
};
let myfunc = setInterval(main, 1000);
function updateDom(time) {
// if(time.hours!=0){
// time.hours-=1;
// }else{
// time.hours=23;
// }
daysElement.innerHTML = time.days;
hoursElement.innerHTML = time.hours;
minutesElement.innerHTML = time.minutes;
secondsElement.innerHTML = time.seconds;
if (time.timeleft < 0) {
let h1 = document.createElement("h1");
h1.innerHTML = whatToSay;
document.getElementById("main").innerHTML = "";
document.getElementById("main").appendChild(h1);
}
}
main();