Update and rename frontend.js to jspp.js
This commit is contained in:
parent
62a36f98b9
commit
9e4ae827de
1 changed files with 32 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
// JS++
|
||||||
// Created by Samuel Lord (NodeMixaholic/Sparksammy)
|
// Created by Samuel Lord (NodeMixaholic/Sparksammy)
|
||||||
// Now Maintained by Sneed Group
|
// Now Maintained by Sneed Group
|
||||||
// Licensed under Samuel Public License with <3
|
// Licensed under Samuel Public License with <3
|
||||||
|
@ -10,16 +11,40 @@ class JSPlusPlus {
|
||||||
Function(js)()
|
Function(js)()
|
||||||
}
|
}
|
||||||
readInternetText(url) {
|
readInternetText(url) {
|
||||||
var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object
|
try {
|
||||||
request.open('GET', url, false); // Open the request with synchronous mode
|
var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object
|
||||||
request.send(null); // Send the request with no additional data
|
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
|
if (request.status === 200) { // Check if the request was successful
|
||||||
return request.responseText; // Return the response text
|
return request.responseText; // Return the response text
|
||||||
} else {
|
} else {
|
||||||
return 'Error: ' + request.status; // Return an error message if the request failed
|
return 'Error: ' + request.status; // Return an error message if the request failed
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
try {
|
||||||
|
let http = require('http');
|
||||||
|
let body = ""
|
||||||
|
let request = http.get(url, function (res) {
|
||||||
|
var data = '';
|
||||||
|
res.on('data', function (chunk) {
|
||||||
|
data += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', function () {
|
||||||
|
body = data.toString()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
request.on('error', function (e) {
|
||||||
|
body = e.message
|
||||||
|
});
|
||||||
|
request.end();
|
||||||
|
return body;
|
||||||
|
} catch {
|
||||||
|
return "Unknown error fetching URL! :'("
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require(jsURI) {
|
require(jsURI) {
|
||||||
try {
|
try {
|
||||||
let req = JSPlusPlus.JSPlusPlus.readInternetText(jsURI);
|
let req = JSPlusPlus.JSPlusPlus.readInternetText(jsURI);
|
||||||
|
@ -445,7 +470,5 @@ class JSPlusPlus {
|
||||||
JSPlusPlus.General.require("https://cdn.jsdelivr.net/npm/gun/gun.js")
|
JSPlusPlus.General.require("https://cdn.jsdelivr.net/npm/gun/gun.js")
|
||||||
return Gun(relays)
|
return Gun(relays)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue