summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-13 14:23:02 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-13 14:23:02 +0200
commitf48b45f5c7e040a7a6cbe243f6196f77c2b1e895 (patch)
treef3b04e8598073397e4ccc78c1172ba63bbbfa12c
parenta2275a04ac07e22790a31e128e3df4473d4afc26 (diff)
Simplify settings handling
-rw-r--r--js/codeq/settings.js12
1 files changed, 3 insertions, 9 deletions
diff --git a/js/codeq/settings.js b/js/codeq/settings.js
index df704b0..dd844a5 100644
--- a/js/codeq/settings.js
+++ b/js/codeq/settings.js
@@ -6,7 +6,6 @@
var guiLangSelect = $('#gui_lang_select'),
robotAddressInput = $('#robot_address_input'),
previousGuiLang = guiLangSelect.val(),
- previousRobotAddress = robotAddressInput.val(),
closedWithSave = false;
guiLangSelect.on("change",function() {
@@ -23,15 +22,10 @@
$("#settings_dropdown_menu").on("shown.bs.dropdown", function() {
closedWithSave = false;
previousGuiLang = codeq.settings['gui_lang'];
- previousRobotAddress = robotAddressInput.val();
}).on("hidden.bs.dropdown", function() {
if(closedWithSave){
- var guiLang = guiLangSelect.val(),
- newSettings = {'robot_address': robotAddressInput.val()};
- if (guiLang in codeq.supportedLangs) {
- newSettings['gui_lang'] = guiLang;
- }
- codeq.comms.updateSettings(newSettings)
+ codeq.settings['robot_address'] = robotAddressInput.val();
+ codeq.comms.updateSettings(codeq.settings)
.then(function (data) {
if (data.code !== 0) {
throw new Error('Updating settings failed, code: ' + data.code + ', message: ' + data.message);
@@ -41,7 +35,7 @@
}else{
guiLangSelect.val(previousGuiLang);
if (previousGuiLang in codeq.supportedLangs) codeq.setLang(previousGuiLang);
- robotAddressInput.val(previousRobotAddress);
+ robotAddressInput.val(codeq.settings['robot_address']);
}
});
})();