From 8367989b42f0148df28e58ac492080a660c353a3 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 23 Jan 2022 17:42:17 +0200 Subject: 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. --- server.js | 24 ++++++++++++++++++++---- 1 file 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 = "
" + + `
${examInfo[week].message}
` + + "