From 776605926111b462bba2d397b150b0447da8b6d9 Mon Sep 17 00:00:00 2001 From: zlg Date: Sat, 1 Apr 2023 23:41:02 -0700 Subject: Initial commit This is a simple streaming timer meant to be hooked up to OBS and customized using a separate CSS file. --- timer.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 timer.js (limited to 'timer.js') diff --git a/timer.js b/timer.js new file mode 100644 index 0000000..e2e9380 --- /dev/null +++ b/timer.js @@ -0,0 +1,49 @@ +let params; +let cur_seconds = null; +let timer_id; +const cd = document.getElementById("countdown"); + +function setupCountdown() { + params = new URLSearchParams(document.location.search); + for ([key, value] of params.entries()) { + console.log(`${key}: ${value}`); + } + + cur_seconds = parseInt(params.get("duration")); + + if (params.get("f_family") !== "") { + cd.style.fontFamily = params.get("f_family"); + } + cd.style.color = params.get("f_color"); + + draw(); + timer_id = window.setInterval(tick, 1000); +} + +function tick() { + if (cur_seconds == 0) { + while (cd.firstChild) { + cd.removeChild(cd.firstChild); + } + let end_msg = document.createElement("div"); + end_msg.textContent = params.get("end_text"); + cd.appendChild(end_msg); + window.clearInterval(timer_id); + return; + } + cur_seconds--; + draw(); +} + +function draw() { + document.getElementById("minutes").textContent = zero_pad(Math.floor(cur_seconds / 60)); + document.getElementById("seconds").textContent = zero_pad((cur_seconds % 60)); +} + +function zero_pad(num) { + if (num < 10) { + return "0"+num; + } else { + return num; + } +} -- cgit v1.2.3-54-g00ecf /1-23_decomment.c?id=893e4a375873f4b98d8691ffafbba8a2ccb1b55d&follow=1'>diff
path: root/ch1/1-23_decomment.c (unfollow)
de6ace1f0355c4c16&follow=1'>Bump to 0.3alpha6 for PyPI
AgeCommit message (Collapse)AuthorFilesLines
2014-05-21Refactor flag handlingzlg3-24/+51
zlg1-1/+1
2018-10-09cli: Add "notes" commandzlg2-4/+74
2018-10-09update_game: ensure notes are also savedzlg1-2/+2
2018-10-09cli: add 'update' commandzlg3-20/+92
2018-10-06cli: Add "delete" commandzlg2-0/+19
2018-10-06Remove ID field from DBzlg3-38/+46
2018-10-06cli: change "Status" heading to "Progress"zlg2-36/+40
2018-09-29Bump to 0.3alpha5 for PyPIzlg1-1/+1
2018-09-29cli: Add pretty printing to 'list' commandzlg3-17/+107
2018-09-08setup.py: Bump to alpha4 for PyPIzlg1-1/+1
2018-09-08cli: add '--raw' option to list commandzlg2-9/+45
2018-09-08Add remaining filters to vgstash packagezlg1-2/+11
2018-09-04Update LICENSE to match setup.pyzlg1-80/+67
2018-09-03Branch off from master with pytest, tox, clickzlg16-778/+779
2018-03-18Flesh out filter types and ownership statuszlg3-82/+144
2018-03-18README.mdown: break line correctlyzlg1-1/+1
2018-03-18add 'playlog' list filterzlg2-2/+9
2018-03-13Update helpers a bitzlg1-2/+9
2018-03-13Make VGSTASH_DB_LOCATION point to a filezlg2-21/+20
2016-11-18Remove settings from helpers.shZe Libertine Gamer1-5/+0
2016-11-15Correct phrasing in README.Ze Libertine Gamer1-4/+4
2016-11-13DerpZe Libertine Gamer1-0/+1
2016-11-03Improve error handling in shell scriptsZe Libertine Gamer4-3/+23
2016-10-24Correct run_again, add recursionZe Libertine Gamer1-0/+4
2016-10-21Add quotes to correct behavior for arglistZe Libertine Gamer1-1/+1
2016-10-14updater.sh: add recursion, error handlingZe Libertine Gamer1-43/+101
2016-10-14Correct pipe-handling behaviorZe Libertine Gamer1-1/+9
2016-10-12Clarify a method to move between platformsZe Libertine Gamer1-2/+5