forked from Saurav017/Kaushal_TechFest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
100 lines (73 loc) · 2.24 KB
/
script.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
const menu = document.querySelector('#mobile-menu');
const menuLinks = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-links')
const loader = document.querySelector('.loader');
const main = document.querySelector('.kaushal-website');
const body = document.querySelector('body')
// loader
function init() {
setTimeout(() => {
loader.style.opacity = 0;
loader.style.display = 'none';
main.style.display = 'block';
setTimeout(() => (main.style.opacity = 1), 50);
}, 10);
}
init();
// Navbar
menu.addEventListener('click', function () {
menu.classList.toggle('is-active');
console.log("Button is active");
menuLinks.classList.toggle('active');
body.classList.toggle('is-nav');
// Nav button scroll
for (var i = 0; i < navLinks.length; i++) {
var self = navLinks[i];
self.addEventListener(
"click",
function () {
menu.classList.remove('is-active');
menuLinks.classList.remove("active");
body.classList.remove("is-nav");
})
}
})
// Get a Date
const countdown = () => {
const countDate = new Date("Dec 17, 2021 00:00:00").getTime();
const now = new Date().getTime();
const gap = countDate - now;
const second = 1000;
const minute = second * 60;
const hour = minute * 60;
const day = hour * 24;
// Calculate the days
const festDay = Math.floor(gap / day);
console.log(festDay);
document.querySelector(".days-remaining span").innerText = festDay;
}
countdown()
// Modal
// Get the modal
let modal = document.getElementById("myModal");
// Get the button that opens the modal
let btn = document.querySelectorAll(".know-more");
// Get the <span> element that closes the modal
let span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
for (i of btn) {
i.addEventListener('click', function () {
console.log("Clicked");
modal.style.display = "block";
})
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}