mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-09 04:06:27 -04:00
Support Edge and Firefox
Former-commit-id: 4c595746128f92e6eae25d06c2c9e2a0bd91ffe5 [formerly 1c3159d1bb7c9d31db8c23c0608b3b5bcc1702a3] Former-commit-id: 1f09b9a25fa4e4fba6d3c05fa9e2b8cd8a683340
This commit is contained in:
parent
dd86f1c27b
commit
92026daebc
@ -539,7 +539,7 @@
|
||||
<div class="panel-body">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="rememberLastPage" id="rememberLastPageCheck">
|
||||
<b>Remember last-visited page</b> and re-open on next app launch
|
||||
<b>Reopen last-visited page</b> on next app launch
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -189,20 +189,24 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
params.cssSource = e.target.checked ? "desktop" : "mobile";
|
||||
params.printIntercept = true;
|
||||
params.printInterception = false;
|
||||
document.getElementById('confirm-print-continue').disabled = true;
|
||||
goToArticle(decodeURIComponent(history.state.title));
|
||||
var btnContinue = document.getElementById('confirm-print-continue');
|
||||
var btnCancel = document.getElementById('confirm-print-cancel');
|
||||
btnCancel.disabled = true;
|
||||
btnContinue.disabled = true;
|
||||
btnContinue.innerHTML = "Please wait";
|
||||
goToArticle(decodeURIComponent(params.lastPageVisit.replace(/@kiwixKey@.+/, "")));
|
||||
});
|
||||
function printCleanup() {
|
||||
params.printIntercept = false;
|
||||
params.printInterception = false;
|
||||
goToArticle(decodeURIComponent(history.state.title));
|
||||
goToArticle(decodeURIComponent(params.lastPageVisit.replace(/@kiwixKey@.+/, "")));
|
||||
setTimeout(function () { //Restore temporarily changed value after page has reloaded
|
||||
params.rememberLastPage = cookies.getItem('rememberLastPage') == "false" ? false : true;
|
||||
if (!params.rememberLastPage) {
|
||||
params.lastPageVisit = "";
|
||||
cookies.setItem('lastPageVisit', "", Infinity);
|
||||
if (typeof (Storage) !== "undefined") {
|
||||
localStorage.setItem('lastPageHTML', "");
|
||||
try { htmlContent = localStorage.setItem('lastPageHTML', ""); }
|
||||
catch (err) { console.log("localStorage not supported: " + err); }
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
@ -213,7 +217,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
params.printInterception = params.printIntercept;
|
||||
params.printIntercept = false;
|
||||
document.getElementById('btnAbout').classList.add('active');
|
||||
document.getElementById('confirm-print-continue').disabled = false;
|
||||
var btnContinue = document.getElementById('confirm-print-continue');
|
||||
var btnCancel = document.getElementById('confirm-print-cancel');
|
||||
btnCancel.disabled = false;
|
||||
btnContinue.disabled = false;
|
||||
btnContinue.innerHTML = "Continue";
|
||||
var printModalContent = document.getElementById('print-modal-content');
|
||||
printModalContent.classList.remove('dark');
|
||||
if (params.cssUITheme != "light") {
|
||||
@ -228,12 +236,14 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
params.rememberLastPage = true; //Re-enable caching to speed up reloading of page
|
||||
params.printIntercept = true;
|
||||
params.printInterception = false;
|
||||
document.getElementById('confirm-print-continue').disabled = true;
|
||||
btnCancel.disabled = true;
|
||||
btnContinue.disabled = true;
|
||||
btnContinue.innerHTML = "Please wait";
|
||||
$("#printModal").modal({
|
||||
backdrop: "static",
|
||||
keyboard: true,
|
||||
});
|
||||
goToArticle(decodeURIComponent(history.state.title));
|
||||
goToArticle(decodeURIComponent(params.lastPageVisit.replace(/@kiwixKey@.+/, "")));
|
||||
return;
|
||||
}
|
||||
//Pre-load all images in case user wants to print them
|
||||
@ -788,7 +798,8 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
cookies.setItem('lastPageVisit', "", Infinity);
|
||||
//Clear localStorage
|
||||
if (typeof (Storage) !== "undefined") {
|
||||
localStorage.setItem('lastPageHTML', "");
|
||||
try { htmlContent = localStorage.setItem('lastPageHTML', ""); }
|
||||
catch (err) { console.log("localStorage not supported: " + err); }
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1731,11 +1742,12 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
if (!htmlContent) {
|
||||
if (params.rememberLastPage && typeof (Storage) !== "undefined" &&
|
||||
dirEntry.namespace + '/' + dirEntry.url == decodeURIComponent(params.lastPageVisit.replace(/@kiwixKey@.+/, ""))) {
|
||||
htmlContent = localStorage.getItem('lastPageHTML');
|
||||
try { htmlContent = localStorage.getItem('lastPageHTML'); }
|
||||
catch(err) { console.log("localStorage not supported: " + err); }
|
||||
}
|
||||
if (/<html[^>]*>/.test(htmlContent)) {
|
||||
console.log("Fast article retrieval from localStorage...");
|
||||
setTimeout(function () { displayArticleInForm(dirEntry, htmlContent); }, 1);
|
||||
setTimeout(function () { displayArticleInForm(dirEntry, htmlContent); }, 100);
|
||||
} else {
|
||||
selectedArchive.readArticle(dirEntry, displayArticleInForm);
|
||||
}
|
||||
@ -1839,13 +1851,16 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
|
||||
!~window.history.state.title.indexOf("/" + dirEntry.url)) {
|
||||
pushBrowserHistoryState(dirEntry.namespace + "/" + dirEntry.url);
|
||||
}
|
||||
if (params.rememberLastPage && !~decodeURIComponent(params.lastPageVisit).indexOf(dirEntry.url)) {
|
||||
if (!~decodeURIComponent(params.lastPageVisit).indexOf(dirEntry.url)) {
|
||||
params.lastPageVisit = encodeURIComponent(dirEntry.namespace + "/" + dirEntry.url) +
|
||||
"@kiwixKey@" + selectedArchive._file._files[0].name;
|
||||
cookies.setItem('lastPageVisit', params.lastPageVisit, Infinity);
|
||||
//Store current document's raw HTML in localStorage for fast restart
|
||||
if (typeof (Storage) !== "undefined") {
|
||||
localStorage.setItem('lastPageHTML', htmlArticle);
|
||||
if (params.rememberLastPage) {
|
||||
cookies.setItem('lastPageVisit', params.lastPageVisit, Infinity);
|
||||
//Store current document's raw HTML in localStorage for fast restart
|
||||
if (typeof (Storage) !== "undefined") {
|
||||
try { htmlContent = localStorage.setItem('lastPageHTML', htmlArticle); }
|
||||
catch (err) { console.log("localStorage not supported: " + err); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user