mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-24 04:54:51 -04:00
Closes #494
This commit is contained in:
parent
aead42a7dc
commit
feadb4546b
@ -888,12 +888,19 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the article corresponding to the given dirEntry
|
* Read the article corresponding to the given dirEntry
|
||||||
* @param {DirEntry} dirEntry
|
* @param {DirEntry} dirEntry The directory entry of the article to read
|
||||||
*/
|
*/
|
||||||
function readArticle(dirEntry) {
|
function readArticle(dirEntry) {
|
||||||
if (contentInjectionMode === 'serviceworker') {
|
if (contentInjectionMode === 'serviceworker') {
|
||||||
// In ServiceWorker mode, we simply set the iframe src.
|
// In ServiceWorker mode, we simply set the iframe src.
|
||||||
// (reading the backend is handled by the ServiceWorker itself)
|
// (reading the backend is handled by the ServiceWorker itself)
|
||||||
|
|
||||||
|
// We will need the encoded URL on article load so that we can set the iframe's src correctly,
|
||||||
|
// but we must not encode the '/' character or else relative links may fail [kiwix-js #498]
|
||||||
|
var encodedUrl = dirEntry.url.replace(/[^/]+/g, function(matchedSubstring) {
|
||||||
|
return encodeURIComponent(matchedSubstring);
|
||||||
|
});
|
||||||
|
|
||||||
var iframeArticleContent = document.getElementById('articleContent');
|
var iframeArticleContent = document.getElementById('articleContent');
|
||||||
iframeArticleContent.onload = function() {
|
iframeArticleContent.onload = function() {
|
||||||
// The iframe is empty, show spinner on load of landing page
|
// The iframe is empty, show spinner on load of landing page
|
||||||
@ -918,7 +925,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
// We put the ZIM filename as a prefix in the URL, so that browser caches are separate for each ZIM file
|
// We put the ZIM filename as a prefix in the URL, so that browser caches are separate for each ZIM file
|
||||||
iframeArticleContent.src = selectedArchive._file._files[0].name + "/" + dirEntry.namespace + "/" + encodeURIComponent(dirEntry.url);
|
iframeArticleContent.src = "../" + selectedArchive._file._files[0].name + "/" + dirEntry.namespace + "/" + encodedUrl;
|
||||||
// Display the iframe content
|
// Display the iframe content
|
||||||
$("#articleContent").show();
|
$("#articleContent").show();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user