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,6 +11,7 @@ class JSPlusPlus {
|
||||||
Function(js)()
|
Function(js)()
|
||||||
}
|
}
|
||||||
readInternetText(url) {
|
readInternetText(url) {
|
||||||
|
try {
|
||||||
var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object
|
var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object
|
||||||
request.open('GET', url, false); // Open the request with synchronous mode
|
request.open('GET', url, false); // Open the request with synchronous mode
|
||||||
request.send(null); // Send the request with no additional data
|
request.send(null); // Send the request with no additional data
|
||||||
|
@ -19,7 +21,30 @@ class JSPlusPlus {
|
||||||
} 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