Update frontend.js

This commit is contained in:
Sam Sneed 2024-05-28 18:28:22 +00:00 committed by GitHub
parent 8f05b551c1
commit 62a36f98b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();