From 529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105 Mon Sep 17 00:00:00 2001 From: Minteck Date: Tue, 24 Aug 2021 15:38:16 +0200 Subject: Update --- .../resources/private/global.js._/index.php | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Neutron-trunk/resources/private/global.js._/index.php (limited to 'Neutron-trunk/resources/private/global.js._/index.php') 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 + ""; + 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 + ""; + Array.from(document.getElementsByTagName('script')).forEach((el) => { + if (el.src.trim() == "") { + eval(el.innerHTML); + } + }); + if (location.pathname.startsWith("/cms-special/admin")) { + $.ajax({ + type: "GET", + dataType: 'html', + url: "/cms-special/admin/$resources/admin.js", + success: function (data) { + eval(data); + }, + error: function (error) { + console.error("Unable to load script at " + "/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 -- cgit