Skip to content

Commit

Permalink
Improve solution around #5161
Browse files Browse the repository at this point in the history
This will make sure a refresh happens when any of the three values change.  Should be good enough.
  • Loading branch information
TheWitness committed Jan 21, 2023
1 parent 942a7d6 commit a082f37
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
<script type='text/javascript'>

var themeChanged = false;
var langChanged = false;
var langRefresh = false;
var currentTheme = '';
var currentLang = '';
var rrdArchivePath = '';
Expand Down Expand Up @@ -506,7 +506,7 @@
return false;
}

if (themeChanged == true || langChanged == true) {
if (themeChanged == true || langRefresh == true) {
$.post('settings.php?tab='+$('#tab').val()+'&header=false', $('input, select, textarea').prop('disabled', false).serialize()).done(function(data) {
document.location = 'settings.php?newtheme=1&tab='+$('#tab').val();
});
Expand All @@ -519,8 +519,10 @@
});

if (currentTab == 'general') {
currentPerms = $('#graph_auth_method').val();
currentLang = $('#i18n_auto_detection').val();
currentPerms = $('#graph_auth_method').val();
currentLangDetect = $('#i18n_auto_detection').val();
currentLanguage = $('#i18n_default_language').val();
currentLangSupport = $('#i18n_language_support').val();

$('#selective_plugin_debug').multiselect({
menuHeight: $(window).height()*.7,
Expand Down Expand Up @@ -570,7 +572,7 @@
permsChanger();
});

$('#i18n_auto_detection').change(function() {
$('#i18n_default_language, #i18n_auto_detection, #i18n_language_support').change(function() {
langDetectionChanger();
});
} else if (currentTab == 'spikes') {
Expand Down Expand Up @@ -868,10 +870,14 @@ function themeChanger() {
}

function langDetectionChanger() {
if ($('#i18n_auto_detection').val() != currentLang) {
langChanged = true;
var changed = currentLanguage != $('#i18n_default_language').val() ||
currentLangDetect != $('#i18n_auto_detection').val() ||
currentLangSupport != $('#i18n_language_support').val();

if (changed) {
langRefresh = true;
} else {
langChanged = false;
langRefresh = false;
}
}

Expand Down

0 comments on commit a082f37

Please sign in to comment.