From a6b996d77237e5685dd8de39b1e0f3c26d64c8d6 Mon Sep 17 00:00:00 2001 From: lub Date: Thu, 13 Jun 2019 18:16:36 +0200 Subject: [PATCH] init --- index.html | 15 +++++++++++++++ main.css | 6 ++++++ main.js | 26 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 index.html create mode 100644 main.css create mode 100644 main.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..423dcb7 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + Good Times ahead + + + + ∞∞ Days
+ ∞∞ Hours
+ ∞∞ Minutes
+ ∞∞ Seconds
+ + + + \ No newline at end of file diff --git a/main.css b/main.css new file mode 100644 index 0000000..af8b8c2 --- /dev/null +++ b/main.css @@ -0,0 +1,6 @@ +body { + background-color: black; + color: #0f0; + font-family: monospace; + font-size: 4rem; +} \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..95fe626 --- /dev/null +++ b/main.js @@ -0,0 +1,26 @@ +const target = new Date('2019-06-21T10:54:00+02:00'); + +const second = 1000; +const minute = second*60; +const hour = minute*60; +const day = hour*24; + +setInterval(() => { + const now = new Date(); + const diff = target - now; + + const timeleft = {}; + timeleft.days = Math.floor(diff/day); + timeleft.hours = Math.floor(diff%day/hour); + timeleft.minutes = Math.floor(diff%day%hour/minute); + timeleft.seconds = Math.floor(diff%day%hour%minute/second); + + Object.keys(timeleft).forEach((unit) => { + // retrieve value, cast it to string and optionally pad it with a leading 0 + const value = timeleft[unit] + .toString() + .padStart(2, '0'); + + document.getElementById(unit).innerHTML = value; + }); +}, 500); \ No newline at end of file