Fixes some leakage in the language selector

Signed-off-by: Christopher Rogers <chrissrogers@gmail.com>
This commit is contained in:
Christopher Rogers 2014-04-09 14:14:24 -07:00
parent 53db9d4a64
commit 68807cd485

View file

@ -13,7 +13,12 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations License for the specific language governing permissions and limitations
under the License. under the License.
*/ */
languages = [] (function (global) {
var languages = [];
global.setupLanguages = setupLanguages;
global.activateLanguage = activateLanguage;
function activateLanguage(language) { function activateLanguage(language) {
$("#lang-selector a").removeClass('active'); $("#lang-selector a").removeClass('active');
$("#lang-selector a[data-language-name='" + language + "']").addClass('active'); $("#lang-selector a[data-language-name='" + language + "']").addClass('active');
@ -21,13 +26,13 @@ function activateLanguage(language) {
$(".highlight." + languages[i]).hide(); $(".highlight." + languages[i]).hide();
} }
$(".highlight." + language).show(); $(".highlight." + language).show();
} }
function setupLanguages(l) { function setupLanguages(l) {
var currentLanguage = l[0];
var defaultLanguage = localStorage.getItem("language");
languages = l; languages = l;
currentLanguage = languages[0];
defaultLanguage = localStorage.getItem("language");
if ((location.search.substr(1) != "") && (jQuery.inArray(location.search.substr(1), languages)) != -1) { if ((location.search.substr(1) != "") && (jQuery.inArray(location.search.substr(1), languages)) != -1) {
// the language is in the URL, so use that language! // the language is in the URL, so use that language!
@ -50,3 +55,4 @@ function setupLanguages(l) {
}); });
} }
})(window);