From 3d0c8ac713ec35e943f001308bc7b9590a06eeef Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 19 Nov 2012 10:42:12 +0100 Subject: JSLintization. --- hesla.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'hesla.js') diff --git a/hesla.js b/hesla.js index 5e6d3b4..af1802f 100644 --- a/hesla.js +++ b/hesla.js @@ -1,3 +1,5 @@ +"use strict"; + if (!Date.prototype.toISODateString) { (function() { @@ -20,17 +22,18 @@ if (!Date.prototype.toISODateString) { (function () { function Page() { + var that = this; this.cur_date = null; document.getElementById("czech_nav").addEventListener("click", function(evt) { localStorage.language = "cs"; - lang_reload(); + that.lang_reload(); }, false); document.getElementById("german_nav").addEventListener("click", function(evt) { localStorage.language = "de"; - lang_reload(); + that.lang_reload(); }, false); } @@ -38,7 +41,7 @@ if (!Date.prototype.toISODateString) { // Display cur_date losungen Page.prototype.display = function display(new_date) { if (this.cur_date !== null) { - document.getElementById(cur_date.toISODateString()).style.display = 'none'; + document.getElementById(this.cur_date.toISODateString()).style.display = 'none'; } if (new_date === undefined) { @@ -64,14 +67,13 @@ if (!Date.prototype.toISODateString) { // Switch langauge Page.prototype.lang_reload = function lang_reload() { - var new_basename = "index.html"; - var new_url = "NOURL"; + var new_basename = "index.html", new_url = "NOURL", + old_basename = window.location.pathname.split("/").slice(-1); + if (localStorage.language && (localStorage.language === "de")) { new_basename = "index_de.html"; } - var old_basename = window.location.pathname.split("/").slice(-1); - if ((old_basename !== new_basename) || (window.location.pathname.length === 0)) { new_url = window.location.href.replace(/(index[a-zA-Z-_]*\.html)?$/, new_basename); -- cgit