Skip to content

Commit f28c7a0

Browse files
committed
Add countdown
1 parent c8cde0f commit f28c7a0

3 files changed

Lines changed: 108 additions & 3 deletions

File tree

_includes/countdown.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const countDownDate = new Date("{{ include.date }}").getTime();
2+
3+
document.addEventListener("DOMContentLoaded", () => {
4+
(function updateTimer() {
5+
let now = new Date().getTime();
6+
let distance = countDownDate - now;
7+
let days = Math.floor(distance / (1000 * 60 * 60 * 24));
8+
let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
9+
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
10+
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
11+
12+
document.getElementById("days").children[0].innerHTML = String(days).padStart(2, '0');
13+
document.getElementById("hours").children[0].innerHTML = String(hours).padStart(2, '0');
14+
document.getElementById("minutes").children[0].innerHTML = String(minutes).padStart(2, '0');
15+
document.getElementById("seconds").children[0].innerHTML = String(seconds).padStart(2, '0');
16+
17+
if (distance >= 0) {
18+
setTimeout(updateTimer, 1000)
19+
}
20+
})();
21+
});

css/main.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
--color-heading-inv: #111;
2626
--color-text-inv: #000;
2727

28+
--text-smaller: 0.8rem;
2829
--text-small: 0.9rem;
2930
--text-normal: 1.05rem;
3031
--text-large: 1.5rem;
@@ -202,6 +203,7 @@ div.schedule {
202203
// background-color: var(--color-background-light);
203204
background-color: var(--color-background-alt);
204205
margin-top: 1rem;
206+
padding-bottom: 2rem;
205207

206208
div.days {
207209
display: flex;
@@ -273,6 +275,43 @@ div.partners-container {
273275
}
274276
}
275277

278+
div#timer {
279+
display: flex;
280+
flex-direction: row;
281+
gap: 2rem;
282+
align-items: center;
283+
justify-content: center;
284+
font-family: var(--font-monospace);
285+
286+
div#timer-time {
287+
display: flex;
288+
flex-direction: row;
289+
gap: 1.5rem;
290+
align-items: center;
291+
292+
div {
293+
display: flex;
294+
flex-direction: column;
295+
align-items: center;
296+
}
297+
298+
div:not(:last-child) {
299+
border-right: 1px solid var(--color-text);
300+
padding-right: 1.5rem;
301+
}
302+
303+
div span.count {
304+
color: var(--color-primary);
305+
font-weight: 700;
306+
font-size: 3rem;
307+
}
308+
309+
div span.label {
310+
font-size: var(--text-smaller);
311+
}
312+
}
313+
}
314+
276315
div.faqs {
277316

278317
}
@@ -396,4 +435,8 @@ div.footer-content {
396435
align-items: flex-start;
397436
}
398437
}
438+
439+
div#timer {
440+
flex-direction: column;
441+
}
399442
}

index.html

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@
7070
- name: AlgoSoc
7171
logo: /assets/algosoc-logo-colour.png
7272
colour: "0B0000"
73-
url: ""
73+
url: "https://www.guildofstudents.com/organisation/algosoc/"
7474
- name: Games Development Society
7575
logo: /assets/gds-logo-colour.png
7676
colour: "fff"
77-
url: ""
77+
url: "https://www.guildofstudents.com/organisation/gamesdevelopment/"
7878
- name: Guild of Students
7979
logo: /assets/gos-logo-colour.png
8080
colour: "eee"
8181
url: https://guildofstudents.com
8282
- name: The Univeristy of Birmingham School of Computer Science
8383
logo: /assets/uob-logo-colour.png
8484
colour: "eee"
85-
url: https://cs.bham.ac.uk
85+
url: https://www.cs.bham.ac.uk
8686
faqs:
8787
- question: What's a hackathon?
8888
answer: |
@@ -200,6 +200,44 @@ <h3 class="header">{{ day.day }}</h3>
200200
<p class="disclaimer">* This schedule is not final; it is subject to change.</p>
201201
{% endunless %}
202202
</div>
203+
204+
<div id="timer">
205+
<div id="timer-time">
206+
<div id="days">
207+
<span class="count">
208+
--
209+
</span>
210+
<span class="label">
211+
days
212+
</span>
213+
</div>
214+
<div id="hours">
215+
<span class="count">
216+
--
217+
</span>
218+
<span class="label">
219+
hours
220+
</span>
221+
</div>
222+
<div id="minutes">
223+
<span class="count">
224+
--
225+
</span>
226+
<span class="label">
227+
minutes
228+
</span>
229+
</div>
230+
<div id="seconds">
231+
<span class="count">
232+
--
233+
</span>
234+
<span class="label">
235+
seconds
236+
</span>
237+
</div>
238+
</div>
239+
<span class="timer-label">until birmingHack starts!</span>
240+
</div>
203241
</div>
204242

205243
<div id="partners" class="partners section">
@@ -226,3 +264,6 @@ <h2 class="section-title">FAQs</h2>
226264
{% endfor %}
227265
</div>
228266

267+
<script>
268+
{% include countdown.js date="Mar 22, 2025 09:00:00" %}
269+
</script>

0 commit comments

Comments
 (0)