From 6c9685e695a9864513405c2d38d1ae5f95a92c8b Mon Sep 17 00:00:00 2001
From: Mars <72959419+Mars7383@users.noreply.github.com>
Date: Mon, 27 Dec 2021 00:18:38 -0500
Subject: [PATCH] Optimization
No longer scans for PIDs every 2.5 seconds
---
CREDITS.md | 7 +--
build/asset-manifest.json | 20 ++++----
build/index.html | 2 +-
build/utils.js | 100 ++++++++++++++++++++++++--------------
electron/main.js | 2 +-
package.json | 4 +-
public/utils.js | 100 ++++++++++++++++++++++++--------------
src/App.css | 9 ++++
src/App.js | 5 +-
9 files changed, 157 insertions(+), 92 deletions(-)
diff --git a/CREDITS.md b/CREDITS.md
index e4a7d51..8726fe7 100644
--- a/CREDITS.md
+++ b/CREDITS.md
@@ -42,10 +42,11 @@
QA Testing
diff --git a/build/asset-manifest.json b/build/asset-manifest.json
index 7435575..443228a 100644
--- a/build/asset-manifest.json
+++ b/build/asset-manifest.json
@@ -1,22 +1,22 @@
{
"files": {
- "main.css": "./static/css/main.3817b7f4.chunk.css",
- "main.js": "./static/js/main.4dddd5b1.chunk.js",
- "main.js.map": "./static/js/main.4dddd5b1.chunk.js.map",
+ "main.css": "./static/css/main.ef7df470.chunk.css",
+ "main.js": "./static/js/main.288579d3.chunk.js",
+ "main.js.map": "./static/js/main.288579d3.chunk.js.map",
"runtime-main.js": "./static/js/runtime-main.3d67b72f.js",
"runtime-main.js.map": "./static/js/runtime-main.3d67b72f.js.map",
- "static/js/2.115e10fd.chunk.js": "./static/js/2.115e10fd.chunk.js",
- "static/js/2.115e10fd.chunk.js.map": "./static/js/2.115e10fd.chunk.js.map",
+ "static/js/2.56c5226b.chunk.js": "./static/js/2.56c5226b.chunk.js",
+ "static/js/2.56c5226b.chunk.js.map": "./static/js/2.56c5226b.chunk.js.map",
"static/js/3.41faa0d5.chunk.js": "./static/js/3.41faa0d5.chunk.js",
"static/js/3.41faa0d5.chunk.js.map": "./static/js/3.41faa0d5.chunk.js.map",
"index.html": "./index.html",
- "static/css/main.3817b7f4.chunk.css.map": "./static/css/main.3817b7f4.chunk.css.map",
- "static/js/2.115e10fd.chunk.js.LICENSE.txt": "./static/js/2.115e10fd.chunk.js.LICENSE.txt"
+ "static/css/main.ef7df470.chunk.css.map": "./static/css/main.ef7df470.chunk.css.map",
+ "static/js/2.56c5226b.chunk.js.LICENSE.txt": "./static/js/2.56c5226b.chunk.js.LICENSE.txt"
},
"entrypoints": [
"static/js/runtime-main.3d67b72f.js",
- "static/js/2.115e10fd.chunk.js",
- "static/css/main.3817b7f4.chunk.css",
- "static/js/main.4dddd5b1.chunk.js"
+ "static/js/2.56c5226b.chunk.js",
+ "static/css/main.ef7df470.chunk.css",
+ "static/js/main.288579d3.chunk.js"
]
}
\ No newline at end of file
diff --git a/build/index.html b/build/index.html
index ef4c5ea..acb254c 100644
--- a/build/index.html
+++ b/build/index.html
@@ -1 +1 @@
-Calamari
\ No newline at end of file
+Calamari
\ No newline at end of file
diff --git a/build/utils.js b/build/utils.js
index 91ecd77..01b4d34 100644
--- a/build/utils.js
+++ b/build/utils.js
@@ -1,5 +1,5 @@
const fs2 = require("fs"); // these have a 2 in their name because they are redeclared in the other js file and that makes the interpreter sad :(
-const path2 = require("path")
+const path2 = require("path");
// Load prefs
let prefsFileLocation2 = path2.join(__dirname, "../../config.json");
var prefsObj2;
@@ -57,14 +57,21 @@ window.setPreference = async function(preference, value) { // string preference,
window.minimizeWindow = function() {
require("electron").remote.BrowserWindow.getFocusedWindow().minimize();
}
-
+let updateAvailable = "unloaded";
window.togglePreferencePane = function(bool) {
if (bool) {
+ // we dont wanna keep checking the filesystem for update file, so we'll only do it once
+ if (updateAvailable == "unloaded") updateAvailable = fs.existsSync(path.join(__dirname, "../../newapp.asar"))
document.getElementById("configPage").style.position = "static"
document.getElementById("configPage").style.visibility = "visible"
+ try {if (updateAvailable) {
+ document.getElementById("pending").style.visibility = "visible"
+ firstUpdateCheck = false;
+ }} catch(err) {console.error(err)}
} else {
document.getElementById("configPage").style.position = "absolute"
document.getElementById("configPage").style.visibility = "hidden"
+ document.getElementById("pending").style.visibility = "hidden"
}
}
@@ -84,47 +91,65 @@ sessionStorage.outputScrollPos = 0;
let robloxExistedAtTheTimeThisVariableWasDefinedNoCap = false;
-setInterval(() => {
- if (document.getElementsByClassName("editorBox").length == 0) {
- if (editorVisible) {
- //console.log("Editor left the screen")
- editorVisible = false;
- }
- }
- if (document.getElementsByClassName("editorBox").length == 1) {
- if (!editorVisible) {
+// migrating code from setInterval to onclick events
+
+var editorExists = true; //document.body.contains(document.getElementsByClassName("editorBox")[0]);
+var observer = new MutationObserver(function(mutations) {
+ if (document.body.contains(document.getElementsByClassName("editorBox")[0])) {
+ if (!editorExists) {
+ console.log("editor inserted (and output)");
//console.log("Editor visible again")
- document.getElementsByClassName("editorBox")[0].value = sessionStorage.editorText
- document.getElementsByClassName("editorBox")[0].scrollTop = sessionStorage.editorScrollPos
+ let editorBox = document.getElementsByClassName("editorBox")[0];
+ let outputBox = document.getElementsByClassName("outputBox")[0];
+ editorBox.value = sessionStorage.editorText
+ editorBox.scrollTop = sessionStorage.editorScrollPos
editorVisible = true;
- } else {
- //console.log("Storing editor values")
- sessionStorage.editorText = document.getElementsByClassName("editorBox")[0].value
- sessionStorage.editorScrollPos = document.getElementsByClassName("editorBox")[0].scrollTop
- }
- }
-
- if (document.getElementsByClassName("outputBox").length == 0) {
- if (outputVisible) {
- //console.log("Output left the screen")
- outputVisible = false;
- }
- }
- if (document.getElementsByClassName("outputBox").length == 1) {
- if (!outputVisible) {
//console.log("Output visible again")
- document.getElementsByClassName("outputBox")[0].value = sessionStorage.outputText;
- document.getElementsByClassName("outputBox")[0].style.color = sessionStorage.outputColor;
- document.getElementsByClassName("outputBox")[0].scrollTop = sessionStorage.outputScrollPos
+ outputBox.value = sessionStorage.outputText;
+ outputBox.style.color = sessionStorage.outputColor;
+ outputBox.scrollTop = sessionStorage.outputScrollPos
outputVisible = true;
- } else {
- //console.log("Storing output values")
- sessionStorage.outputText = document.getElementsByClassName("outputBox")[0].value
- sessionStorage.outputColor = document.getElementsByClassName("outputBox")[0].style.color
- sessionStorage.outputScrollPos = document.getElementsByClassName("outputBox")[0].scrollTop
}
+ editorExists = true;
+ } else if (editorExists) {
+ editorExists = false;
+ console.log("editor removed (and output)");
+ //console.log("Editor left the screen")
+ editorVisible = false;
+ outputVisible = false;
+ //console.log("Storing editor values")
+ //outputBox.removeEventListener("change");
+ //editorBox.removeEventListener("change");
+ /*
+ sessionStorage.editorText = document.getElementsByClassName("editorBox")[0].value
+ sessionStorage.editorScrollPos = document.getElementsByClassName("editorBox")[0].scrollTop
+ //console.log("Output left the screen")
+ //console.log("Storing output values")
+ sessionStorage.outputText = document.getElementsByClassName("outputBox")[0].value
+ sessionStorage.outputColor = document.getElementsByClassName("outputBox")[0].style.color
+ sessionStorage.outputScrollPos = document.getElementsByClassName("outputBox")[0].scrollTop
+ */
}
+
+});
+document.addEventListener("DOMContentLoaded", function(event) {
+ console.log("DOM fully loaded and parsed");
+ let editorBox = document.getElementsByClassName("editorBox")[0];
+ let outputBox = document.getElementsByClassName("outputBox")[0];
+ editorBox.addEventListener('change', (event) => {
+ sessionStorage.editorText = event.target.value;
+ sessionStorage.editorScrollPos = event.target.scrollTop;
+ });
+ outputBox.addEventListener('change', (event) => {
+ sessionStorage.outputText = event.target.value;
+ sessionStorage.outputScrollPos = event.target.scrollTop;
+ sessionStorage.outputColor = event.target.style.color
+ });
+ observer.observe(document.body, {childList: true, subtree: true});
+});
+/*
+setInterval(() => {
// reset output box once roblox closes
if (getProcesses().length == 0) {
if (robloxExistedAtTheTimeThisVariableWasDefinedNoCap) {
@@ -140,4 +165,5 @@ setInterval(() => {
robloxExistedAtTheTimeThisVariableWasDefinedNoCap = true;
}
-}, 1000);
\ No newline at end of file
+}, 2500);
+*/
\ No newline at end of file
diff --git a/electron/main.js b/electron/main.js
index 2a3c808..1531897 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -38,7 +38,7 @@ const createMainWindow = () => {
transparent: true,
frame: false,
titleBarStyle: 'customButtonsOnHover',
- backgroundColor: '#00ffffff',
+ backgroundColor: 'ffffffff', //'#00ffffff',
closable: false,
maximizable: false,
resizable: false
diff --git a/package.json b/package.json
index 41fb8ad..c45648e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "caliware",
- "version": "1.3.1",
+ "version": "1.3.2",
"bootstrapperVersion": "1.1.0",
"private": true,
"main": "electron/main.js",
@@ -8,7 +8,9 @@
"bindings": "^1.5.0",
"child_process": "^1.0.2",
"electron-is-dev": "^2.0.0",
+ "express": "^4.17.2",
"fs": "0.0.1-security",
+ "http": "0.0.1-security",
"keytar": "^7.6.0",
"node-fetch": "^2.6.1",
"os": "^0.1.2",
diff --git a/public/utils.js b/public/utils.js
index 91ecd77..01b4d34 100644
--- a/public/utils.js
+++ b/public/utils.js
@@ -1,5 +1,5 @@
const fs2 = require("fs"); // these have a 2 in their name because they are redeclared in the other js file and that makes the interpreter sad :(
-const path2 = require("path")
+const path2 = require("path");
// Load prefs
let prefsFileLocation2 = path2.join(__dirname, "../../config.json");
var prefsObj2;
@@ -57,14 +57,21 @@ window.setPreference = async function(preference, value) { // string preference,
window.minimizeWindow = function() {
require("electron").remote.BrowserWindow.getFocusedWindow().minimize();
}
-
+let updateAvailable = "unloaded";
window.togglePreferencePane = function(bool) {
if (bool) {
+ // we dont wanna keep checking the filesystem for update file, so we'll only do it once
+ if (updateAvailable == "unloaded") updateAvailable = fs.existsSync(path.join(__dirname, "../../newapp.asar"))
document.getElementById("configPage").style.position = "static"
document.getElementById("configPage").style.visibility = "visible"
+ try {if (updateAvailable) {
+ document.getElementById("pending").style.visibility = "visible"
+ firstUpdateCheck = false;
+ }} catch(err) {console.error(err)}
} else {
document.getElementById("configPage").style.position = "absolute"
document.getElementById("configPage").style.visibility = "hidden"
+ document.getElementById("pending").style.visibility = "hidden"
}
}
@@ -84,47 +91,65 @@ sessionStorage.outputScrollPos = 0;
let robloxExistedAtTheTimeThisVariableWasDefinedNoCap = false;
-setInterval(() => {
- if (document.getElementsByClassName("editorBox").length == 0) {
- if (editorVisible) {
- //console.log("Editor left the screen")
- editorVisible = false;
- }
- }
- if (document.getElementsByClassName("editorBox").length == 1) {
- if (!editorVisible) {
+// migrating code from setInterval to onclick events
+
+var editorExists = true; //document.body.contains(document.getElementsByClassName("editorBox")[0]);
+var observer = new MutationObserver(function(mutations) {
+ if (document.body.contains(document.getElementsByClassName("editorBox")[0])) {
+ if (!editorExists) {
+ console.log("editor inserted (and output)");
//console.log("Editor visible again")
- document.getElementsByClassName("editorBox")[0].value = sessionStorage.editorText
- document.getElementsByClassName("editorBox")[0].scrollTop = sessionStorage.editorScrollPos
+ let editorBox = document.getElementsByClassName("editorBox")[0];
+ let outputBox = document.getElementsByClassName("outputBox")[0];
+ editorBox.value = sessionStorage.editorText
+ editorBox.scrollTop = sessionStorage.editorScrollPos
editorVisible = true;
- } else {
- //console.log("Storing editor values")
- sessionStorage.editorText = document.getElementsByClassName("editorBox")[0].value
- sessionStorage.editorScrollPos = document.getElementsByClassName("editorBox")[0].scrollTop
- }
- }
-
- if (document.getElementsByClassName("outputBox").length == 0) {
- if (outputVisible) {
- //console.log("Output left the screen")
- outputVisible = false;
- }
- }
- if (document.getElementsByClassName("outputBox").length == 1) {
- if (!outputVisible) {
//console.log("Output visible again")
- document.getElementsByClassName("outputBox")[0].value = sessionStorage.outputText;
- document.getElementsByClassName("outputBox")[0].style.color = sessionStorage.outputColor;
- document.getElementsByClassName("outputBox")[0].scrollTop = sessionStorage.outputScrollPos
+ outputBox.value = sessionStorage.outputText;
+ outputBox.style.color = sessionStorage.outputColor;
+ outputBox.scrollTop = sessionStorage.outputScrollPos
outputVisible = true;
- } else {
- //console.log("Storing output values")
- sessionStorage.outputText = document.getElementsByClassName("outputBox")[0].value
- sessionStorage.outputColor = document.getElementsByClassName("outputBox")[0].style.color
- sessionStorage.outputScrollPos = document.getElementsByClassName("outputBox")[0].scrollTop
}
+ editorExists = true;
+ } else if (editorExists) {
+ editorExists = false;
+ console.log("editor removed (and output)");
+ //console.log("Editor left the screen")
+ editorVisible = false;
+ outputVisible = false;
+ //console.log("Storing editor values")
+ //outputBox.removeEventListener("change");
+ //editorBox.removeEventListener("change");
+ /*
+ sessionStorage.editorText = document.getElementsByClassName("editorBox")[0].value
+ sessionStorage.editorScrollPos = document.getElementsByClassName("editorBox")[0].scrollTop
+ //console.log("Output left the screen")
+ //console.log("Storing output values")
+ sessionStorage.outputText = document.getElementsByClassName("outputBox")[0].value
+ sessionStorage.outputColor = document.getElementsByClassName("outputBox")[0].style.color
+ sessionStorage.outputScrollPos = document.getElementsByClassName("outputBox")[0].scrollTop
+ */
}
+
+});
+document.addEventListener("DOMContentLoaded", function(event) {
+ console.log("DOM fully loaded and parsed");
+ let editorBox = document.getElementsByClassName("editorBox")[0];
+ let outputBox = document.getElementsByClassName("outputBox")[0];
+ editorBox.addEventListener('change', (event) => {
+ sessionStorage.editorText = event.target.value;
+ sessionStorage.editorScrollPos = event.target.scrollTop;
+ });
+ outputBox.addEventListener('change', (event) => {
+ sessionStorage.outputText = event.target.value;
+ sessionStorage.outputScrollPos = event.target.scrollTop;
+ sessionStorage.outputColor = event.target.style.color
+ });
+ observer.observe(document.body, {childList: true, subtree: true});
+});
+/*
+setInterval(() => {
// reset output box once roblox closes
if (getProcesses().length == 0) {
if (robloxExistedAtTheTimeThisVariableWasDefinedNoCap) {
@@ -140,4 +165,5 @@ setInterval(() => {
robloxExistedAtTheTimeThisVariableWasDefinedNoCap = true;
}
-}, 1000);
\ No newline at end of file
+}, 2500);
+*/
\ No newline at end of file
diff --git a/src/App.css b/src/App.css
index af937e1..0aa47f7 100644
--- a/src/App.css
+++ b/src/App.css
@@ -153,6 +153,15 @@ html, body {
left: 410px;
top: 255px;
}
+#pending {
+ position: absolute;
+ visibility: hidden;
+ color: orange;
+ font-size: 8px;
+ font-weight: bold;
+ left: 403px;
+ top: 262px;
+}
Button {
margin-bottom: 5px;
diff --git a/src/App.js b/src/App.js
index 3b8779c..5d8cbe4 100644
--- a/src/App.js
+++ b/src/App.js
@@ -61,7 +61,7 @@ export default class extends Component {
id="autoUpdateToggle"
onClick= {(e) => {window.setPreference("autoUpdate", document.getElementById("autoUpdateToggle").checked)}}
>Auto updates
-
+
@@ -72,6 +72,7 @@ export default class extends Component {
}}>
Open Resources Folder
+ (update downloaded)
@@ -146,7 +147,7 @@ export default class extends Component {
-