-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
114 lines (105 loc) · 3.73 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"
/>
<script
src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"
></script>
<style>
body {
margin: 10px;
text-align: center;
padding: auto;
}
p {
display: inline;
font-size: 40px;
}
h1 {
padding: 10px;
}
#card-wrapper {
margin-left: auto;
margin-right: auto;
padding: auto;
}
.card {
text-align: center;
}
</style>
</head>
<body>
<div id="title">
<h1>When is Sahil's Birthday?</h1>
</div>
<div id="card-wrapper">
<div class="card">
<div class="card-body">
<p id="days"></p>
<p id="hours"></p>
<p id="mins"></p>
<p id="secs"></p>
<h2 id="end"></h2>
</div>
</div>
</div>
<script>
// The data/time we want to countdown to
var birthday = new Date("Apr 24, 2021 00:00:00");
var today = new Date()
birthday.setFullYear(today.getFullYear())
// Not birthday
if (today.getDate() != 24 || today.getMonth() != 3) {
if (birthday < today) {
birthday.setFullYear(today.getFullYear() + 1)
}
}
var countDownDate = birthday.getTime();
console.log(birthday);
// Run myfunc every second
var myfunc = setInterval(function () {
var now = new Date().getTime();
var timeleft = countDownDate - now;
// Calculating the days, hours, minutes and seconds left
var days = Math.floor(timeleft / (1000 * 60 * 60 * 24));
var hours = Math.floor(
(timeleft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
var minutes = Math.floor((timeleft % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((timeleft % (1000 * 60)) / 1000);
// Result is output to the specific element
document.getElementById("days").innerHTML = days + "d ";
document.getElementById("hours").innerHTML = hours + "h ";
document.getElementById("mins").innerHTML = minutes + "m ";
document.getElementById("secs").innerHTML = seconds + "s ";
// Display the message when countdown is over
if (timeleft < 0) {
clearInterval(myfunc);
document.getElementById("days").innerHTML = "";
document.getElementById("hours").innerHTML = "";
document.getElementById("mins").innerHTML = "";
document.getElementById("secs").innerHTML = "";
document.getElementById("end").innerHTML = '<iframe width="560" height="315" src="https://www.youtube.com/embed/n9QCoA-Gh9Y?autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
}
}, 1000);
</script>
</body>
</html>