diff --git a/pwabuilder-sw.js b/pwabuilder-sw.js index 32dfb29c..8127654a 100644 --- a/pwabuilder-sw.js +++ b/pwabuilder-sw.js @@ -4,7 +4,7 @@ // App version number - ENSURE IT MATCHES VALUE IN init.js // DEV: Changing this will cause the browser to recognize that the Service Worker has changed, and it will download and // install a new copy -const appVersion = '1.1.4-RP11'; +const appVersion = '1.1.4'; // Kiwix ZIM Archive Download Server in regex form // DEV: The server URL is defined in init.js, but is not available to us in SW diff --git a/www/js/app.js b/www/js/app.js index d008bf2d..cf2e63bb 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -795,14 +795,18 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett document.getElementById('btnConfigure').addEventListener('click', function () { var searchDiv = document.getElementById('configuration'); - if (searchDiv.style.display != 'none') { + if (searchDiv.style.display !== 'none') { setTab(); if (params.themeChanged) { params.themeChanged = false; - if (history.state !== null) { - var thisURL = decodeURIComponent(history.state.title); - goToArticle(thisURL); + var archiveName = appstate.selectedArchive ? appstate.selectedArchive._file._files[0].name : null; + if (archiveName && ~params.lastPageVisit.indexOf(archiveName)) { + goToArticle(params.lastPageVisit.replace(/@kiwixKey@.+$/, '')); } + //if (history.state !== null) { + // var thisURL = decodeURIComponent(history.state.title); + // goToArticle(thisURL); + //} } return; } @@ -2312,7 +2316,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett } else { // The archive has changed, so we must blank the last page in case the Home page of the new archive // has the same title as the previous archive (possible if it is, for example, "index") - params.lastPageVisit = ""; + params.lastPageVisit = ''; + params.lastPageHTML = ''; document.getElementById('btnHome').click(); } } @@ -2793,11 +2798,12 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett appstate.selectedArchive.readUtf8File(dirEntry, displayArticleInForm); // This is needed so that the html is cached in displayArticleInForm params.lastPageVisit = ''; + params.lastPageHTML = ''; //} } }; if (params.rememberLastPage && params.lastPageVisit) lastPage = params.lastPageVisit.replace(/@kiwixKey@.+/, ""); - if (params.rememberLastPage && (typeof Storage !== "undefined") && dirEntry.namespace + '/' + dirEntry.url == lastPage) { + if (params.rememberLastPage && dirEntry.namespace + '/' + dirEntry.url === lastPage) { if (!params.lastPageHTML) { cache.getArticle(params.lastPageVisit.replace(/.*@kiwixKey@/, ''), lastPage, function (html) { params.lastPageHTML = html; @@ -3045,17 +3051,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett var baseUrl = dirEntry.namespace + '/' + dirEntry.url.replace(/[^/]+$/, ''); //Since page has been successfully loaded, store it in the browser history - if (!window.history.state || - !window.history.state.title || - !~window.history.state.title.indexOf("/" + dirEntry.url)) { - pushBrowserHistoryState(dirEntry.namespace + "/" + dirEntry.url); - } + pushBrowserHistoryState(dirEntry.namespace + '/' + dirEntry.url); // Store for fast retrieval - if (!~params.lastPageVisit.indexOf(dirEntry.url)) { - params.lastPageVisit = dirEntry.namespace + "/" + dirEntry.url + - "@kiwixKey@" + appstate.selectedArchive._file._files[0].name; - cache.setArticle(appstate.selectedArchive._file._files[0].name, dirEntry.namespace + '/' + dirEntry.url, htmlArticle, function(){}); - } + params.lastPageVisit = dirEntry.namespace + '/' + dirEntry.url + '@kiwixKey@' + appstate.selectedArchive._file._files[0].name; + cache.setArticle(appstate.selectedArchive._file._files[0].name, dirEntry.namespace + '/' + dirEntry.url, htmlArticle, function(){}); params.htmlArticle = htmlArticle; // Replaces ZIM-style URLs of img, script, link and media tags with a data-kiwixurl to prevent 404 errors [kiwix-js #272 #376] diff --git a/www/js/init.js b/www/js/init.js index bd387686..cb73eb52 100644 --- a/www/js/init.js +++ b/www/js/init.js @@ -49,7 +49,7 @@ var params = {}; */ var appstate = {}; /******** UPDATE VERSION IN pwabuilder-sw.js TO MATCH VERSION *******/ -params['version'] = "1.1.4-RP11"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js +params['version'] = "1.1.4"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js /******* UPDATE THIS ^^^^^^ IN serveice worker!! ********************/ params['packagedFile'] = "wikipedia_en_100_maxi.zim"; //For packaged Kiwix JS (e.g. with Wikivoyage file), set this to the filename (for split files, give the first chunk *.zimaa) and place file(s) in default storage params['archivePath'] = "archives"; //The directory containing the packaged archive(s) (relative to app's root directory)