From e7decd4349443c33c726a45668e4224919ff2034 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Mon, 17 Aug 2015 03:01:51 -0400 Subject: [PATCH] Initial commit to branch upgrade-js Start incrementally adding to sites javascript. Starting with, handling application cache events, then considering additional features like using local storage to allow offline reading of posts, as well as an interface to view and manage them. Signed-off-by: Collin J. Doering --- js/default.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/default.js b/js/default.js index 38386fc..52fc03e 100644 --- a/js/default.js +++ b/js/default.js @@ -218,6 +218,11 @@ _paq.push(['enableLinkTracking']); }); } + function appCacheUpdateReady () { + window.applicationCache.swapCache(); + // TODO: find what resource is loaded currently and reload it if it has changed + } + function init(router) { router.setCallback(loadPageContent); @@ -225,6 +230,11 @@ _paq.push(['enableLinkTracking']); router.runRouter(location.pathname); }); + window.addEventListener("updateready", appCacheUpdateReady); + if (window.applicationCache.status === window.applicationCache.UPDATEREADY) { + appCacheUpdateReady(); + } + $(document).ready(function () { $('#nav-menu a.menuitem').click(function () { $(this).closest('ul').find('li.active').removeClass('active');