aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-01-23 17:42:17 +0200
committerJoel Kronqvist <joel.h.kronqvist@gmail.com>2022-01-23 17:42:17 +0200
commit8367989b42f0148df28e58ac492080a660c353a3 (patch)
tree8d41cd0c2e9639e8398efebbd539f52815e4d464
parent9c8fc9f997a42926dedffedaaead5bdd6e9fc96f (diff)
downloadLYLLRuoka-8367989b42f0148df28e58ac492080a660c353a3.tar.gz
LYLLRuoka-8367989b42f0148df28e58ac492080a660c353a3.zip
Exam info system added
It works only based on the current date. A better system would require good date functions, and right now if I want to make somethng for this project I should focus on either getting it working or making the code less messy (aka writing a big part of it again...). This was my first project of this scale, and the first one that seems to get finished & even published.
-rw-r--r--server.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/server.js b/server.js
index 046563f..7fa8154 100644
--- a/server.js
+++ b/server.js
@@ -1,13 +1,12 @@
-
-const http = require("http");
+//const http = require("http");
const https = require("https");
-const fs = require("fs");
const url = require("url");
const scrape = require("./scrape.js");
const SQL_DBS = require("./database.js");
const DBPARSE = require("./dbparse.js");
const openFile = require("./open.js").file;
-const updateDB = require("./update.js");
+const strFuncs = require("./funcs/stringFuncs.js");
+const dateFuncs = require("./funcs/dateFuncs.js");
async function init()
@@ -216,6 +215,23 @@ async function buildMain(args)
if (res["shift"] === -1)
res["shift"] = "Kurssilla/opettajalla/luokalla ei ole ruokailua päivällä tai kurssia ei ole olemassa!";
+ // Show message if the normal schedule isn't in place
+ const examInfo = await SQLDB.query("SELECT * FROM exams");
+ for(let week = 0; week < examInfo.length; week++)
+ {
+ if (dateFuncs.between(
+ d,
+ new Date(examInfo[week].start),
+ new Date(examInfo[week].end)
+ ))
+ {
+ const message = "<div id=\"foodshift\">" +
+ `<div class="float-block">${examInfo[week].message}</div>` +
+ "</div";
+ data_string = strFuncs.replaceElement(data_string, "div id=\"foodshift\"", message);
+ }
+ }
+
// get the example input
res["example-input"] = await DBPARSE.randomIndex(day, SQLDB);