summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/codeq/core.js4
-rw-r--r--js/codeq/hint.js2
-rw-r--r--js/codeq/login.js16
-rw-r--r--js/codeq/navigation.js5
-rw-r--r--js/codeq/robot.js3
-rw-r--r--js/codeq/settings.js32
-rw-r--r--js/codeq/statusbar.js26
-rw-r--r--js/codeq/translation.js4
8 files changed, 36 insertions, 56 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js
index 6b76042..0976ecc 100644
--- a/js/codeq/core.js
+++ b/js/codeq/core.js
@@ -395,10 +395,6 @@
'sl': 'Slovenščina'
},
'isWebApp': false, // this is a PhoneGap/Cordova build, will be overridden in cordova.js for webapp
- 'getLang': function () {
- return codeq.settings['gui_lang'];
- },
-
'setLang': function (newLang) {
codeq.settings['gui_lang'] = newLang;
codeq.fire('langchange', {'lang': newLang});
diff --git a/js/codeq/hint.js b/js/codeq/hint.js
index d5e27b0..b5468e0 100644
--- a/js/codeq/hint.js
+++ b/js/codeq/hint.js
@@ -280,7 +280,7 @@
jqMark.popover({
'content': function () {
// decide on what to display only after the popup is triggered, so we can choose the correct translation
- return htmlPrefix + translations[codeq.getLang()] + '</span>';
+ return htmlPrefix + translations[codeq.settings['gui_lang']] + '</span>';
},
'html': true,
'placement': 'auto bottom',
diff --git a/js/codeq/login.js b/js/codeq/login.js
index b8323e1..32b821d 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');
@@ -47,6 +48,7 @@
codeq.globalStateMachine.register('login',{
'enter': function(){
+ $('#navigation-home').off('click');//remove the click listener of this element here only - in each other state the listener should exist
$('#signed-in-title').html('');
$("#submit").on('click', loginFun);
formInputs.on('keyup', function (ev) {
@@ -54,16 +56,22 @@
$('#submit').trigger('click');
}
});
- $('#modalLogIn').modal();
- //$("#screen_login").css('display', '');
+ //$('#modalLogIn').modal();
+ $("#screen_login").css('display', '');
$('#disabled').css('display', 'none');
},
'exit' : function(){
$("#submit").off('click', loginFun);
formInputs.off('keyup');
- $('#modalLogIn').modal('hide');
- //$("#screen_login").css('display', 'none');
+ //$('#modalLogIn').modal('hide');
+ $("#screen_login").css('display', 'none');
+ $('#signed-in-title').html('Signed in as '+$('#username').val());
$("#password").val('');
+ //re-enable the click listener
+ $('#navigation-home').on('click', function(e){
+ codeq.globalStateMachine.transition('language');
+ e.preventDefault();
+ });
}
});
})();
diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js
index eafa5cc..af1d250 100644
--- a/js/codeq/navigation.js
+++ b/js/codeq/navigation.js
@@ -105,14 +105,15 @@
codeq.comms.logout()
.then(function (data) {
console.log(data);
- //codeq.globalStateMachine.transition('login');
+ codeq.comms.disconnect();
+ codeq.globalStateMachine.transition('login');
})
.fail(function (reason) {
console.log(reason);
})
.done();
- codeq.globalStateMachine.transition('login');
+ //codeq.globalStateMachine.transition('login');
e.preventDefault();//prevent this since we'll trigger a page reload otherwise
});
$('#navigation-profile').on('click', function(e){
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..dd844a5 100644
--- a/js/codeq/settings.js
+++ b/js/codeq/settings.js
@@ -3,12 +3,13 @@
*/
(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(),
+ 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 +21,21 @@
$("#settings_dropdown_menu").on("shown.bs.dropdown", function() {
closedWithSave = false;
- previousLang = codeq.getLang();
+ previousGuiLang = codeq.settings['gui_lang'];
}).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();
- }
+ 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);
+ }
+ })
+ .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(codeq.settings['robot_address']);
}
});
})();
diff --git a/js/codeq/statusbar.js b/js/codeq/statusbar.js
deleted file mode 100644
index 56070bd..0000000
--- a/js/codeq/statusbar.js
+++ /dev/null
@@ -1,26 +0,0 @@
-(function () {
-
- var jqBar = $('#topbar'),
- jqLang = jqBar.find('.lang-selection'),
- jqLangChoice = jqLang.find('.lang-choice');
-
- (function () {
- var langs = codeq.supportedLangs,
- jqMenu = jqLang.find('.dropdown-menu'),
- lang, cssClass;
- for (lang in langs) {
- if (!langs.hasOwnProperty(lang)) continue;
- cssClass = 'lang-' + lang;
- jqMenu.append('<li><a class="' + cssClass + '">' + lang + '</a></li>');
- jqMenu.find('.' + cssClass).on('click', (function (l) {return function () {codeq.setLang(l)};})(lang));
- }
- })();
-
- codeq.on('langchange', function (params) {
- jqLangChoice.text(params.lang);
- });
-
- codeq.statusbar = {
-
- };
-})(); \ No newline at end of file
diff --git a/js/codeq/translation.js b/js/codeq/translation.js
index bd2bf32..f0c8aab 100644
--- a/js/codeq/translation.js
+++ b/js/codeq/translation.js
@@ -80,7 +80,7 @@
'emptyDictionary': {}, // use this with registerDictionary when you don't want any translations
'translateDom': function (jqTopElt) {
- var lang = codeq.getLang();
+ var lang = codeq.settings['gui_lang'];
jqTopElt.filter('[data-tkey]').each(function () {
translateElement(jqTopElt,'tkey', lang)
});
@@ -93,4 +93,4 @@
return dicts[name];
}
};
-})(); \ No newline at end of file
+})();