From b84f599687a980abd117da856454948e8292ebea Mon Sep 17 00:00:00 2001 From: "Glitch (presence-button)" Date: Sat, 9 May 2020 20:19:32 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9A=F0=9F=8C=B4=20Checkpoint=20./serve?= =?UTF-8?q?r.js:933874/1408?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 14fff32..c234328 100644 --- a/server.js +++ b/server.js @@ -49,9 +49,13 @@ app.get("/img", (req, res) => { res.header("Pragma", "no-cache"); res.header("Expires", "0"); if (fuzIsOpen && new Date() - closingTimeout < lastSeen) { - return res.sendFile(__dirname + "/views/open.svg"); // https://www.flaticon.com/free-icon/open_1234189, maybe try https://flaticons.net/customize.php?dir=Miscellaneous&icon=Open.png without attribution + // https://www.iconfinder.com/icons/1871431/online_open_shop_shopping_sign_icon + // formerly https://www.flaticon.com/free-icon/open_1234189, maybe try https://flaticons.net/customize.php?dir=Miscellaneous&icon=Open.png without attribution + return res.sendFile(__dirname + "/views/open.svg"); } - res.sendFile(__dirname + "/views/closed.svg"); // https://www.flaticon.com/free-icon/closed_1234190, maybe try https://flaticons.net/customize.php?dir=Miscellaneous&icon=Closed.png without attribution + // https://www.iconfinder.com/icons/1871435/closed_online_shop_shopping_sign_icon + // formerly https://www.flaticon.com/free-icon/closed_1234190, maybe try https://flaticons.net/customize.php?dir=Miscellaneous&icon=Closed.png without attribution + res.sendFile(__dirname + "/views/closed.svg"); }); app.get("/api", (req, res) => { @@ -146,7 +150,7 @@ request.post( console.log("loop", lastClosed); if ( //fuzIsOpen && - lastSeen < new Date() - closingTimeout && + lastSeen < new Date() - defaultClosingTimeout && lastClosed < lastSeen ) { // the Fuz is newly closed, notify on matrix and write file to survive reboot @@ -197,6 +201,19 @@ request.post( } ); +const formatSeconds = function () { + var seconds = Math.floor(this), + hours = Math.floor(seconds / 3600); + seconds -= hours*3600; + var minutes = Math.floor(seconds / 60); + seconds -= minutes*60; + + if (hours < 10) {hours = "0"+hours;} + if (minutes < 10) {minutes = "0"+minutes;} + if (seconds < 10) {seconds = "0"+seconds;} + return hours+':'+minutes+':'+seconds; +} + if (process.env.PROJECT_DOMAIN != "") { process.on("SIGTERM", function() { console.log("SIGTERM received, sending SOS to Resurrect...");