mirror of
https://github.com/TheGreyDiamond/Enlight.git
synced 2025-07-17 20:33:48 +02:00
faster then before
This commit is contained in:
36
index.js
36
index.js
@ -7,6 +7,8 @@ var aWin2 = undefined;
|
||||
|
||||
var preLoadedAmount = 0;
|
||||
|
||||
var networkInterfaces = [];
|
||||
|
||||
/// !!!-----------!!!
|
||||
/// PAGE LOOKUP TABLE
|
||||
var preloadedPageLookup = {};
|
||||
@ -61,6 +63,8 @@ function createWindow() {
|
||||
win.setFullScreen(true);
|
||||
win.setMenuBarVisibility(false);
|
||||
win.setAutoHideMenuBar(true);
|
||||
|
||||
|
||||
main = loadPage("index")
|
||||
header = loadPage("header")
|
||||
|
||||
@ -121,16 +125,14 @@ function doneLoading() {
|
||||
function init() {
|
||||
win = createWindow();
|
||||
aWin2 = createStartupInfo();
|
||||
//const view = new BrowserView({
|
||||
// webPreferences: {
|
||||
// nodeIntegration: true,
|
||||
// },
|
||||
//})
|
||||
|
||||
//win.setBrowserView(view)
|
||||
//view.setBounds({ x: 0, y: 0, width: screen.getPrimaryDisplay().size.width, height: 100 })
|
||||
//view.webContents.loadFile('ui_templates/header.html')
|
||||
|
||||
sysInf.networkInterfaces(function (data) {
|
||||
networkInterfaces = data;
|
||||
});
|
||||
setInterval(function(){
|
||||
sysInf.networkInterfaces(function (data) {
|
||||
networkInterfaces = data;
|
||||
});
|
||||
}, 2 * 60 * 1000) // Update network interface every 2 mins
|
||||
|
||||
setTimeout(doneLoading, 2000);
|
||||
ipcMain.on("asynchronous-message", (event, arg) => {
|
||||
@ -155,9 +157,12 @@ function init() {
|
||||
}else if (String(arg).includes("loadOverride")) {
|
||||
event.returnValue = false;
|
||||
}else if (String(arg).includes("getNetworks")) {
|
||||
sysInf.networkInterfaces(function (data) {
|
||||
|
||||
/*sysInf.networkInterfaces(function (data) {
|
||||
event.returnValue = data;
|
||||
});
|
||||
});*/
|
||||
event.returnValue = networkInterfaces;
|
||||
|
||||
}else if (String(arg).includes("set:newNetwork")) {
|
||||
fs.writeFile('usrStore/lastNetwork.data', String(arg).split("|")[1], function (err) {
|
||||
if (err) return console.log(err);
|
||||
@ -183,8 +188,15 @@ function init() {
|
||||
|
||||
header = loadPage("header")
|
||||
toLoad = header + main;
|
||||
console.log(toLoad)
|
||||
const timestamp = Date.now();
|
||||
fs.writeFileSync("ui_templates/temp.html", toLoad)
|
||||
const timestamp2 = Date.now();
|
||||
win.loadFile("ui_templates/temp.html")
|
||||
const timestamp3 = Date.now();
|
||||
//win.loadFile("ui_templates/header.html")
|
||||
console.log("LOADTIMES: ", (timestamp2 - timestamp), (timestamp3 - timestamp2), (timestamp3 - timestamp))
|
||||
|
||||
|
||||
event.returnValue = "";
|
||||
}else{
|
||||
|
195
test.html
Normal file
195
test.html
Normal file
@ -0,0 +1,195 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Enlight - Screen 1</title>
|
||||
<!--<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="script-src 'self' 'unsafe-inline';"
|
||||
/>-->
|
||||
<script src="static/jquery-1.7.1.min.js" type="text/javascript"></script>
|
||||
<script src="static/js/helper.js" type="text/javascript"></script>
|
||||
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>*-->
|
||||
<link href="static/default.css" rel="stylesheet" />
|
||||
<link
|
||||
href="static/fontawesome-free-5.15.1-web/css/all.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="header-bar" class="header-bar">
|
||||
<div class="areaRight">
|
||||
<network>
|
||||
<i
|
||||
class="fas fa-network-wired"
|
||||
id="networkBtn"
|
||||
onclick='document.getElementById("networkDropdown").classList.toggle("show");'
|
||||
></i>
|
||||
<div id="networkDropdown" class="dropdown-content"></div>
|
||||
</network>
|
||||
<battery id="battery" class="fa"></battery>
|
||||
<clock id="clock" class="header-clock"></clock>
|
||||
<i
|
||||
class="fa-spin loader1 fa"
|
||||
style="font-size: 18px; padding-right: 4px"
|
||||
id="loader"
|
||||
></i
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var loaderInUse = true;
|
||||
const { ipcRenderer } = require("electron");
|
||||
setInterval(function () {
|
||||
// Pulling general info from main thread
|
||||
loadOverride = ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"loadOverride"
|
||||
);
|
||||
if (!loaderInUse) {
|
||||
if (loadOverride) {
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
} else {
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
|
||||
// Network info
|
||||
var allNetworkNames = [];
|
||||
function buildNetworkDropDown() {
|
||||
loaderInUse = true;
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
allNetworks = ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"getNetworks"
|
||||
);
|
||||
lastNetwork = ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"getMainNetwork"
|
||||
);
|
||||
allNetworkNames = [];
|
||||
console.log(lastNetwork);
|
||||
i = 0;
|
||||
var dropDown = document.getElementById("networkDropdown");
|
||||
dropDown.innerHTML = "";
|
||||
while (i < allNetworks.length) {
|
||||
temp =
|
||||
"<a id='networkEntry" +
|
||||
String(i) +
|
||||
"' onclick='selectNewNetwork(" +
|
||||
String(i) +
|
||||
")'> " +
|
||||
encode_html(allNetworks[i].ifaceName) +
|
||||
"</a>";
|
||||
dropDown.innerHTML += temp;
|
||||
allNetworkNames.push(allNetworks[i].ifaceName);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (does_list_contain(allNetworkNames, lastNetwork)) {
|
||||
nameOfElm =
|
||||
"networkEntry" + String(allNetworkNames.indexOf(lastNetwork));
|
||||
networkEntryElm = document.getElementById(nameOfElm);
|
||||
networkEntryElm.innerHTML = networkEntryElm.innerHTML.replace(
|
||||
" ",
|
||||
"✔"
|
||||
);
|
||||
} else {
|
||||
console.warn("Network is no longer valid");
|
||||
ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"state:networkNoLongerValid"
|
||||
);
|
||||
}
|
||||
loaderInUse = false;
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
}
|
||||
|
||||
function selectNewNetwork(id) {
|
||||
idAsNumber = parseInt(id);
|
||||
newNetwork = allNetworkNames[id];
|
||||
ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"set:newNetwork|" + newNetwork
|
||||
);
|
||||
buildNetworkDropDown();
|
||||
|
||||
nameOfElm = "networkEntry" + String(idAsNumber);
|
||||
networkEntryElm = document.getElementById(nameOfElm);
|
||||
networkEntryElm.innerHTML = networkEntryElm.innerHTML.replace(
|
||||
" ",
|
||||
"✔"
|
||||
);
|
||||
}
|
||||
buildNetworkDropDown();
|
||||
</script>
|
||||
<script>
|
||||
// Battery info screen
|
||||
batteryExists = ipcRenderer.sendSync("synchronous-message", "hasBattery"); // prints "pong"
|
||||
var batteryShowdStart = false;
|
||||
if (batteryExists) {
|
||||
batteryLevel = ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"getBatteryLevel"
|
||||
);
|
||||
|
||||
//Setup regular updates
|
||||
setInterval(function () {
|
||||
batteryLevel = parseInt(
|
||||
ipcRenderer.sendSync("synchronous-message", "getBatteryLevel")
|
||||
);
|
||||
|
||||
batteryShowdStart = true;
|
||||
if (batteryLevel > 75) {
|
||||
document.getElementById("battery").innerHTML = "";
|
||||
} else if (batteryLevel <= 75 && batteryLevel > 50) {
|
||||
document.getElementById("battery").innerHTML = "";
|
||||
} else if (batteryLevel <= 50 && batteryLevel > 25) {
|
||||
document.getElementById("battery").innerHTML = "";
|
||||
} else if (batteryLevel <= 25 && batteryLevel > 5) {
|
||||
document.getElementById("battery").innerHTML = "";
|
||||
} else {
|
||||
document.getElementById("battery").innerHTML = "";
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
batteryShowdStart = true;
|
||||
}
|
||||
if (batteryShowdStart) {
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
loaderInUse = false;
|
||||
}
|
||||
|
||||
setInterval(function () {
|
||||
var date = new Date();
|
||||
hour = updateTime(date.getHours());
|
||||
min = updateTime(date.getMinutes());
|
||||
sec = updateTime(date.getSeconds());
|
||||
document.getElementById("clock").innerHTML =
|
||||
hour + ":" + min + ":" + sec;
|
||||
}, 500);
|
||||
</script>
|
||||
<script>
|
||||
window.onclick = function (event) {
|
||||
if (!event.target.matches("#networkBtn")) {
|
||||
var dropdowns = document.getElementsByClassName("dropdown-content");
|
||||
var i;
|
||||
for (i = 0; i < dropdowns.length; i++) {
|
||||
var openDropdown = dropdowns[i];
|
||||
if (openDropdown.classList.contains("show")) {
|
||||
openDropdown.classList.remove("show");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<!--</body>
|
||||
</html>-->
|
||||
|
||||
<h1>Sessions</h1>
|
||||
yes.
|
||||
<button onclick='ipcRenderer.sendSync("synchronous-message", "PAGE:change.index");'>Go back</button>
|
||||
</body>
|
||||
</html>
|
@ -24,7 +24,7 @@
|
||||
<i
|
||||
class="fas fa-network-wired"
|
||||
id="networkBtn"
|
||||
onclick='document.getElementById("networkDropdown").classList.toggle("show");'
|
||||
onclick='document.getElementById("networkDropdown").classList.toggle("show");buildNetworkDropDown();'
|
||||
></i>
|
||||
<div id="networkDropdown" class="dropdown-content"></div>
|
||||
</network>
|
||||
@ -61,6 +61,8 @@
|
||||
function buildNetworkDropDown() {
|
||||
loaderInUse = true;
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
console.log("show loader")
|
||||
const timestamp = Date.now();
|
||||
allNetworks = ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"getNetworks"
|
||||
@ -69,6 +71,9 @@
|
||||
"synchronous-message",
|
||||
"getMainNetwork"
|
||||
);
|
||||
const timestamp2 = Date.now();
|
||||
console.log("Requests took" , (timestamp2 - timestamp))
|
||||
|
||||
allNetworkNames = [];
|
||||
console.log(lastNetwork);
|
||||
i = 0;
|
||||
@ -103,6 +108,7 @@
|
||||
"state:networkNoLongerValid"
|
||||
);
|
||||
}
|
||||
console.log("hide loader")
|
||||
loaderInUse = false;
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
}
|
||||
@ -123,7 +129,10 @@
|
||||
"✔"
|
||||
);
|
||||
}
|
||||
buildNetworkDropDown();
|
||||
//setTimeout(function(){
|
||||
// buildNetworkDropDown();
|
||||
//}, 1000)
|
||||
//
|
||||
</script>
|
||||
<script>
|
||||
// Battery info screen
|
||||
@ -161,14 +170,18 @@
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
loaderInUse = false;
|
||||
}
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
function updateClock(){
|
||||
var date = new Date();
|
||||
hour = updateTime(date.getHours());
|
||||
min = updateTime(date.getMinutes());
|
||||
sec = updateTime(date.getSeconds());
|
||||
document.getElementById("clock").innerHTML =
|
||||
hour + ":" + min + ":" + sec;
|
||||
}
|
||||
updateClock();
|
||||
setInterval(function () {
|
||||
updateClock()
|
||||
}, 500);
|
||||
</script>
|
||||
<script>
|
||||
@ -185,5 +198,6 @@
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!--</body>
|
||||
</html>-->
|
||||
|
@ -24,7 +24,7 @@
|
||||
<i
|
||||
class="fas fa-network-wired"
|
||||
id="networkBtn"
|
||||
onclick='document.getElementById("networkDropdown").classList.toggle("show");'
|
||||
onclick='document.getElementById("networkDropdown").classList.toggle("show");buildNetworkDropDown();'
|
||||
></i>
|
||||
<div id="networkDropdown" class="dropdown-content"></div>
|
||||
</network>
|
||||
@ -61,6 +61,8 @@
|
||||
function buildNetworkDropDown() {
|
||||
loaderInUse = true;
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
console.log("show loader")
|
||||
const timestamp = Date.now();
|
||||
allNetworks = ipcRenderer.sendSync(
|
||||
"synchronous-message",
|
||||
"getNetworks"
|
||||
@ -69,6 +71,9 @@
|
||||
"synchronous-message",
|
||||
"getMainNetwork"
|
||||
);
|
||||
const timestamp2 = Date.now();
|
||||
console.log("Requests took" , (timestamp2 - timestamp))
|
||||
|
||||
allNetworkNames = [];
|
||||
console.log(lastNetwork);
|
||||
i = 0;
|
||||
@ -103,6 +108,7 @@
|
||||
"state:networkNoLongerValid"
|
||||
);
|
||||
}
|
||||
console.log("hide loader")
|
||||
loaderInUse = false;
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
}
|
||||
@ -123,7 +129,10 @@
|
||||
"✔"
|
||||
);
|
||||
}
|
||||
buildNetworkDropDown();
|
||||
//setTimeout(function(){
|
||||
// buildNetworkDropDown();
|
||||
//}, 1000)
|
||||
//
|
||||
</script>
|
||||
<script>
|
||||
// Battery info screen
|
||||
@ -161,14 +170,18 @@
|
||||
document.getElementById("loader").innerHTML = "";
|
||||
loaderInUse = false;
|
||||
}
|
||||
|
||||
setInterval(function () {
|
||||
|
||||
function updateClock(){
|
||||
var date = new Date();
|
||||
hour = updateTime(date.getHours());
|
||||
min = updateTime(date.getMinutes());
|
||||
sec = updateTime(date.getSeconds());
|
||||
document.getElementById("clock").innerHTML =
|
||||
hour + ":" + min + ":" + sec;
|
||||
}
|
||||
updateClock();
|
||||
setInterval(function () {
|
||||
updateClock()
|
||||
}, 500);
|
||||
</script>
|
||||
<script>
|
||||
@ -185,6 +198,7 @@
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!--</body>
|
||||
</html>-->
|
||||
<!DOCTYPE html>
|
||||
|
Reference in New Issue
Block a user