diff --git a/WebContent/gui/OSRM.MainGUI.js b/WebContent/gui/OSRM.MainGUI.js index e2bcb2b18..015a9087d 100644 --- a/WebContent/gui/OSRM.MainGUI.js +++ b/WebContent/gui/OSRM.MainGUI.js @@ -42,7 +42,7 @@ init: function() { document.getElementById('gui-input-target').value = OSRM.DEFAULTS.ONLOAD_TARGET; // init units selector - OSRM.GUI.initSelector( "gui-units-toggle", [{display:"Kilometers",value:0},{display:"Miles",value:1}], 0, OSRM.GUI.onUnitsChanged ); + OSRM.GUI.selectorInit( "gui-units-toggle", [{display:"Kilometers",value:0},{display:"Miles",value:1}], 0, OSRM.GUI.onUnitsChanged ); }, // set language dependent labels diff --git a/WebContent/gui/OSRM.Selector.js b/WebContent/gui/OSRM.Selector.js index 6d545d8c7..cd593c5ea 100644 --- a/WebContent/gui/OSRM.Selector.js +++ b/WebContent/gui/OSRM.Selector.js @@ -22,7 +22,7 @@ or see http://www.gnu.org/licenses/agpl.txt. OSRM.GUI.extend( { // initialize selector with all options and our look&feel -initSelector: function(id, options, selected, onchange_fct) { +selectorInit: function(id, options, selected, onchange_fct) { // create dropdown menu var select = document.getElementById(id); select.className = "styled-select-helper base-font"; @@ -56,6 +56,12 @@ selectorOnChange: function(select) { document.getElementById("styled-select-" + select.id).childNodes[0].nodeValue = option[i].childNodes[0].nodeValue; break; } +}, + +// change selector value +selectorChange: function(select, value) { + select.value = value; + OSRM.GUI.selectorOnChange(select); } }); \ No newline at end of file diff --git a/WebContent/localization/OSRM.Localization.js b/WebContent/localization/OSRM.Localization.js index f674ac274..58b878b0f 100644 --- a/WebContent/localization/OSRM.Localization.js +++ b/WebContent/localization/OSRM.Localization.js @@ -42,14 +42,17 @@ init: function() { } // generate selectors - OSRM.GUI.initSelector("gui-language-toggle", options, selected, OSRM.Localization.setLanguage); - OSRM.GUI.initSelector("gui-language-toggle-2", options_2, selected, OSRM.Localization.setLanguage); + OSRM.GUI.selectorInit("gui-language-toggle", options, selected, OSRM.Localization.setLanguage); + OSRM.GUI.selectorInit("gui-language-toggle-2", options_2, selected, OSRM.Localization.setLanguage); // set default language - OSRM.Localization.setLanguage( OSRM.DEFAULTS.LANGUAGE ); + OSRM.Localization.setLanguage( OSRM.DEFAULTS.LANGUAGE ); }, setLanguage: function(language) { - // TODO: also change language of other selector + // change value of both language selectors + OSRM.GUI.selectorChange( document.getElementById('gui-language-toggle'), language ); + OSRM.GUI.selectorChange( document.getElementById('gui-language-toggle-2'), language ); + if( OSRM.Localization[language]) { OSRM.Localization.current_language = language; // change gui language