mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-23 04:28:30 -04:00
parent
7f9ddc5a07
commit
1cd958752c
@ -900,36 +900,31 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
|||||||
var encodedUrl = dirEntry.url.replace(/[^/]+/g, function(matchedSubstring) {
|
var encodedUrl = dirEntry.url.replace(/[^/]+/g, function(matchedSubstring) {
|
||||||
return encodeURIComponent(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 content is fully loaded by the browser : we can hide the spinner
|
||||||
$("#searchingArticles").show();
|
$("#searchingArticles").hide();
|
||||||
$("#articleList").empty();
|
|
||||||
$('#articleListHeaderMessage').empty();
|
|
||||||
$('#articleListWithHeader').hide();
|
|
||||||
$("#prefix").val("");
|
|
||||||
iframeArticleContent.onload = function() {
|
|
||||||
// The content is fully loaded by the browser : we can hide the spinner
|
|
||||||
$("#searchingArticles").hide();
|
|
||||||
// Deflect drag-and-drop of ZIM file on the iframe to Config
|
|
||||||
var doc = iframeArticleContent.contentDocument ? iframeArticleContent.contentDocument.documentElement : null;
|
|
||||||
var docBody = doc ? doc.getElementsByTagName('body') : null;
|
|
||||||
docBody = docBody ? docBody[0] : null;
|
|
||||||
if (docBody) {
|
|
||||||
docBody.addEventListener('dragover', handleIframeDragover);
|
|
||||||
docBody.addEventListener('drop', handleIframeDrop);
|
|
||||||
}
|
|
||||||
if (iframeArticleContent.contentWindow) iframeArticleContent.contentWindow.onunload = function() {
|
|
||||||
$("#searchingArticles").show();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
// 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 + "/" + encodedUrl;
|
|
||||||
// Display the iframe content
|
// Display the iframe content
|
||||||
$("#articleContent").show();
|
$("#articleContent").show();
|
||||||
|
// Deflect drag-and-drop of ZIM file on the iframe to Config
|
||||||
|
var doc = iframeArticleContent.contentDocument ? iframeArticleContent.contentDocument.documentElement : null;
|
||||||
|
var docBody = doc ? doc.getElementsByTagName('body') : null;
|
||||||
|
docBody = docBody ? docBody[0] : null;
|
||||||
|
if (docBody) {
|
||||||
|
docBody.addEventListener('dragover', handleIframeDragover);
|
||||||
|
docBody.addEventListener('drop', handleIframeDrop);
|
||||||
|
}
|
||||||
|
// Reset UI when the article is unloaded
|
||||||
|
if (iframeArticleContent.contentWindow) iframeArticleContent.contentWindow.onunload = function() {
|
||||||
|
$("#articleList").empty();
|
||||||
|
$('#articleListHeaderMessage').empty();
|
||||||
|
$('#articleListWithHeader').hide();
|
||||||
|
$("#prefix").val("");
|
||||||
|
$("#searchingArticles").show();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
iframeArticleContent.src = "article.html";
|
// 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 + "/" + encodedUrl;
|
||||||
} else {
|
} else {
|
||||||
// In jQuery mode, we read the article content in the backend and manually insert it in the iframe
|
// In jQuery mode, we read the article content in the backend and manually insert it in the iframe
|
||||||
if (dirEntry.isRedirect()) {
|
if (dirEntry.isRedirect()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user