summaryrefslogtreecommitdiff
path: root/to/js
diff options
context:
space:
mode:
authors1n <[email protected]>2019-10-20 19:09:53 -0700
committers1n <[email protected]>2019-10-20 19:09:53 -0700
commitca9c832f875194684f02b89feb2cf47f9f867491 (patch)
treec0ea440ac9306addd221c6f6314e1ea44db3f05b /to/js
parentformatting and linking for cars (diff)
downloads1n.pw-admin-ca9c832f875194684f02b89feb2cf47f9f867491.tar.xz
s1n.pw-admin-ca9c832f875194684f02b89feb2cf47f9f867491.zip
/to/ for link shortener, very useful :), grammer
Diffstat (limited to 'to/js')
-rw-r--r--to/js/countdown.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/to/js/countdown.js b/to/js/countdown.js
new file mode 100644
index 0000000..c31a289
--- /dev/null
+++ b/to/js/countdown.js
@@ -0,0 +1,25 @@
+function startTimer(duration, display) {
+ var timer = duration,
+ minutes, seconds;
+ setInterval(function () {
+ minutes = parseInt(timer / 60, 10);
+ seconds = parseInt(timer % 60, 10);
+
+ // minutes = minutes < 10 ? "0" + minutes : minutes;
+ seconds = seconds < 10 ? "" + seconds : seconds; // In "" should be 0
+
+ display.textContent = seconds;
+ // Original with minutes
+ // display.textContent = minutes + ":" + seconds;
+
+ if (--timer < 0) {
+ timer = duration;
+ }
+ }, 1000);
+}
+
+window.onload = function () {
+ var fiveMinutes = 5 * 1, // 60 * 5
+ display = document.querySelector('#time');
+ startTimer(fiveMinutes, display);
+}; \ No newline at end of file