-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.js
86 lines (67 loc) · 2.64 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
// Setup End Date for Countdown (getTime == Time in Milleseconds)
let launchDate = new Date("Nov 09, 2021 00:00:00").getTime();
// Setup Timer to tick every 1 second
let timer = setInterval(tick, 1000);
function tick () {
// Get current time
let now = new Date().getTime();
// Get the difference in time to get time left until reaches 0
let t = launchDate - now;
// Check if time is above 0
if (t > 0) {
// Setup Days, hours, seconds and minutes
// Algorithm to calculate days...
let days = Math.floor(t / (1000 * 60 * 60 * 24));
// prefix any number below 10 with a "0" E.g. 1 = 01
if (days < 10) { days = "0" + days; }
// Algorithm to calculate hours
let hours = Math.floor((t % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
if (hours < 10) { hours = "0" + hours; }
// Algorithm to calculate minutes
let mins = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60));
if (mins < 10) { mins = "0" + mins; }
// Algorithm to calc seconds
let secs = Math.floor((t % (1000 * 60)) / 1000);
if (secs < 10) { secs = "0" + secs; }
// Create Time String
let time = `${days} : ${hours} : ${mins} : ${secs}`;
// Set time on document
document.querySelector('.countdown').innerText = time;
}
}
//Accordion
document.addEventListener("DOMContentLoaded", function(event) {
var acc = document.getElementsByClassName("accordion");
var panel = document.getElementsByClassName('panel');
for (var i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
var setClasses = !this.classList.contains('active');
setClass(acc, 'active', 'remove');
setClass(panel, 'show', 'remove');
if (setClasses) {
this.classList.toggle("active");
this.nextElementSibling.classList.toggle("show");
}
}
}
function setClass(els, className, fnName) {
for (var i = 0; i < els.length; i++) {
els[i].classList[fnName](className);
}
}
});
// Nav button hide
var links = document.querySelectorAll('.nav-links');
var linksLength = links.length
for(var i = 0; i < linksLength; i++) {
links[i].addEventListener('click', function() {
document.getElementById('check').checked = false;
});
}
var links1 = document.querySelectorAll('.logo-container');
var linksLength1 = links1.length
for(var j = 0; j < linksLength1; j++) {
links1[j].addEventListener('click', function() {
document.getElementById('check').checked = false;
});
}