Compare commits

...

4 Commits

Author SHA1 Message Date
b21bbb7e3e fixed some vulns 2024-08-18 22:27:27 +02:00
f32790706e - fixed issue with faulty progress bar
- fixed issue with config-safe-states
2023-08-09 15:25:29 +02:00
cec31d81f0 inital fix for misbehaviour of relativAdd 2023-08-08 21:42:46 +02:00
704ecb4249 finally introduced CNTDWN-1 (allow/disallow overrun) 2023-08-07 16:59:38 +02:00
9 changed files with 247 additions and 174 deletions

348
index.js
View File

@ -1,14 +1,14 @@
const express = require("express"); const express = require("express");
const fs = require("fs"); const fs = require("fs");
const bodyParser = require("body-parser"); const bodyParser = require("body-parser");
const ws = require('ws'); const ws = require("ws");
const helper = require("./helpers.js"); const helper = require("./helpers.js");
const loggy = require("./logging") const loggy = require("./logging");
const Eta = require("eta"); const Eta = require("eta");
const _ = require("underscore") const _ = require("underscore");
const path = require("path") const path = require("path");
loggy.init(true) loggy.init(true);
loggy.log("Preparing server", "info", "Server"); loggy.log("Preparing server", "info", "Server");
const app = express(); const app = express();
@ -27,25 +27,26 @@ app.use(
// Allowed urls for requests to /assets/ // Allowed urls for requests to /assets/
const allowsURLs = [ const allowsURLs = [
'bootstrap-icons/font/bootstrap-icons.css', "bootstrap-icons/font/bootstrap-icons.css",
'js-cookie/dist/js.cookie.min.js', "js-cookie/dist/js.cookie.min.js",
'bootstrap/dist/css/bootstrap.min.css', "bootstrap/dist/css/bootstrap.min.css",
'mdbootstrap/css/style.css', "mdbootstrap/css/style.css",
'bootstrap/dist/js/bootstrap.bundle.min.js', "bootstrap/dist/js/bootstrap.bundle.min.js",
'jquery/dist/jquery.min.js', "jquery/dist/jquery.min.js",
'darkreader/darkreader.js', "darkreader/darkreader.js",
'bootstrap-duration-picker/dist/bootstrap-duration-picker.css', "bootstrap-duration-picker/dist/bootstrap-duration-picker.css",
'flatpickr/dist/flatpickr.min.css', "flatpickr/dist/flatpickr.min.css",
'bootstrap-duration-picker/dist/bootstrap-duration-picker-debug.js', "bootstrap-duration-picker/dist/bootstrap-duration-picker-debug.js",
'flatpickr/dist/flatpickr.js', "flatpickr/dist/flatpickr.js",
'bootstrap-icons/font/fonts/bootstrap-icons.woff2', "bootstrap-icons/font/fonts/bootstrap-icons.woff2",
'bootstrap/dist/css/bootstrap.min.css.map', "bootstrap/dist/css/bootstrap.min.css.map",
'less/dist/less.min.js', "less/dist/less.min.js",
'less/dist/less.min.js.map', "less/dist/less.min.js.map",
'mdbootstrap/js/mdb.min.js' "mdbootstrap/js/mdb.min.js",
]; ];
let loadedData = {} let loadedData = {};
let dataToBeWritten = {}
loggy.log("Loading config", "info", "Config"); loggy.log("Loading config", "info", "Config");
if (fs.existsSync("data-persistence.json")) { if (fs.existsSync("data-persistence.json")) {
@ -68,18 +69,26 @@ currentState = {
showMessage: false, showMessage: false,
messageAppearTime: 0, messageAppearTime: 0,
showProgressbar: true, showProgressbar: true,
colorSegments: { 40000: "yellow", 20000: "#FFAE00", 5000: "#ff0000", "START": "green" }, colorSegments: {
40000: "yellow",
20000: "#FFAE00",
5000: "#ff0000",
START: "green",
},
textColors: {}, textColors: {},
srvTime: 0, srvTime: 0,
enableColoredText: true, enableColoredText: true,
debug: false, debug: false,
sessionToken: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), enableOverrun: true,
sessionToken:
Math.random().toString(36).substring(2, 15) +
Math.random().toString(36).substring(2, 15),
}; };
let configObject = { let configObject = {
language: "en_uk", language: "en_uk",
port: 3000 port: 3000,
} };
if (!fs.existsSync("config.json")) { if (!fs.existsSync("config.json")) {
fs.writeFileSync("config.json", "{}"); fs.writeFileSync("config.json", "{}");
} }
@ -88,9 +97,9 @@ configObject = _.extend(configObject, tempJsonText);
fs.writeFileSync("config.json", JSON.stringify(configObject)); fs.writeFileSync("config.json", JSON.stringify(configObject));
currentState = Object.assign({}, currentState, loadedData); currentState = Object.assign({}, currentState, loadedData);
currentState.textColors = currentState.colorSegments currentState.textColors = currentState.colorSegments;
loggy.log("Searching for languages", "info", "Language") loggy.log("Searching for languages", "info", "Language");
const languagesRaw = fs.readdirSync("./lang"); const languagesRaw = fs.readdirSync("./lang");
const languages = []; const languages = [];
for (let i = 0; i < languagesRaw.length; i++) { for (let i = 0; i < languagesRaw.length; i++) {
@ -98,19 +107,19 @@ for (let i = 0; i < languagesRaw.length; i++) {
languages.push(languagesRaw[i].replace(".json", "")); languages.push(languagesRaw[i].replace(".json", ""));
} }
} }
loggy.log("Found " + languages.length + " languages", "info", "Language") loggy.log("Found " + languages.length + " languages", "info", "Language");
loggy.log("Reading language file", "info", "Language");
let languageProfile = JSON.parse(
loggy.log("Reading language file", "info", "Language") fs.readFileSync("lang/" + configObject.language + ".json", "utf8")
let languageProfile = JSON.parse(fs.readFileSync("lang/" + configObject.language + ".json", "utf8")); );
loggy.log("Preparing websocket", "info", "Websocket"); loggy.log("Preparing websocket", "info", "Websocket");
const wsServer = new ws.Server({ noServer: true }); const wsServer = new ws.Server({ noServer: true });
wsServer.on('connection', socket => { wsServer.on("connection", (socket) => {
socket.on('message', function incoming(data) { socket.on("message", function incoming(data) {
if (data.toString() == "new client") { if (data.toString() == "new client") {
updatedData() updatedData();
} }
}); });
}); });
@ -126,7 +135,7 @@ wsServer.broadcast = function broadcast(data) {
let updatey = undefined; let updatey = undefined;
function updatedData() { function updatedData() {
currentState.srvTime = new Date().getTime() currentState.srvTime = new Date().getTime();
wsServer.broadcast(JSON.stringify(currentState)); wsServer.broadcast(JSON.stringify(currentState));
clearTimeout(updatey); clearTimeout(updatey);
setTimeout(updatedData, 5000); setTimeout(updatedData, 5000);
@ -140,18 +149,20 @@ app.get("/", function (req, res) {
Eta.render(data, { Eta.render(data, {
lang: languageProfile, lang: languageProfile,
additional: { additional: {
languages: languages languages: languages,
} },
})); })
);
} catch (e) { } catch (e) {
loggy.log("Error rendering template", "error", "Server"); loggy.log("Error rendering template", "error", "Server");
const dataN = fs.readFileSync("templates/brokenTranslation.html", "utf8"); const dataN = fs.readFileSync("templates/brokenTranslation.html", "utf8");
res.send( res.send(
Eta.render(dataN, { Eta.render(dataN, {
additional: { additional: {
languages: languages languages: languages,
} },
})); })
);
} }
}); });
@ -166,7 +177,7 @@ app.get("/timer-old", function (req, res) {
}); });
app.get("/api/v1/data", function (req, res) { app.get("/api/v1/data", function (req, res) {
currentState.srvTime = new Date().getTime() currentState.srvTime = new Date().getTime();
res.json(currentState); res.json(currentState);
}); });
@ -187,166 +198,181 @@ app.get("/api/v1/system", function (req, res) {
nodeEnv: process.env, nodeEnv: process.env,
nodeConfig: process.config, nodeConfig: process.config,
nodeTitle: process.title, nodeTitle: process.title,
systemVersion: tempPkgObj.version systemVersion: tempPkgObj.version,
} };
res.json(systemData); res.json(systemData);
}); });
app.get("/api/v1/set/mode", function (req, res) { app.get("/api/v1/set/mode", function (req, res) {
currentState.mode = req.query.mode; currentState.mode = req.query.mode;
updatedData() updatedData();
res.json({ status: "ok" }); res.json({ status: "ok" });
}); });
app.get("/api/v1/set/layout/showMillis", function (req, res) { app.get("/api/v1/set/layout/showMillis", function (req, res) {
const resy = helper.wrapBooleanConverter(req.query.show, res) const resy = helper.wrapBooleanConverter(req.query.show, res);
if (resy != undefined) { if (resy != undefined) {
currentState.showMilliSeconds = resy; currentState.showMilliSeconds = resy;
if (req.query.persist === 'true') { if (req.query.persist === "true") {
dataToBeWritten.showMilliSeconds = currentState.showMilliSeconds dataToBeWritten.showMilliSeconds = currentState.showMilliSeconds;
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
} }
updatedData() updatedData();
}); });
app.get("/api/v1/set/timerGoal", function (req, res) { app.get("/api/v1/set/timerGoal", function (req, res) {
currentState.countdownGoal = new Date(parseInt(req.query.time)).getTime(); // ToDO error handling currentState.countdownGoal = new Date(parseInt(req.query.time)).getTime(); // ToDO error handling
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/set/addMillisToTimer", function (req, res) { app.get("/api/v1/set/addMillisToTimer", function (req, res) {
currentState.timeAmountInital = req.query.time; currentState.timeAmountInital = req.query.time;
currentState.countdownGoal = new Date().getTime() + parseInt(req.query.time) currentState.countdownGoal = new Date().getTime() + parseInt(req.query.time);
currentState.pauseMoment = new Date().getTime(); currentState.pauseMoment = new Date().getTime();
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/set/relativAddMillisToTimer", function (req, res) { app.get("/api/v1/set/relativAddMillisToTimer", function (req, res) {
currentState.timeAmountInital = req.query.time;
currentState.countdownGoal = currentState.countdownGoal + parseInt(req.query.time) currentState.timeAmountInital = parseInt(req.query.time) + parseInt(currentState.timeAmountInital);
currentState.pauseMoment = new Date().getTime(); currentState.countdownGoal = currentState.countdownGoal + parseInt(req.query.time);
// currentState.pauseMoment = new Date().getTime();
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/ctrl/timer/pause", function (req, res) { app.get("/api/v1/ctrl/timer/pause", function (req, res) {
currentState.timerRunState = false; currentState.timerRunState = false;
currentState.pauseMoment = new Date().getTime(); currentState.pauseMoment = new Date().getTime();
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/ctrl/timer/play", function (req, res) { app.get("/api/v1/ctrl/timer/play", function (req, res) {
if (currentState.timerRunState == false) { if (currentState.timerRunState == false) {
currentState.timerRunState = true currentState.timerRunState = true;
currentState.countdownGoal += new Date().getTime() - currentState.pauseMoment; currentState.countdownGoal +=
new Date().getTime() - currentState.pauseMoment;
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/ctrl/timer/restart", function (req, res) { app.get("/api/v1/ctrl/timer/restart", function (req, res) {
currentState.countdownGoal = new Date().getTime() + parseInt(currentState.timeAmountInital) currentState.countdownGoal =
new Date().getTime() + parseInt(currentState.timeAmountInital);
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/set/layout/showTime", function (req, res) { app.get("/api/v1/set/layout/showTime", function (req, res) {
const resy = helper.wrapBooleanConverter(req.query.show, res) const resy = helper.wrapBooleanConverter(req.query.show, res);
if (resy != undefined) { if (resy != undefined) {
currentState.showTimeOnCountdown = resy; currentState.showTimeOnCountdown = resy;
if (req.query.persist === 'true') { if (req.query.persist === "true") {
dataToBeWritten.showTimeOnCountdown = currentState.showTimeOnCountdown dataToBeWritten.showTimeOnCountdown = currentState.showTimeOnCountdown;
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
} }
updatedData() updatedData();
});
app.get("/api/v1/set/enableOverrun", function (req, res) {
const resy = helper.wrapBooleanConverter(req.query.enable, res);
if (resy != undefined) {
currentState.enableOverrun = resy;
if (req.query.persist === "true") {
dataToBeWritten.enableOverrun = currentState.enableOverrun;
}
res.json({ status: "ok" });
}
updatedData();
}); });
app.get("/api/v1/set/progressbar/show", function (req, res) { app.get("/api/v1/set/progressbar/show", function (req, res) {
currentState.showProgressbar = (req.query.show === 'true'); currentState.showProgressbar = req.query.show === "true";
if (req.query.persist === 'true') { if (req.query.persist === "true") {
dataToBeWritten.showProgressbar = currentState.showProgressbar dataToBeWritten.showProgressbar = currentState.showProgressbar;
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/set/progressbar/colors", function (req, res) { app.get("/api/v1/set/progressbar/colors", function (req, res) {
try { try {
let data = req.query.colors let data = req.query.colors;
if (req.query.isBase64 === "true") { if (req.query.isBase64 === "true") {
data = atob(data) let buff = new Buffer(data, 'base64');
data = buff.toString('ascii');
} }
currentState.colorSegments = JSON.parse(data); currentState.colorSegments = JSON.parse(data);
if (req.query.persist === 'true') { if (req.query.persist === "true") {
dataToBeWritten.colorSegments = currentState.colorSegments dataToBeWritten.colorSegments = currentState.colorSegments;
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
} catch (error) { } catch (error) {
res.json({ status: "error", message: error }); res.json({ status: "error", message: error });
console.error(error) console.error(error);
} }
updatedData() updatedData();
}); });
app.get("/api/v1/set/text/colors", function (req, res) { app.get("/api/v1/set/text/colors", function (req, res) {
try { try {
if (req.query.copy === "true") { if (req.query.copy === "true") {
currentState.textColors = currentState.colorSegments currentState.textColors = currentState.colorSegments;
res.json({ status: "ok" }); res.json({ status: "ok" });
} else { } else {
let data = req.query.colors let data = req.query.colors;
if (req.query.isBase64 === "true") { if (req.query.isBase64 === "true") {
data = atob(data) let buff = new Buffer(data, 'base64');
let data = buff.toString('ascii');
} }
console.debug(data) console.debug(data);
currentState.textColors = JSON.parse(data); currentState.textColors = JSON.parse(data);
if (req.query.persist === 'true') { if (req.query.persist === "true") {
dataToBeWritten.textColors = currentState.textColors dataToBeWritten.textColors = currentState.textColors;
} }
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
} catch (error) { } catch (error) {
res.json({ status: "error", message: error }); res.json({ status: "error", message: error });
console.error(error) console.error(error);
} }
updatedData() updatedData();
}); });
app.get("/api/v1/set/text/enableColoring", function (req, res) { app.get("/api/v1/set/text/enableColoring", function (req, res) {
currentState.enableColoredText = (req.query.enable === 'true'); currentState.enableColoredText = req.query.enable === "true";
if (req.query.persist === 'true') { if (req.query.persist === "true") {
dataToBeWritten.enableColoredText = currentState.enableColoredText dataToBeWritten.enableColoredText = currentState.enableColoredText;
} }
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/ctrl/message/show", function (req, res) { app.get("/api/v1/ctrl/message/show", function (req, res) {
currentState.message = req.query.msg currentState.message = req.query.msg;
currentState.showMessage = true currentState.showMessage = true;
currentState.messageAppearTime = new Date().getTime() currentState.messageAppearTime = new Date().getTime();
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/debug", function (req, res) { app.get("/api/v1/debug", function (req, res) {
currentState.debug = (req.query.enable === 'true'); currentState.debug = req.query.enable === "true";
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/ctrl/message/hide", function (req, res) { app.get("/api/v1/ctrl/message/hide", function (req, res) {
currentState.showMessage = false currentState.showMessage = false;
res.json({ status: "ok" }); res.json({ status: "ok" });
updatedData() updatedData();
}); });
app.get("/api/v1/storage/commit", function (req, res) { app.get("/api/v1/storage/commit", function (req, res) {
@ -357,10 +383,9 @@ app.get("/api/v1/storage/commit", function (req, res) {
} catch (error) { } catch (error) {
res.json({ status: "error", reason: error }); res.json({ status: "error", reason: error });
} }
updatedData() updatedData();
}); });
app.get("/api/v1/storage/delete", function (req, res) { app.get("/api/v1/storage/delete", function (req, res) {
if (req.query.delete === "true") { if (req.query.delete === "true") {
if (fs.existsSync("data-persistence.json")) { if (fs.existsSync("data-persistence.json")) {
@ -369,11 +394,10 @@ app.get("/api/v1/storage/delete", function (req, res) {
} else { } else {
res.json({ status: "error", reason: "No persistence data was found" }); res.json({ status: "error", reason: "No persistence data was found" });
} }
} else { } else {
}
} res.json({ status: "error", reason: "Missing delete argument" }); res.json({ status: "error", reason: "Missing delete argument" });
updatedData() updatedData();
}); });
// UI Routes // UI Routes
@ -381,10 +405,10 @@ app.get("/api/v1/storage/delete", function (req, res) {
app.get("/api/ui/v1/lang/list", function handleLangList(req, res) { app.get("/api/ui/v1/lang/list", function handleLangList(req, res) {
const tempRespObject = { const tempRespObject = {
status: "ok", status: "ok",
languages: languages languages: languages,
} };
res.json(tempRespObject); res.json(tempRespObject);
}) });
app.get("/api/ui/v1/lang/set", function (req, res) { app.get("/api/ui/v1/lang/set", function (req, res) {
if (req.query.lang == undefined || req.query.lang == "") { if (req.query.lang == undefined || req.query.lang == "") {
@ -392,68 +416,91 @@ app.get("/api/ui/v1/lang/set", function (req, res) {
return; return;
} }
const testLang = req.query.lang; const testLang = req.query.lang;
loggy.log("Reloading language file", "info", "Language") loggy.log("Reloading language file", "info", "Language");
if (!fs.existsSync("lang/" + testLang + ".json")) { if (!fs.existsSync("lang/" + testLang + ".json")) {
loggy.log("Language reload failed, file does not exist", "error", "Language") loggy.log(
res.status(500).json({ status: "error", reason: "Language file not found" }); "Language reload failed, file does not exist",
return "error",
"Language"
);
res
.status(500)
.json({ status: "error", reason: "Language file not found" });
return;
} }
const tempLang = fs.readFileSync("lang/" + testLang + ".json", "utf8"); const tempLang = fs.readFileSync("lang/" + testLang + ".json", "utf8");
const tempLangObj = helper.tryToParseJson(tempLang); const tempLangObj = helper.tryToParseJson(tempLang);
if (!tempLangObj) { if (!tempLangObj) {
loggy.log("Language reload failed, file is not valid", "error", "Language") loggy.log("Language reload failed, file is not valid", "error", "Language");
res.status(500).json({ status: "error", reason: "Language file is not valid" }); res
return .status(500)
.json({ status: "error", reason: "Language file is not valid" });
return;
} }
if (tempLangObj._metadata == undefined) { if (tempLangObj._metadata == undefined) {
loggy.log("Language reload failed, file is not valid, metadata missing", "error", "Language") loggy.log(
res.status(500).json({ status: "error", reason: "Language file is not valid" }); "Language reload failed, file is not valid, metadata missing",
return "error",
"Language"
);
res
.status(500)
.json({ status: "error", reason: "Language file is not valid" });
return;
} }
loggy.log("Language reloaded, loaded " + tempLangObj._metadata.lang + "@" + tempLangObj._metadata.version, "info", "Language") loggy.log(
"Language reloaded, loaded " +
tempLangObj._metadata.lang +
"@" +
tempLangObj._metadata.version,
"info",
"Language"
);
configObject.language = req.query.lang; configObject.language = req.query.lang;
languageProfile = tempLangObj; languageProfile = tempLangObj;
res.status(200).json({ status: "ok" }); res.status(200).json({ status: "ok" });
fs.writeFileSync("config.json", JSON.stringify(configObject)); fs.writeFileSync("config.json", JSON.stringify(configObject));
}); });
app.use("/assets/*", function handleModuleFiles(req, res) { app.use("/assets/*", function handleModuleFiles(req, res) {
if (allowsURLs.indexOf(req.params[0]) > -1) { if (allowsURLs.indexOf(req.params[0]) > -1) {
res.sendFile(path.join(__dirname, "node_modules", req.params[0])); res.sendFile(path.join(__dirname, "node_modules", req.params[0]));
} else { } else {
loggy.log("Attempt to access restricted asset file " + req.params[0], "error", "Security") loggy.log(
res.status(403).json({ status: "error", reason: "Access to restricted asset file denied" }); "Attempt to access restricted asset file " + req.params[0],
"error",
"Security"
);
res.status(403).json({
status: "error",
reason: "Access to restricted asset file denied",
});
} }
// console.log(recordedURLs) // console.log(recordedURLs)
}) });
app.use(function (req, res, next) { app.use(function (req, res, next) {
res.status(404); res.status(404);
loggy.log("Server responded with 404 error", "warn", "Server", true); loggy.log("Server responded with 404 error", "warn", "Server", true);
// respond with html page // respond with html page
if (req.accepts('html')) { if (req.accepts("html")) {
const data = fs.readFileSync("templates/errorPages/404.html", "utf8"); const data = fs.readFileSync("templates/errorPages/404.html", "utf8");
res.status(404) res.status(404);
res.send(data); res.send(data);
return; return;
} }
// respond with json // respond with json
if (req.accepts('json')) { if (req.accepts("json")) {
res.json({ error: 'Not found' }); res.json({ error: "Not found" });
return; return;
} }
// default to plain-text. send() // default to plain-text. send()
res.type('txt').send('Not found'); res.type("txt").send("Not found");
}); });
/*app.use(function(err, req, res, next) { /*app.use(function(err, req, res, next) {
console.error(err.stack); console.error(err.stack);
if(String(err.stack).includes("TypeError: Cannot read properties of undefined")) { if(String(err.stack).includes("TypeError: Cannot read properties of undefined")) {
@ -465,30 +512,41 @@ app.use(function (req, res, next) {
});*/ });*/
loggy.log("Starting server", "info", "Server"); loggy.log("Starting server", "info", "Server");
const port = configObject.port; const port = configObject.port;
process.on('SIGINT', function () { process.on("SIGINT", function () {
loggy.log("Caught interrupt signal and shutting down gracefully", "info", "Shutdown"); loggy.log(
"Caught interrupt signal and shutting down gracefully",
"info",
"Shutdown"
);
server.close(); // Make the express server stop server.close(); // Make the express server stop
loggy.log("Goodbye! 👋", "magic", "Shutdown", true) loggy.log("Goodbye! 👋", "magic", "Shutdown", true);
loggy.close(); // Close and write log loggy.close(); // Close and write log
process.exit(); // Quit the application process.exit(); // Quit the application
}); });
const server = app.listen(port); const server = app.listen(port);
server.on('upgrade', (request, socket, head) => { server.on("upgrade", (request, socket, head) => {
wsServer.handleUpgrade(request, socket, head, socket => { wsServer.handleUpgrade(request, socket, head, (socket) => {
wsServer.emit('connection', socket, request); wsServer.emit("connection", socket, request);
}); });
}); });
loggy.log("=======================", "info", "", true); loggy.log("=======================", "info", "", true);
loggy.log("Server running on port " + port, "magic", "", true); loggy.log("Server running on port " + port, "magic", "", true);
loggy.log("Visit http://localhost:" + port + "/timer for the timer view", "magic", "", true); loggy.log(
loggy.log("Visit http://localhost:" + port + " for the admin view", "magic", "", true); "Visit http://localhost:" + port + "/timer for the timer view",
"magic",
"",
true
);
loggy.log(
"Visit http://localhost:" + port + " for the admin view",
"magic",
"",
true
);
loggy.log("=======================", "info", "", true); loggy.log("=======================", "info", "", true);

View File

@ -46,7 +46,8 @@
"enableTextClrs": "Text Farben aktivieren:", "enableTextClrs": "Text Farben aktivieren:",
"textClrs": "Text Farben", "textClrs": "Text Farben",
"addRow": "Neue Zeile", "addRow": "Neue Zeile",
"timeVar": "Aktiviere zeitabweichungs display:" "timeVar": "Aktiviere zeitabweichungs display:",
"allowOverrun": "Überlauf erlauben: "
}, },
"untis": "untis":
{ {

View File

@ -49,7 +49,8 @@
"addRow": "Add Row", "addRow": "Add Row",
"timeVar": "Enable time variance display:", "timeVar": "Enable time variance display:",
"language": "Select a language", "language": "Select a language",
"apply": "Apply" "apply": "Apply",
"allowOverrun": "Allow overrun:"
}, },
"untis": "untis":
{ {

View File

@ -46,7 +46,8 @@
"enableTextClrs": "██████ ████ ███████:", "enableTextClrs": "██████ ████ ███████:",
"textClrs": "████ ██████", "textClrs": "████ ██████",
"addRow": "███ ███", "addRow": "███ ███",
"timeVar": "██████ ████ ███████ ███████:" "timeVar": "██████ ████ ███████ ███████:",
"allowOverrun": "██████ ████████:"
}, },
"untis": "untis":
{ {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "opencountdown", "name": "opencountdown",
"version": "1.0.4", "version": "1.0.7",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "opencountdown", "name": "opencountdown",
"version": "1.0.4", "version": "1.0.7",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"dependencies": { "dependencies": {
"body-parser": "^1.20.1", "body-parser": "^1.20.1",

View File

@ -10,26 +10,26 @@
"author": "TheGreydiamond", "author": "TheGreydiamond",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"dependencies": { "dependencies": {
"body-parser": "^1.20.1", "body-parser": "^1.20.2",
"bootstrap": "^5.2.2", "bootstrap": "^5.3.1",
"bootstrap-duration-picker": "^2.1.3", "bootstrap-duration-picker": "^2.1.3",
"bootstrap-icons": "^1.10.1", "bootstrap-icons": "^1.10.5",
"colors": "^1.4.0", "colors": "^1.4.0",
"darkreader": "^4.9.58", "darkreader": "^4.9.58",
"eta": "^1.12.3", "eta": "^1.14.2",
"express": "^4.18.2", "express": "^4.19.2",
"flatpickr": "^4.6.13", "flatpickr": "^4.6.13",
"jquery": "^3.6.1", "jquery": "^3.7.0",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"less": "^4.1.3", "less": "^4.1.3",
"mdbootstrap": "^4.20.0", "mdbootstrap": "^4.20.0",
"open": "^8.4.0", "open": "^8.4.0",
"underscore": "^1.13.6", "underscore": "^1.13.6",
"ws": "^8.11.0" "ws": "^8.18.0"
}, },
"devDependencies": { "devDependencies": {
"electron": "^21.2.3", "electron": "^25.9.8",
"electron-builder": "^23.6.0" "electron-builder": "^24.6.3"
}, },
"build": { "build": {
"extraMetadata": { "extraMetadata": {

View File

@ -131,6 +131,7 @@ $(function () {
$("#showMillis")[0].checked = jsonResult.showMilliSeconds; $("#showMillis")[0].checked = jsonResult.showMilliSeconds;
$("#progBarShow")[0].checked = jsonResult.showProgressbar; $("#progBarShow")[0].checked = jsonResult.showProgressbar;
$("#textColors")[0].checked = jsonResult.enableColoredText; $("#textColors")[0].checked = jsonResult.enableColoredText;
$("#allowOverrun")[0].checked = jsonResult.enableOverrun;
console.log(document.getElementById("tableCopySource")) console.log(document.getElementById("tableCopySource"))
let tableEntryDom = document.getElementById("tableCopySource").cloneNode(true) let tableEntryDom = document.getElementById("tableCopySource").cloneNode(true)
@ -266,6 +267,7 @@ $(function () {
const showMillisB = $("#showMillis")[0].checked const showMillisB = $("#showMillis")[0].checked
const progBarShowB = $("#progBarShow")[0].checked const progBarShowB = $("#progBarShow")[0].checked
const textColorsB = $("#textColors")[0].checked const textColorsB = $("#textColors")[0].checked
const allowOverrun = $("#allowOverrun")[0].checked
const colors = convertColorSegments("colors1") const colors = convertColorSegments("colors1")
const colors2 = convertColorSegments("colors2") const colors2 = convertColorSegments("colors2")
@ -276,6 +278,8 @@ $(function () {
allPathes.push("/api/v1/set/text/enableColoring?enable=" + textColorsB) allPathes.push("/api/v1/set/text/enableColoring?enable=" + textColorsB)
allPathes.push("/api/v1/set/progressbar/colors?isBase64=true&colors=" + btoa(JSON.stringify(colors))) allPathes.push("/api/v1/set/progressbar/colors?isBase64=true&colors=" + btoa(JSON.stringify(colors)))
allPathes.push("/api/v1/set/text/colors?isBase64=true&colors=" + btoa(JSON.stringify(colors2))) allPathes.push("/api/v1/set/text/colors?isBase64=true&colors=" + btoa(JSON.stringify(colors2)))
allPathes.push("/api/v1/set/enableOverrun?enable=" + allowOverrun)
for (pI in allPathes) { for (pI in allPathes) {
@ -301,11 +305,13 @@ $(function () {
const showMillisB = $("#showMillis")[0].checked const showMillisB = $("#showMillis")[0].checked
const progBarShowB = $("#progBarShow")[0].checked const progBarShowB = $("#progBarShow")[0].checked
const textColorsB = $("#textColors")[0].checked const textColorsB = $("#textColors")[0].checked
const allowOverrun = $("#allowOverrun")[0].checked
allPathes.push("/api/v1/set/layout/showTime?persist=true&show=" + showTimeB) allPathes.push("/api/v1/set/layout/showTime?persist=true&show=" + showTimeB)
allPathes.push("/api/v1/set/layout/showMillis?persist=true&show=" + showMillisB) allPathes.push("/api/v1/set/layout/showMillis?persist=true&show=" + showMillisB)
allPathes.push("/api/v1/set/progressbar/show?persist=true&show=" + progBarShowB) allPathes.push("/api/v1/set/progressbar/show?persist=true&show=" + progBarShowB)
allPathes.push("/api/v1/set/text/enableColoring?persist=true&enable=" + textColorsB) allPathes.push("/api/v1/set/text/enableColoring?persist=true&enable=" + textColorsB)
allPathes.push("/api/v1/set/enableOverrun?persist=true&enable=" + allowOverrun)
for (pI in allPathes) { for (pI in allPathes) {
const path = allPathes[pI]; const path = allPathes[pI];

View File

@ -186,6 +186,9 @@ function handleUpdate() {
progressBar.style.width = percentage(diff, dataFrame.timeAmountInital) + "%"; progressBar.style.width = percentage(diff, dataFrame.timeAmountInital) + "%";
} else { } else {
progressBar.style.width = "0%"; progressBar.style.width = "0%";
if(!dataFrame.enableOverrun) {
timer.innerHTML = "00:00:00";
}
} }
progressBar.style.backgroundColor = findProgessColor(dataFrame.colorSegments, diff) progressBar.style.backgroundColor = findProgessColor(dataFrame.colorSegments, diff)

View File

@ -262,6 +262,9 @@
<label for="progBarShow"><%= it.lang.labels.showProgress %></label> <label for="progBarShow"><%= it.lang.labels.showProgress %></label>
<input type="checkbox" name="progBarShow" id="progBarShow"><br> <input type="checkbox" name="progBarShow" id="progBarShow"><br>
<label for="allowOverrun"><%= it.lang.labels.allowOverrun %></label>
<input type="checkbox" name="allowOverrun" id="allowOverrun"><br>
<details> <details>
<summary><%= it.lang.labels.progbarColors %></summary> <summary><%= it.lang.labels.progbarColors %></summary>
<p> <p>