mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-10 12:53:54 -04:00
ES Lint issues
This commit is contained in:
parent
98e7409d95
commit
e96c4fc3d8
@ -5855,8 +5855,10 @@ params.preloadAllImages = function () {
|
|||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
params.preloadingAllImages = true;
|
params.preloadingAllImages = true;
|
||||||
if (params.imageDisplay) params.contentInjectionMode === 'jquery'
|
if (params.imageDisplay) {
|
||||||
|
params.contentInjectionMode === 'jquery'
|
||||||
? images.prepareImagesJQuery(articleWindow, true) : images.prepareImagesServiceWorker(articleWindow, true);
|
? images.prepareImagesJQuery(articleWindow, true) : images.prepareImagesServiceWorker(articleWindow, true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// All images should now be loaded, or else user did not request loading images
|
// All images should now be loaded, or else user did not request loading images
|
||||||
|
@ -40,6 +40,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
|
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global params, appstate, Windows, articleContainer */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import uiUtil from './uiUtil.js';
|
import uiUtil from './uiUtil.js';
|
||||||
@ -238,7 +241,7 @@ function queueImages(docImgs, action, margin, callback) {
|
|||||||
// have been returned before running callback code; NB if images have been scheduled for extraction, callback will be
|
// have been returned before running callback code; NB if images have been scheduled for extraction, callback will be
|
||||||
// called above instead of here, but we still need this in case there are no immediately visible images
|
// called above instead of here, but we still need this in case there are no immediately visible images
|
||||||
if (callback && !batchCount) setTimeout(callback);
|
if (callback && !batchCount) setTimeout(callback);
|
||||||
return { 'visible': visible, 'remaining': remaining };
|
return { visible: visible, remaining: remaining };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +260,7 @@ function prepareImagesServiceWorker (win, forPrinting) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
if (!forPrinting && !documentImages.length) return;
|
if (!forPrinting && !documentImages.length) return;
|
||||||
var imageHtml;
|
var imageHtml;
|
||||||
var indexRoot = window.location.pathname.replace(/[^\/]+$/, '') + encodeURI(appstate.selectedArchive._file.name) + '/';
|
var indexRoot = window.location.pathname.replace(/[^/]+$/, '') + encodeURI(appstate.selectedArchive._file.name) + '/';
|
||||||
for (var i = 0, l = documentImages.length; i < l; i++) {
|
for (var i = 0, l = documentImages.length; i < l; i++) {
|
||||||
// Process Wikimedia MathML, but not if we'll be using the jQuery routine later
|
// Process Wikimedia MathML, but not if we'll be using the jQuery routine later
|
||||||
if (!(params.manipulateImages || params.allowHTMLExtraction)) {
|
if (!(params.manipulateImages || params.allowHTMLExtraction)) {
|
||||||
@ -334,7 +337,7 @@ function prepareImagesJQuery (win, forPrinting) {
|
|||||||
container = win;
|
container = win;
|
||||||
var doc = container.document;
|
var doc = container.document;
|
||||||
var documentImages = doc.querySelectorAll('img[data-kiwixurl], video, audio');
|
var documentImages = doc.querySelectorAll('img[data-kiwixurl], video, audio');
|
||||||
var indexRoot = window.location.pathname.replace(/[^\/]+$/, '') + encodeURI(appstate.selectedArchive._file.name) + '/';
|
var indexRoot = window.location.pathname.replace(/[^/]+$/, '') + encodeURI(appstate.selectedArchive._file.name) + '/';
|
||||||
indexRoot = indexRoot.replace(/^\//, '');
|
indexRoot = indexRoot.replace(/^\//, '');
|
||||||
// Zimit ZIMs work better if all images are extracted
|
// Zimit ZIMs work better if all images are extracted
|
||||||
if (params.zimType === 'zimit') forPrinting = true;
|
if (params.zimType === 'zimit') forPrinting = true;
|
||||||
@ -406,9 +409,11 @@ function insertMediaBlobsJQuery(medium) {
|
|||||||
// If the "controls" property is missing, we need to add it to ensure jQuery-only users can operate the video. See kiwix-js #760.
|
// If the "controls" property is missing, we need to add it to ensure jQuery-only users can operate the video. See kiwix-js #760.
|
||||||
if (/audio|video/i.test(mediaElement.tagName) && !mediaElement.hasAttribute('controls')) mediaElement.setAttribute('controls', '');
|
if (/audio|video/i.test(mediaElement.tagName) && !mediaElement.hasAttribute('controls')) mediaElement.setAttribute('controls', '');
|
||||||
// Create custom subtitle / cc load menu if it doesn't already exist
|
// Create custom subtitle / cc load menu if it doesn't already exist
|
||||||
if (!container.document.getElementById('kiwixCCMenu')) buildCustomCCMenu(container.document, mediaElement, function (ccBlob) {
|
if (!container.document.getElementById('kiwixCCMenu')) {
|
||||||
|
buildCustomCCMenu(container.document, mediaElement, function (ccBlob) {
|
||||||
trackBlob = ccBlob;
|
trackBlob = ccBlob;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
// Load media file
|
// Load media file
|
||||||
appstate.selectedArchive.getDirEntryByPath(decodeURIComponent(source)).then(function (dirEntry) {
|
appstate.selectedArchive.getDirEntryByPath(decodeURIComponent(source)).then(function (dirEntry) {
|
||||||
return appstate.selectedArchive.readBinaryFile(dirEntry, function (fileDirEntry, mediaArray) {
|
return appstate.selectedArchive.readBinaryFile(dirEntry, function (fileDirEntry, mediaArray) {
|
||||||
@ -430,16 +435,16 @@ function insertMediaBlobsJQuery(medium) {
|
|||||||
' <span id="alertMessage"></span>\n' +
|
' <span id="alertMessage"></span>\n' +
|
||||||
'</div>\n';
|
'</div>\n';
|
||||||
var alertMessage = document.getElementById('alertMessage');
|
var alertMessage = document.getElementById('alertMessage');
|
||||||
var filename = iframe.title + '_' + dirEntry.url.replace(/^.*\/([^\/]+)$/, '$1');
|
var filename = iframe.title + '_' + dirEntry.url.replace(/^.*\/([^/]+)$/, '$1');
|
||||||
// Make filename safe
|
// Make filename safe
|
||||||
filename = filename.replace(/[\/\\:*?"<>|]/g, '_');
|
filename = filename.replace(/[/\\:*?"<>|]/g, '_');
|
||||||
alertMessage.innerHTML = '<a href="#" class="alert-link" id="downloadMedia">Download this file</a> (and any selected subtitles) to play with another app';
|
alertMessage.innerHTML = '<a href="#" class="alert-link" id="downloadMedia">Download this file</a> (and any selected subtitles) to play with another app';
|
||||||
document.getElementById('downloadMedia').addEventListener('click', function () {
|
document.getElementById('downloadMedia').addEventListener('click', function () {
|
||||||
var downloadFiles = [];
|
var downloadFiles = [];
|
||||||
downloadFiles.push({
|
downloadFiles.push({
|
||||||
'blob': blob,
|
blob: blob,
|
||||||
'filename': filename,
|
filename: filename,
|
||||||
'src': mediaSource.src
|
src: mediaSource.src
|
||||||
});
|
});
|
||||||
// Add any selected subtitle file to the download package
|
// Add any selected subtitle file to the download package
|
||||||
var selTextTrack = iframe.getElementById('kiwixSelCC');
|
var selTextTrack = iframe.getElementById('kiwixSelCC');
|
||||||
@ -447,9 +452,9 @@ function insertMediaBlobsJQuery(medium) {
|
|||||||
var selTextExt = selTextTrack.dataset.kiwixurl.replace(/^.*\.([^.]+)$/, '$1');
|
var selTextExt = selTextTrack.dataset.kiwixurl.replace(/^.*\.([^.]+)$/, '$1');
|
||||||
// Subtitle files should have same name as video + .es.vtt (for example)
|
// Subtitle files should have same name as video + .es.vtt (for example)
|
||||||
downloadFiles.push({
|
downloadFiles.push({
|
||||||
'blob': trackBlob,
|
blob: trackBlob,
|
||||||
'filename': filename.replace(/^(.*)\.[^.]+$/, '$1.' + selTextTrack.srclang + '.' + selTextExt),
|
filename: filename.replace(/^(.*)\.[^.]+$/, '$1.' + selTextTrack.srclang + '.' + selTextExt),
|
||||||
'src': selTextTrack.src
|
src: selTextTrack.src
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (var j = downloadFiles.length; j--;) {
|
for (var j = downloadFiles.length; j--;) {
|
||||||
@ -601,35 +606,35 @@ function loadMathJax(win) {
|
|||||||
}
|
}
|
||||||
if (params.containsMathTexRaw || params.containsMathTex || params.containsMathSVG) {
|
if (params.containsMathTexRaw || params.containsMathTex || params.containsMathSVG) {
|
||||||
var script1, script2, script3;
|
var script1, script2, script3;
|
||||||
var link = doc.createElement("link");
|
var link = doc.createElement('link');
|
||||||
link.rel = "stylesheet";
|
link.rel = 'stylesheet';
|
||||||
link.href = prefix + "js/katex/katex.min.css";
|
link.href = prefix + 'js/katex/katex.min.css';
|
||||||
doc.head.appendChild(link);
|
doc.head.appendChild(link);
|
||||||
script1 = doc.createElement("script");
|
script1 = doc.createElement('script');
|
||||||
script1.type = "text/javascript";
|
script1.type = 'text/javascript';
|
||||||
// script.src = "js/MathJax/MathJax.js?config=TeX-AMS_HTML-full";
|
// script.src = "js/MathJax/MathJax.js?config=TeX-AMS_HTML-full";
|
||||||
script1.src = prefix + "js/katex/katex.min.js";
|
script1.src = prefix + 'js/katex/katex.min.js';
|
||||||
if (params.containsMathTex) {
|
if (params.containsMathTex) {
|
||||||
script2 = doc.createElement("script");
|
script2 = doc.createElement('script');
|
||||||
script2.type = "text/javascript";
|
script2.type = 'text/javascript';
|
||||||
script2.src = prefix + "js/katex/contrib/mathtex-script-type.min.js";
|
script2.src = prefix + 'js/katex/contrib/mathtex-script-type.min.js';
|
||||||
}
|
}
|
||||||
if (params.containsMathTex || params.containsMathTexRaw) {
|
if (params.containsMathTex || params.containsMathTexRaw) {
|
||||||
script3 = doc.createElement("script");
|
script3 = doc.createElement('script');
|
||||||
script3.type = "text/javascript";
|
script3.type = 'text/javascript';
|
||||||
script3.src = prefix + "js/katex/contrib/auto-render.min.js";
|
script3.src = prefix + 'js/katex/contrib/auto-render.min.js';
|
||||||
script3.onload = function () {
|
script3.onload = function () {
|
||||||
container.renderMathInElement(doc.body, {
|
container.renderMathInElement(doc.body, {
|
||||||
delimiters: [
|
delimiters: [
|
||||||
{left: "$$", right: "$$", display: true},
|
{ left: '$$', right: '$$', display: true },
|
||||||
{left: "$", right: "$", display: false},
|
{ left: '$', right: '$', display: false },
|
||||||
{left: "\\(", right: "\\)", display: false},
|
{ left: '\\(', right: '\\)', display: false },
|
||||||
// {left: "\\begin{equation}", right: "\\end{equation}", display: true},
|
// {left: "\\begin{equation}", right: "\\end{equation}", display: true},
|
||||||
// {left: "\\begin{align}", right: "\\end{align}", display: true},
|
// {left: "\\begin{align}", right: "\\end{align}", display: true},
|
||||||
// {left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
// {left: "\\begin{alignat}", right: "\\end{alignat}", display: true},
|
||||||
// {left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
// {left: "\\begin{gather}", right: "\\end{gather}", display: true},
|
||||||
// {left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
// {left: "\\begin{CD}", right: "\\end{CD}", display: true},
|
||||||
{left: "\\[", right: "\\]", display: true}
|
{ left: '\\[', right: '\\]', display: true }
|
||||||
],
|
],
|
||||||
globalGroup: true,
|
globalGroup: true,
|
||||||
throwOnError: false
|
throwOnError: false
|
||||||
|
@ -53,7 +53,7 @@ function feedNodeWithBlob (node, nodeAttribute, content, mimeType, makeDataURI,
|
|||||||
content = util.dataURItoUint8Array(content);
|
content = util.dataURItoUint8Array(content);
|
||||||
}
|
}
|
||||||
// DEV: Note that webpMachine is single threaded and will reject an image if it is busy
|
// DEV: Note that webpMachine is single threaded and will reject an image if it is busy
|
||||||
// However, the loadImagesJQuery() function in app.js is sequential (it waits for a callback
|
// However, the prepareImagesJQuery() function in images.js is sequential (it waits for a callback
|
||||||
// before processing another image) so we do not need to queue WebP images here
|
// before processing another image) so we do not need to queue WebP images here
|
||||||
webpMachine.decode(content).then(function (uri) {
|
webpMachine.decode(content).then(function (uri) {
|
||||||
// DEV: WebpMachine.decode() returns a data: URI
|
// DEV: WebpMachine.decode() returns a data: URI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user