timekeeper

[Abandoned unfinished] CGI web application in C for time tracking. (My first, just a learning project)
Log | Files | Refs | README

commit 334c3728d0e769f0a79a65c32eb03e3590335f24
parent a2a9a6ed659d985aca1d008078b58d7c3886920c
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Tue,  5 Mar 2024 23:25:34 -0800

Cleanup main.js

Diffstat:
Mscripts/main.js | 20+++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/scripts/main.js b/scripts/main.js @@ -1,18 +1,13 @@ -function getduration(s) { - var hours = s.match(/(\d+)\s*h/); - var minutes = s.match(/(\d+)\s*m/); - var seconds = s.match(/(\d+)\s*s/); - return (parseInt(hours[1]) * 3600) + (parseInt(minutes[1]) * 60) + - parseInt(seconds[1]) -} - function gettime() { return Math.trunc(Date.now() / 1000) } -let start = document.getElementById("counter") -console.log(getduration(start.dateTime)) -let starttime = gettime() - getduration(start.dateTime) +function getduration(s) { + let hr = s.match(/(\d+)\s*h/); + let mn = s.match(/(\d+)\s*m/); + let sc = s.match(/(\d+)\s*s/); + return (parseInt(hr[1]) * 3600) + (parseInt(mn[1]) * 60) + parseInt(sc[1]) +} function sn(n) { return String(n).padStart(2, "0") @@ -29,4 +24,7 @@ function updatetime() { setTimeout(updatetime, 1000) } +let start = document.getElementById("counter") +let starttime = gettime() - getduration(start.dateTime) + updatetime()