mirror of
https://github.com/marcogll/soul23_placeholder_site_server.git
synced 2026-01-13 13:25:18 +00:00
feat: Add initial project structure with HTML, CSS, JavaScript libraries, and image assets.
This commit is contained in:
33
js/countdown.js
Normal file
33
js/countdown.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var dateData = document.getElementById('countdown-timer').getAttribute('data-date');
|
||||
var countDownDate = new Date(dateData).getTime();
|
||||
|
||||
// Update the count down every 1 second
|
||||
var x = setInterval(function () {
|
||||
|
||||
// Get todays date and time
|
||||
var now = new Date().getTime();
|
||||
|
||||
// Find the distance between now an the count down date
|
||||
var distance = countDownDate - now;
|
||||
|
||||
// Time calculations for days, hours, minutes and seconds
|
||||
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
||||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||
|
||||
if (distance > 0) {
|
||||
$("div[name='seconds']").html(seconds);
|
||||
$("div[name='minutes']").html(minutes);
|
||||
$("div[name='hours']").html(hours);
|
||||
$("div[name='days']").html(days);
|
||||
}
|
||||
else {
|
||||
$("div[name='seconds']").html("-");
|
||||
$("div[name='minutes']").html("-");
|
||||
$("div[name='hours']").html("-");
|
||||
$("div[name='days']").html("-");
|
||||
}
|
||||
|
||||
}, 1000);
|
||||
|
||||
Reference in New Issue
Block a user