aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/resources/private/global.js._/index.php
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 15:38:16 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 15:38:16 +0200
commit529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105 (patch)
tree8a50c30271b9b328cde0d907b1441f2dabdc341b /Neutron-trunk/resources/private/global.js._/index.php
parent15e4724761c50b30803df1811a525c85058f70bf (diff)
downloadelectrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.tar.gz
electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.tar.bz2
electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.zip
Update
Diffstat (limited to 'Neutron-trunk/resources/private/global.js._/index.php')
-rw-r--r--Neutron-trunk/resources/private/global.js._/index.php95
1 files changed, 95 insertions, 0 deletions
diff --git a/Neutron-trunk/resources/private/global.js._/index.php b/Neutron-trunk/resources/private/global.js._/index.php
new file mode 100644
index 0000000..2a721a8
--- /dev/null
+++ b/Neutron-trunk/resources/private/global.js._/index.php
@@ -0,0 +1,95 @@
+window.onerror = function(msg, url, line, col, error) {
+ if (msg == "ResizeObserver loop completed with undelivered notifications.") {
+ return;
+ }
+ if (typeof line != "undefined") {
+ if (typeof col != "undefined") {
+ linecol = "at line " + line + " and column " + col
+ } else {
+ linecol = "at line " + line
+ }
+ }
+ alert_full("Sorry, a runtime error occurred on this page:\n" + msg + "\n\nThe error is from " + url + "\n" + linecol + "\n\nWe suggest that you submit a bug report on Neutron's website and include above information.");
+};
+
+// New Ajax Lazy Loader
+location.reloadLegacy = location.reload;
+reloadPage = () => { location.reload() };
+ajaxPageReload = () => {
+ try {
+ document.title = "...";
+ $('body').fadeOut(200);
+ $.ajax({
+ type: "GET",
+ dataType: 'html',
+ url: location.href,
+ success: function (data) {
+ document.getElementsByTagName('html')[0].innerHTML = data + "<style>body{display:none;}</style>";
+ setTimeout(() => {
+ $('body').fadeIn(200);
+ }, 500)
+ },
+ error: function (error) {
+ location.reloadLegacy();
+ },
+ cache: false,
+ contentType: false,
+ processData: false
+ });
+ } catch (err) {
+ location.reloadLegacy();
+ }
+}
+switchToPage = (url) => {
+ try {
+ let stateObj = {
+ foo: ".",
+ };
+ document.title = "...";
+ history.pushState(stateObj, "page 2", "#/loading");
+ $('body').fadeOut(200);
+ $.ajax({
+ type: "GET",
+ dataType: 'html',
+ url: url,
+ success: function (data) {
+ document.getElementsByTagName('html')[0].innerHTML = data + "<style>body{display:none;}</style>";
+ Array.from(document.getElementsByTagName('script')).forEach((el) => {
+ if (el.src.trim() == "") {
+ eval(el.innerHTML);
+ }
+ });
+ if (location.pathname.startsWith("<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin")) {
+ $.ajax({
+ type: "GET",
+ dataType: 'html',
+ url: "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/admin.js",
+ success: function (data) {
+ eval(data);
+ },
+ error: function (error) {
+ console.error("Unable to load script at " + "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/$resources/admin.js");
+ },
+ cache: false,
+ contentType: false,
+ processData: false
+ });
+ }
+ setTimeout(() => {
+ $('body').fadeIn(200);
+ history.pushState(stateObj, "page 2", url);
+ }, 500)
+ },
+ error: function (error) {
+ console.log(error);
+ location.href = url;
+ },
+ cache: false,
+ contentType: false,
+ processData: false
+ });
+ } catch (err) {
+ console.log(err);
+ location.href = url;
+ }
+} \ No newline at end of file