From 62a36f98b95610883570cc6575b35ffec80b697f Mon Sep 17 00:00:00 2001 From: Sam Sneed <163201376+sam-sneed@users.noreply.github.com> Date: Tue, 28 May 2024 18:28:22 +0000 Subject: [PATCH] Update frontend.js --- frontend.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/frontend.js b/frontend.js index fb5f8e4..7f4bc8d 100644 --- a/frontend.js +++ b/frontend.js @@ -9,9 +9,20 @@ class JSPlusPlus { let js = jsCode.toString(); Function(js)() } + readInternetText(url) { + var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object + request.open('GET', url, false); // Open the request with synchronous mode + request.send(null); // Send the request with no additional data + + if (request.status === 200) { // Check if the request was successful + return request.responseText; // Return the response text + } else { + return 'Error: ' + request.status; // Return an error message if the request failed + } + } require(jsURI) { try { - let req = JSPlusPlus.Frontend.readInternetText(jsURI); + let req = JSPlusPlus.JSPlusPlus.readInternetText(jsURI); JSPlusPlus.General.exec(req); } catch { console.log(`Error! (Using Node.JS?) @@ -21,7 +32,7 @@ class JSPlusPlus { } } } - Frontend = class { + HTMLFrontend = class { // Get element by ID getElementById(elementID) { return document.getElementById(elementID) @@ -389,18 +400,6 @@ class JSPlusPlus { requestAnimationFrame(animate); } - readInternetText(url) { - var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object - request.open('GET', url, false); // Open the request with synchronous mode - request.send(null); // Send the request with no additional data - - if (request.status === 200) { // Check if the request was successful - return request.responseText; // Return the response text - } else { - return 'Error: ' + request.status; // Return an error message if the request failed - } - } - // Example: getFileSize(path/to/file) getFileSize(file) { file = file.toString();