diff options
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/core.js | 4 | ||||
-rw-r--r-- | js/codeq/hint.js | 2 | ||||
-rw-r--r-- | js/codeq/login.js | 1 | ||||
-rw-r--r-- | js/codeq/robot.js | 3 | ||||
-rw-r--r-- | js/codeq/settings.js | 32 | ||||
-rw-r--r-- | js/codeq/statusbar.js | 26 | ||||
-rw-r--r-- | js/codeq/translation.js | 4 |
7 files changed, 22 insertions, 50 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 902f1b8..a33eb20 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..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 dda5aec..154358a 100644 --- a/js/codeq/translation.js +++ b/js/codeq/translation.js @@ -69,7 +69,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, lang) }); @@ -82,4 +82,4 @@ return dicts[name]; } }; -})();
\ No newline at end of file +})(); |