summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/login.js1
-rw-r--r--js/codeq/settings.js41
2 files changed, 32 insertions, 10 deletions
diff --git a/js/codeq/login.js b/js/codeq/login.js
index 9be1c8c..391592b 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -20,6 +20,7 @@
$.merge(true, codeq.settings, sett);
if('lan' in sett && sett['lan'] in codeq.supportedLangs){
codeq.setLang(sett['lan']);
+ $("#gui_lang_select").val(sett['lan']);
}
codeq.globalStateMachine.transition('language');
diff --git a/js/codeq/settings.js b/js/codeq/settings.js
index 73bef14..9eb4366 100644
--- a/js/codeq/settings.js
+++ b/js/codeq/settings.js
@@ -2,17 +2,38 @@
* Created by robert on 9/29/15.
*/
(function(){
- $("#gui_lang_select").on("change",function() {
+
+ var guiLangSelect = $("#gui_lang_select");
+ var previousLang = guiLangSelect.val();
+ var closedWithSave = false;
+
+ guiLangSelect.on("change",function() {
var lang = $("#gui_lang_select").val();
if (lang in codeq.supportedLangs) {
- codeq.log.debug("Changing lang to:" + lang);
- codeq.comms.updateSettings({'lang': lang})
- .then(function (data) {
- if (data.code !== 0) throw new Error('Change language failed, code: ' + data.code + ', message: ' + data.message);
- codeq.log.debug("success with settings");
- codeq.setLang(lang);
- })
- .done();
+ codeq.setLang(lang);
}
- })
+ });
+
+ $("#settings_save_btn").on("click", function() {
+ closedWithSave = true;
+ });
+
+ $("#settings_dropdown_menu").on("shown.bs.dropdown", function() {
+ closedWithSave = false;
+ previousLang = codeq.getLang();
+ }).on("hidden.bs.dropdown", function() {
+ if(closedWithSave){
+ var lang = $("#gui_lang_select").val();
+ if (lang in codeq.supportedLangs) {
+ codeq.comms.updateSettings({'lang': lang})
+ .then(function (data) {
+ if (data.code !== 0) throw new Error('Change language failed, code: ' + data.code + ', message: ' + data.message);//error msg if something went wring while saving to db
+ })
+ .done();
+ }
+ }else{
+ $("#gui_lang_select").val(previousLang);
+ if (previousLang in codeq.supportedLangs) codeq.setLang(previousLang);
+ }
+ });
})(); \ No newline at end of file