summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html5
-rw-r--r--js/codeq/login.js1
-rw-r--r--js/codeq/robot.js3
-rw-r--r--js/codeq/settings.js36
-rw-r--r--res/en.json1
-rw-r--r--res/sl.json1
6 files changed, 31 insertions, 16 deletions
diff --git a/index.html b/index.html
index bd861d8..62c9d41 100644
--- a/index.html
+++ b/index.html
@@ -74,6 +74,11 @@
<!--<option value="d">Dolgooooooooooooooooooooooooooooooooooooooooooooooo</option>-->
</select>
</div>
+ <div class="form-group">
+ <span class="small" data-tkey="robot_address">Robot’s address</span>
+ <a class="text-muted" data-container="body" data-toggle="popover" data-trigger="hover" data-placement="left" data-html="true" data-content="<span class='small'>Set the robot's IP address.</span>" data-original-title="" title=""><i class="glyphicon glyphicon-question-sign"></i></a><br>
+ <input type="text" class="form-control" id="robot_address_input" />
+ </div>
<!--<div class="form-group">
<span class="small" data-tkey="language">
Language
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);
}
});
})();
diff --git a/res/en.json b/res/en.json
index 4cae11b..2dbf4fd 100644
--- a/res/en.json
+++ b/res/en.json
@@ -1,5 +1,6 @@
{
"language": "Language",
+ "robot_address": "Robot’s IP address",
"problem_list": "Problems",
"python": "Python",
"prolog": "Prolog",
diff --git a/res/sl.json b/res/sl.json
index 26d33ec..eb6b24d 100644
--- a/res/sl.json
+++ b/res/sl.json
@@ -1,5 +1,6 @@
{
"language": "Jezik",
+ "robot_address": "Robotov naslov IP",
"problem_list": "Naloge",
"python": "Python",
"prolog": "Prolog",