Alert if leaving settings without saving changes

This commit is contained in:
JonnyWong16 2016-05-15 02:11:58 -07:00
parent 663b9a610a
commit 363d1b07ca

View file

@ -2059,12 +2059,21 @@ $(document).ready(function() {
}); });
// Global Variables // Global Variables
settingsChanged = false;
serverChanged = false; serverChanged = false;
authChanged = false; authChanged = false;
httpChanged = false; httpChanged = false;
monitorChanged = false; monitorChanged = false;
directoryChanged = false; directoryChanged = false;
// Alert if leaving the page without saving changes to settings
window.onbeforeunload = confirmExit;
function confirmExit() {
if (settingsChanged) {
return "Settings were changed without saving!";
}
}
// Alert the user that their changes require a restart. // Alert the user that their changes require a restart.
function postSaveChecks() { function postSaveChecks() {
if ((serverChanged && $('#monitoring_use_websocket').is(":checked")) || authChanged || httpChanged || monitorChanged || directoryChanged) { if ((serverChanged && $('#monitoring_use_websocket').is(":checked")) || authChanged || httpChanged || monitorChanged || directoryChanged) {
@ -2072,9 +2081,14 @@ $(document).ready(function() {
} }
$("#http_hashed_password").val($("#http_hash_password").is(":checked") ? 1 : 0) $("#http_hashed_password").val($("#http_hash_password").is(":checked") ? 1 : 0)
getSchedulerTable(); getSchedulerTable();
settingsChanged = false;
} }
var configForm = $("#configUpdate"); var configForm = $("#configUpdate");
configForm.change(function () {
settingsChanged = true;
});
function saveSettings() { function saveSettings() {
if (configForm.parsley().validate()) { if (configForm.parsley().validate()) {
doAjaxCall('configUpdate', $(this), 'tabs', true, postSaveChecks); doAjaxCall('configUpdate', $(this), 'tabs', true, postSaveChecks);