diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..064bc2d --- /dev/null +++ b/README.MD @@ -0,0 +1,8 @@ +# openCountdown + +# ToDo +- [X] Pausing functions +- [X] Presets +- [ ] Progress bar +- [ ] time on countdown page +- [ ] one-way messaging \ No newline at end of file diff --git a/index.js b/index.js index e8bd322..9c009ec 100644 --- a/index.js +++ b/index.js @@ -18,9 +18,11 @@ app.use( currentState = { mode: "clock", countdownGoal: new Date().getTime(), - changed: true, showMilliSeconds: true, - defaultFullScreen: true + defaultFullScreen: true, + timeAmountInital: 0, + timerRunState: true, + pauseMoment: 0 }; app.get("/", function (req, res) { @@ -28,13 +30,6 @@ app.get("/", function (req, res) { res.send(data); }); -app.post("/", function (req, res) { - console.log(req.body); - currentState.mode = req.body.mode; - currentState.countdownGoal = req.body.countdownGoal; - res.send("OK"); -}); - app.get("/timer", function (req, res) { const data = fs.readFileSync("templates/timerPage.html", "utf8"); res.send(data); @@ -60,9 +55,26 @@ app.get("/api/v1/set/timerGoal", function (req, res) { }); app.get("/api/v1/set/addMillisToTimer", function (req, res) { - console.log(req.query.time) + currentState.timeAmountInital = req.query.time; currentState.countdownGoal = new Date().getTime() + parseInt(req.query.time) res.json({ status: "ok" }); }); +app.get("/api/v1/ctrl/timer/pause", function (req, res) { + currentState.timerRunState = false; + currentState.pauseMoment = new Date().getTime(); + res.json({ status: "ok" }); +}); + +app.get("/api/v1/ctrl/timer/play", function (req, res) { + currentState.timerRunState = true + currentState.countdownGoal += new Date().getTime() - currentState.pauseMoment; + res.json({ status: "ok" }); +}); + +app.get("/api/v1/ctrl/timer/restart", function (req, res) { + currentState.countdownGoal = new Date().getTime() + parseInt(currentState.timeAmountInital) + res.json({ status: "ok" }); +}); + app.listen(3005); diff --git a/static/js/interface.js b/static/js/interface.js index a3ea68e..5b0a466 100644 --- a/static/js/interface.js +++ b/static/js/interface.js @@ -3,6 +3,6 @@ function convertTimeOffset(){ document.getElementById("time").value = selTime } -function updateHiddenForm(){ - document.getElementById("time").value = document.getElementById('time2').valueAsNumber +function updateHiddenForm2(){ + document.getElementById("time4").value = document.getElementById('time3').value } \ No newline at end of file diff --git a/static/js/script.js b/static/js/script.js index 088625a..f865928 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -60,13 +60,12 @@ function handleUpdate() { document.getElementById("testImg").style.display = "none"; } else if (data.mode == "timer") { - const now = new Date() - const diff = data.countdownGoal - now.getTime() - - - - document.getElementById("timer").innerHTML = msToTime(diff, data); - document.getElementById("testImg").style.display = "none"; + if(data.timerRunState){ + const now = new Date() + const diff = data.countdownGoal - now.getTime() + document.getElementById("timer").innerHTML = msToTime(diff, data); + document.getElementById("testImg").style.display = "none"; + } } else if (data.mode == "black") { document.getElementById("timer").innerHTML = ""; diff --git a/templates/adminPanel.html b/templates/adminPanel.html index 7606dea..51e6927 100644 --- a/templates/adminPanel.html +++ b/templates/adminPanel.html @@ -3,47 +3,73 @@ - - + + - openCountdown - Admin - - + openCountdown - Admin + + - + -
+ + + + + + -
-
-
- - -
+ +
+
+ + +
-
- - - -
+
+ + + +
- +
+ + +
+ +
+ +
+
+ +
+
+ +
+ + - + + \ No newline at end of file