diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-10-12 01:30:28 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-10-12 01:30:28 +0200 |
commit | a9ff501181fb3d3b7050761aeb83fe03ecf5e60e (patch) | |
tree | 5720389c2b0abd7cc518d68f46feeebf514e1dfc | |
parent | 4a19b19a3cc2dfac0588ff44f4fd3ccde7940afb (diff) | |
download | hesla-a9ff501181fb3d3b7050761aeb83fe03ecf5e60e.tar.gz |
When the app is reopened, jump to today.
-rw-r--r-- | hesla.appcache | 2 | ||||
-rw-r--r-- | hesla.es | 28 |
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 @@ -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); |