summaryrefslogtreecommitdiff
path: root/to/js
diff options
context:
space:
mode:
authors1n <[email protected]>2020-03-28 10:31:08 -0700
committers1n <[email protected]>2020-03-28 10:31:08 -0700
commit6b81836e6b9815a2996a55ad37dcaa4d89f99e42 (patch)
tree74bb9aa78ca31a6acfffd908e34dfb0df433c707 /to/js
parentCreate .gitignore (diff)
downloadcyne.cf-backup-master.tar.xz
cyne.cf-backup-master.zip
3/28/2020, 10:30HEADmaster
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..5fc3039
--- /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*60) {
+ timer = duration;
+ }
+ }, 1000);
+}
+
+window.onload = function () {
+ var fiveMinutes = 4 * 1, // 60 * 5
+ display = document.querySelector('#time');
+ startTimer(fiveMinutes, display);
+};