Skip to content
This repository was archived by the owner on Jan 11, 2020. It is now read-only.

Commit 5ee4c8c

Browse files
devgupta2607prateek76
authored andcommitted
Add countdown timer (#276)
* Add countdown timer * Some problems solved * Night mode problem solved
1 parent bf7e9ee commit 5ee4c8c

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

css/main.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,39 @@
4242
background: -webkit-linear-gradient(left, rgb(247, 112, 55) 0%, rgb(250, 168, 68) 100%);
4343
}
4444

45+
.countdownContainer{
46+
position: relative;
47+
padding: 10px;
48+
max-width: 50%;
49+
max-height: 100%;
50+
margin: 20px auto;
51+
box-sizing: border-box;
52+
font-weight: 350;
53+
background-color: transparent !important;
54+
font-size: 3vw;
55+
56+
}
57+
58+
.info {
59+
position: inherit;
60+
padding: 10px;
61+
display: grid;
62+
grid-template-columns: 20% 5% 20% 5% 20% 5% 25%;
63+
align-items: center;
64+
}
65+
66+
.labels {
67+
position: inherit;
68+
display: grid;
69+
grid-template-columns: 25% 25% 25% 25%;
70+
text-align: center;
71+
}
72+
73+
.nightcountdown {
74+
background-color: transparent !important;
75+
color: #fff !important;
76+
}
77+
4578
.portfolio-item {
4679
margin-bottom: 30px;
4780
}

index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
<!-- Animate css -->
2626
<link rel="stylesheet" type="text/css" media="all" href="css/animate.css">
27+
28+
<!-- Font for countdown -->
29+
<link href='https://fonts.googleapis.com/css?family=Orbitron' rel='stylesheet' type='text/css'>
2730

2831
</head>
2932

@@ -75,6 +78,25 @@
7578
<h1 class="display-4 typing-anim-ref"><b>Hello, world!</b></h1>
7679
<h4 class="a-landing-sub-text">Welcome to OpenCode'19</h4>
7780
<a href="#participants"><button class="header-btn mt-5 a-btn">Get Started</button></a>
81+
82+
<div class="countdownContainer display-4 a-landing-header-text">
83+
<div class="values">OpenCode Countdown</div>
84+
<div class="info" style="font-family: 'Orbitron'">
85+
<div id="days" class="values">120</div>
86+
<div class="values"> </div>
87+
<div id="hours" class="values">4</div>
88+
<div class="values">:</div>
89+
<div id="minutes" class="values">12</div>
90+
<div class="values">:</div>
91+
<div id="seconds" class="values">22</div>
92+
</div>
93+
<div class="labels">
94+
<div class= "values">Days</div>
95+
<div class= "values">HH</div>
96+
<div class= "values">MM</div>
97+
<div class= "values">SS</div>
98+
</div>
99+
</div>
78100
</div>
79101

80102
<div class="container">

js/main.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,43 @@ function topFunction() {
1919
document.documentElement.scrollTop = 0;
2020
}
2121

22+
// For countdown timer
23+
function countdown(){
24+
var now = new Date();
25+
var eventDate = new Date(2019, 1, 12);
26+
27+
var currentTime = now.getTime();
28+
var eventTime = eventDate.getTime();
29+
30+
var remTime = eventTime - currentTime;
31+
32+
var s = Math.floor(remTime / 1000);
33+
var m = Math.floor(s / 60);
34+
var h = Math.floor(m / 60);
35+
var d = Math.floor(h / 24);
36+
37+
h %= 24;
38+
m %= 60;
39+
s %= 60;
40+
41+
42+
h = (h < 10) ? "0" + h : h ;
43+
m = (m < 10) ? "0" + m : m ;
44+
s = (s < 10) ? "0" + s : s;
45+
46+
document.getElementById("days").textContent = d;
47+
document.getElementById("days").innerText = d;
48+
49+
document.getElementById("hours").textContent = h;
50+
document.getElementById("minutes").textContent = m;
51+
document.getElementById("seconds").textContent = s;
52+
53+
setTimeout(countdown, 1000);
54+
55+
56+
}
57+
countdown();
58+
2259
$(document).ready(function() {
2360
var mentors;
2461
var participants;
@@ -497,6 +534,8 @@ $(document).ready(function(){
497534
$('.jumbotron').toggleClass('dark-bg-img')
498535
$('.dark-scrl-btn').toggleClass('dark')
499536
$('nav,div,footer').toggleClass('dark')
537+
$('.countdownContainer,.info,.labels,.values,.labellings').toggleClass('dark',false)
538+
$('.countdownContainer,.info,.labels,.values,.labellings').toggleClass('nightcountdown')
500539
$('h2,h3,h5').toggleClass('dark')
501540
$('span,img,ul,li').toggleClass('dark')
502541
$('h1,h4,a').toggleClass('dark-landing-text')

0 commit comments

Comments
 (0)