aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hesla.js16
1 files changed, 9 insertions, 7 deletions
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);