mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-09 04:06:27 -04:00
Fix reload of last page html
Former-commit-id: 08f25c9f21621c20e92e36d4f9d0a4120300cddc [formerly 6db3c8ad04ff210071aad5e22c924cab24646264] [formerly 046876c288d699685baf2dc36672bbda0bd6da7e] [formerly 8befa3c744d962100bb3220af8ac7e21e9e67e17 [formerly 56a21d6774aaf8cf000c2e224926ca80a99594e7 [formerly 03046505bb93171c92d5d9d59d939236ade62117]]] Former-commit-id: a822d902c606a818fd2e6998d9a057635e25ab2d [formerly 19a03a021246ea388e741a8ac1495fe228d3dccc [formerly b390ed882e4706a20f1b2ee817337d9d76e470a6]] Former-commit-id: 04b6f27238e7bde64de2970ab708f3d96ed44bfb [formerly b5959f4e0ac03a22b001c73baf44c298a8f54017] Former-commit-id: 9315ae0252a9f710bd62909262d8c6e0f2098ee5
This commit is contained in:
parent
cc3eb53f0f
commit
0127772107
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user