From 9dc4e61d7fcbccf8da82774b6bd246a6707292cc Mon Sep 17 00:00:00 2001 From: TheGreyDiamond Date: Mon, 23 Nov 2020 22:09:25 +0100 Subject: [PATCH] A bit faster --- index.js | 29 ++++++++++++++++++++++++++++- ui_templates/index.html | 2 +- ui_templates/sessions.html | 6 ++++++ ui_templates/temp.html | 2 +- usrStore/lastNetwork.data | 2 +- 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 ui_templates/sessions.html diff --git a/index.js b/index.js index 60df2a2..831fa5c 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,22 @@ const { win32 } = require("path"); const sysInf = require("systeminformation"); var aWin2 = undefined; +var header = undefined; + +header = fs.readFileSync("ui_templates/header.html").toString(); + +/// !!!-----------!!! +/// PAGE LOOKUP TABLE +var pageLookup = {}; +pageLookup["index"] = "index.html"; +pageLookup["session"] = "sessions.html"; + +fs.readFile('ui_templates/sessions.html', 'utf8', function (err,data) { + if (err) { + return console.log(err); + } + pageLookup["sessionPRELOAD"] = data; +}); function createWindow() { const win = new BrowserWindow({ @@ -17,7 +33,7 @@ function createWindow() { win.setMenuBarVisibility(false); win.setAutoHideMenuBar(true); main = fs.readFileSync("ui_templates/index.html").toString(); - header = fs.readFileSync("ui_templates/header.html").toString(); + //header = fs.readFileSync("ui_templates/header.html").toString(); toLoad = header + main; fs.writeFileSync("ui_templates/temp.html", toLoad) //win.loadURL("data:text/html;charset=utf-8," + encodeURI(toLoad)); @@ -123,6 +139,17 @@ function init() { } + }else if (String(arg).includes("PAGE:change")) { + newPage = String(arg).split(".")[1] + main = pageLookup[newPage + "PRELOAD"] + if(main == undefined){ + main = fs.readFileSync("ui_templates/" + pageLookup[newPage]).toString(); + } + toLoad = header + main; + fs.writeFileSync("ui_templates/temp.html", toLoad) + win.loadFile("ui_templates/temp.html") + + event.returnValue = ""; }else{ event.returnValue = "ERR:UNKNOW_CMD" } diff --git a/ui_templates/index.html b/ui_templates/index.html index cd996e5..5513380 100644 --- a/ui_templates/index.html +++ b/ui_templates/index.html @@ -187,7 +187,7 @@ -->

Hello World!

- Session screen + We are using node -->

Hello World!

- Session screen + We are using node