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/robot.js3
-rw-r--r--js/codeq/settings.js36
3 files changed, 24 insertions, 16 deletions
diff --git a/js/codeq/login.js b/js/codeq/login.js
index d127fe3..114381c 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -30,6 +30,7 @@
codeq.setLang(sett['gui_lang']);
$("#gui_lang_select").val(sett['gui_lang']);
}
+ $('#robot_address_input').val(codeq.settings['robot_address'] || '');
codeq.globalStateMachine.transition('language');
//codeq.activateState('language');
diff --git a/js/codeq/robot.js b/js/codeq/robot.js
index 1188c7f..a1b76f1 100644
--- a/js/codeq/robot.js
+++ b/js/codeq/robot.js
@@ -147,8 +147,7 @@
alert(error);
},
reconnectTimer = null,
- address = '192.168.1.174:8000', // TODO get this from settings
- url = 'ws://' + address + '/',
+ url = 'ws://' + codeq.settings['robot_address'] + ':8000/',
socket = eio(url);
// set up the websocket events
diff --git a/js/codeq/settings.js b/js/codeq/settings.js
index 252a2ea..9e8e499 100644
--- a/js/codeq/settings.js
+++ b/js/codeq/settings.js
@@ -3,12 +3,14 @@
*/
(function(){
- var guiLangSelect = $("#gui_lang_select");
- var previousLang = guiLangSelect.val();
- var closedWithSave = false;
+ var guiLangSelect = $('#gui_lang_select'),
+ robotAddressInput = $('#robot_address_input'),
+ previousGuiLang = guiLangSelect.val(),
+ previousRobotAddress = robotAddressInput.val(),
+ closedWithSave = false;
guiLangSelect.on("change",function() {
- var lang = $("#gui_lang_select").val();
+ var lang = guiLangSelect.val();
if (lang in codeq.supportedLangs) {
codeq.setLang(lang);
}
@@ -20,20 +22,26 @@
$("#settings_dropdown_menu").on("shown.bs.dropdown", function() {
closedWithSave = false;
- previousLang = codeq.getLang();
+ previousGuiLang = codeq.getLang();
+ previousRobotAddress = robotAddressInput.val();
}).on("hidden.bs.dropdown", function() {
if(closedWithSave){
- var lang = $("#gui_lang_select").val();
- if (lang in codeq.supportedLangs) {
- codeq.comms.updateSettings({'gui_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();
+ var guiLang = guiLangSelect.val(),
+ newSettings = {'robot_address': robotAddressInput.val()};
+ if (guiLang in codeq.supportedLangs) {
+ newSettings['gui_lang'] = guiLang;
}
+ codeq.comms.updateSettings(newSettings)
+ .then(function (data) {
+ if (data.code !== 0) {
+ throw new Error('Updating settings failed, code: ' + data.code + ', message: ' + data.message);
+ }
+ })
+ .done();
}else{
- $("#gui_lang_select").val(previousLang);
- if (previousLang in codeq.supportedLangs) codeq.setLang(previousLang);
+ guiLangSelect.val(previousGuiLang);
+ if (previousGuiLang in codeq.supportedLangs) codeq.setLang(previousGuiLang);
+ robotAddressInput.val(previousRobotAddress);
}
});
})();