improve(webui): only send requests for cheats tab when it's opened
This commit is contained in:
parent
81cc773faa
commit
3aca930f34
@ -15,7 +15,6 @@ function loginFromLocalStorage() {
|
|||||||
window.accountId = data.id;
|
window.accountId = data.id;
|
||||||
window.authz = "accountId=" + data.id + "&nonce=" + data.Nonce;
|
window.authz = "accountId=" + data.id + "&nonce=" + data.Nonce;
|
||||||
updateInventory();
|
updateInventory();
|
||||||
fetchSettings();
|
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
logout();
|
logout();
|
||||||
@ -656,26 +655,6 @@ $("#mod-to-acquire").on("input", () => {
|
|||||||
$("#mod-to-acquire").removeClass("is-invalid");
|
$("#mod-to-acquire").removeClass("is-invalid");
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchSettings() {
|
|
||||||
fetch("/custom/config")
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(json =>
|
|
||||||
Object.entries(json).forEach(entry => {
|
|
||||||
const [key, value] = entry;
|
|
||||||
var x = document.getElementById(`${key}`);
|
|
||||||
if (x != null) {
|
|
||||||
if (x.type == "checkbox") {
|
|
||||||
if (value === true) {
|
|
||||||
x.setAttribute("checked", "checked");
|
|
||||||
}
|
|
||||||
} else if (x.type == "number") {
|
|
||||||
x.setAttribute("value", `${value}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const uiConfigs = [
|
const uiConfigs = [
|
||||||
"autoCreateAccount",
|
"autoCreateAccount",
|
||||||
"skipStoryModeChoice",
|
"skipStoryModeChoice",
|
||||||
@ -721,27 +700,52 @@ function doChangeSettings() {
|
|||||||
|
|
||||||
// Cheats route
|
// Cheats route
|
||||||
|
|
||||||
fetch("http://localhost:61558/ping", { mode: "no-cors" }).then(() => {
|
single.getRoute("/webui/cheats").on("beforeload", function () {
|
||||||
$("#client-cheats-nok").addClass("d-none");
|
fetch("/custom/config")
|
||||||
$("#client-cheats-ok").removeClass("d-none");
|
.then(response => response.json())
|
||||||
|
.then(json =>
|
||||||
|
Object.entries(json).forEach(entry => {
|
||||||
|
const [key, value] = entry;
|
||||||
|
var x = document.getElementById(`${key}`);
|
||||||
|
if (x != null) {
|
||||||
|
if (x.type == "checkbox") {
|
||||||
|
if (value === true) {
|
||||||
|
x.setAttribute("checked", "checked");
|
||||||
|
}
|
||||||
|
} else if (x.type == "number") {
|
||||||
|
x.setAttribute("value", `${value}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
fetch("http://localhost:61558/skip_mission_start_timer")
|
fetch("http://localhost:61558/ping", { mode: "no-cors" })
|
||||||
.then(res => res.text())
|
.then(() => {
|
||||||
.then(res => {
|
$("#client-cheats-ok").removeClass("d-none");
|
||||||
document.getElementById("skip_mission_start_timer").checked = res == "1";
|
$("#client-cheats-nok").addClass("d-none");
|
||||||
});
|
|
||||||
document.getElementById("skip_mission_start_timer").onchange = function () {
|
|
||||||
fetch("http://localhost:61558/skip_mission_start_timer?" + this.checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
fetch("http://localhost:61558/fov_override")
|
fetch("http://localhost:61558/skip_mission_start_timer")
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
document.getElementById("fov_override").value = parseFloat(res) * 10000;
|
document.getElementById("skip_mission_start_timer").checked = res == "1";
|
||||||
|
});
|
||||||
|
document.getElementById("skip_mission_start_timer").onchange = function () {
|
||||||
|
fetch("http://localhost:61558/skip_mission_start_timer?" + this.checked);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch("http://localhost:61558/fov_override")
|
||||||
|
.then(res => res.text())
|
||||||
|
.then(res => {
|
||||||
|
document.getElementById("fov_override").value = parseFloat(res) * 10000;
|
||||||
|
});
|
||||||
|
document.getElementById("fov_override").oninput = function () {
|
||||||
|
fetch("http://localhost:61558/fov_override?" + this.value);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
$("#client-cheats-nok").removeClass("d-none");
|
||||||
|
$("#client-cheats-ok").addClass("d-none");
|
||||||
});
|
});
|
||||||
document.getElementById("fov_override").oninput = function () {
|
|
||||||
fetch("http://localhost:61558/fov_override?" + this.value);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function doUnlockAllFocusSchools() {
|
function doUnlockAllFocusSchools() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user