aboutsummaryrefslogtreecommitdiff
path: root/src/public/js/index.js
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2021-10-11 20:02:04 +0200
committerGitHub <noreply@github.com>2021-10-11 20:02:04 +0200
commitc67531161e56488166a33232f87566309ba8676e (patch)
tree846e59a020e80bea48557d5a06af5728e44961ff /src/public/js/index.js
parente6880cd8ccf82d993f222cb14b4860581654acb8 (diff)
parentc1b6eec770b885a9829e1f62bad5cc99389ca429 (diff)
downloadLuxcena-Neo-c67531161e56488166a33232f87566309ba8676e.tar.gz
Luxcena-Neo-c67531161e56488166a33232f87566309ba8676e.zip
Merge pull request #24 from JakobST1n/rebuild
v1.0.0
Diffstat (limited to 'src/public/js/index.js')
-rw-r--r--src/public/js/index.js68
1 files changed, 0 insertions, 68 deletions
diff --git a/src/public/js/index.js b/src/public/js/index.js
deleted file mode 100644
index 5b67de2..0000000
--- a/src/public/js/index.js
+++ /dev/null
@@ -1,68 +0,0 @@
-let socket = io();
-
-module.exports = () => {
- M.AutoInit();
- setupSocket();
-
- setInterval(() => {
- socket.emit("GetGeneralInfo");
- }, 500);
-
- socket.emit("GetLog", {filter: "success error event", entryN: 10});
-};
-
-function setupSocket() {
-
- socket.on("lastLogEntries", (entries) => {
- let list = "";
- entries.forEach((entry) => {
- list += "<tr><td>" + prettifyType(entry.type) + "</td><td>" + entry.time + "</td><td>" + entry.details + "</td></tr>";
- });
-
- document.getElementById("log-table-body").innerHTML = list;
- M.AutoInit();
- });
-
- socket.on("newLogEntry", (entry) => {
- // Start with parsing the new entry, no reason to select the DOM-element and stuff, if we are filtering out the entry anyway.
- let type = entry.type;
- if ( (type.toUpperCase() !== "SUCCESS") && (type.toUpperCase() !== "ERROR") && (type.toUpperCase() !== "EVENT") && (type.toUpperCase() !== "INFO")) {
- return;
- }
-
- let logTable = document.getElementById("log-table-body");
-
- let LTable = logTable.rows.length;
- logTable.deleteRow(LTable - 1); // Since length outputs a 1-based number
-
- let newEntry = logTable.insertRow(0);
- newEntry.insertCell(0).innerHTML = prettifyType(entry.type);
- newEntry.insertCell(1).innerHTML = entry.time;
- newEntry.insertCell(2).innerHTML = entry.details;
- M.AutoInit();
- newEntry.className = "newLogEntry";
- });
-
- socket.on("generalInfo", (info) => {
- if (info["scriptIsExited"]) {
- document.getElementById("currentScript").innerHTML = info["currentScript"] + " (exited)";
- } else {
- document.getElementById("currentScript").innerHTML = info["currentScript"];
- }
- document.getElementById("uptime").innerHTML = info["uptime"] + " seconds";
- });
-
-}
-
-function prettifyType(type) {
- let prettyTable = {
- "DEBUG": `<span class="tooltipped" data-position="top" data-tooltip="Debug-log">😸</span>`,
- "INFO": `<span class="tooltipped" data-position="top" data-tooltip="Just some information">â„šī¸</span>`,
- "WARNING": `<span class="tooltipped" data-position="top" data-tooltip="A warning">âš ī¸</span>`,
- "EVENT": `<span class="tooltipped" data-position="top" data-tooltip="Event">âšĄī¸</span>`,
- "SUCCESS": `<span class="tooltipped" data-position="top" data-tooltip="Something exited successfully">✅</span>`,
- "ERROR": `<span class="tooltipped" data-position="top" data-tooltip="Error">🔴</span>`,
- "PYTHON": `<span class="tooltipped" data-position="top" data-tooltip="Output from user-script">🐍</span>`
- };
- return prettyTable[type];
-}