1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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-v2/$resources/admin.js",
success: function (data) {
eval(data);
},
error: function (error) {
console.error("Unable to load script at " + "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin-v2/$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;
}
}
|