From 1398a39779132974812ff1336f4af8e51b8e92cf Mon Sep 17 00:00:00 2001 From: JoelHMikael Date: Thu, 9 Dec 2021 08:19:20 +0200 Subject: Readability improvements buildMain in server.js --- index.html | 2 +- server.js | 45 +++++++++++++++++++++++++++------------------ shifts.txt | 42 +++++++++++++++++++++++------------------- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/index.html b/index.html index 08d35b6..61bbda3 100644 --- a/index.html +++ b/index.html @@ -39,7 +39,7 @@

\(foodshift-header\)

-

\(result\)

+

\(shift\)

diff --git a/server.js b/server.js index d15d04d..6dc41c5 100644 --- a/server.js +++ b/server.js @@ -69,34 +69,35 @@ async function buildMain(args) if (typeof query.index === "string") index = query.index.toUpperCase().replaceAll(".", "").replaceAll(" ", ""); const DB = args["db"]; - const data = await openFile(path); let data_string = data.toString("utf-8"); - let res; + let res = {}; + const d = new Date(); let day = d.getDay(); - if ((typeof query.day === "string") && (parseInt(query.day).toString() === query.day) && (!isNaN(parseInt(query.day))) && (parseInt(query.day) > 0) && (parseInt(query.day) < 7)) day = parseInt(query.day); + data_string = data_string.replace(`