aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2015-10-12 01:30:28 +0200
committerMatěj Cepl <mcepl@cepl.eu>2015-10-12 01:30:28 +0200
commita9ff501181fb3d3b7050761aeb83fe03ecf5e60e (patch)
tree5720389c2b0abd7cc518d68f46feeebf514e1dfc
parent4a19b19a3cc2dfac0588ff44f4fd3ccde7940afb (diff)
downloadhesla-a9ff501181fb3d3b7050761aeb83fe03ecf5e60e.tar.gz
When the app is reopened, jump to today.
-rw-r--r--hesla.appcache2
-rw-r--r--hesla.es28
2 files changed, 23 insertions, 7 deletions
diff --git a/hesla.appcache b/hesla.appcache
index 48d167f..5433420 100644
--- a/hesla.appcache
+++ b/hesla.appcache
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# v72 - 2015-09-23
+# v74 - 2015-10-12
activePage.js
activePage.js.map
config.js
diff --git a/hesla.es b/hesla.es
index 69b65ef..ccd51b4 100644
--- a/hesla.es
+++ b/hesla.es
@@ -3,7 +3,7 @@ import {ActivePage} from "activePage";
if (!Date.prototype.toISODateString) {
(function() {
Date.prototype.toISODateString = function() {
- return this.toISOString().split('T')[0]
+ return this.toISOString().split('T')[0];
};
}());
@@ -13,16 +13,28 @@ export class Hesla extends ActivePage {
constructor() {
super();
document.getElementById("czech_nav").addEventListener("click",
- (evt: TouchEvent) => {
+ (evt) => {
localStorage.setItem("language", "cs");
this.lang_reload();
}, false);
document.getElementById("german_nav").addEventListener("click",
- (evt: TouchEvent) => {
+ (evt) => {
localStorage.setItem("language", "de");
this.lang_reload();
}, false);
+
+ // requires IE 10, Opera 12.10, Safari 7,
+ // FIXME Android browser requires 4.4 and has only
+ // webkitHidden and the event is webkitvisibilitychange
+ if (typeof document.hidden !== "undefined") {
+ document.addEventListener("visibilitychange",
+ (evt) => {
+ if (! document.hidden) {
+ this.today();
+ }
+ }, false);
+ }
}
/**
@@ -50,9 +62,7 @@ export class Hesla extends ActivePage {
this.prev();
}
else if (Math.abs(distY) > negligible) {
- console.log("jump to today!");
- this.cur_watchword = new Date();
- this.display();
+ this.today();
}
}
@@ -91,6 +101,12 @@ export class Hesla extends ActivePage {
classList.add("visible");
}
+ today() {
+ console.log("jump to today!");
+ this.cur_watchword = new Date();
+ this.display();
+ }
+
shiftDate(shift) {
var cur_date = this.cur_watchword;
cur_date.setDate(cur_date.getDate() + shift);