Skip to content

Commit

Permalink
Clean up some more spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Nov 13, 2023
1 parent 5b61268 commit d0d037a
Showing 1 changed file with 33 additions and 44 deletions.
77 changes: 33 additions & 44 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,8 @@ function launchBrowserExtensionServiceWorker () {
(translateUI.t('dialog-allow-internetaccess-message3') || 'It supports more types of ZIM archives and is much more robust.</p><p>We') + ' ');
message += (translateUI.t('dialog-allow-internetaccess-message4') ||
'need one-time access to our secure server so that the app can re-launch as a Progressive Web App (PWA). ' +
'If available, the PWA will work offline, but will auto-update periodically when online as per the ' +
'Service Worker spec.</p><p>You can switch back any time by returning to JQuery mode.</p>' +
'If available, the PWA will work offline, but will auto-update periodically when online as per the ' +
'Service Worker spec.</p><p>You can switch back any time by returning to JQuery mode.</p>' +
'<p>WARNING: This will attempt to access the following server:<br/>') + params.PWAServer + '</p>';
var launchPWA = function () {
uiUtil.spinnerDisplay(false);
Expand Down Expand Up @@ -1395,7 +1395,7 @@ function displayFileSelect () {
if (e.key === 'Enter' || e.key === ' ' || e.keyCode === 32) {
e.preventDefault();
folderSelect.click();
}
}
});
}

Expand Down Expand Up @@ -1509,18 +1509,7 @@ function setLocalArchiveFromFileList (files) {
}
}
resetCssCache();
selectedArchive = null;
selectedArchive = zimArchiveLoader.loadArchiveFromFiles(files, function () {
document.getElementById('downloadInstruction').style.display = 'none';
// var tmpMessageChannel = new MessageChannel();
// tmpMessageChannel.port1.onmessage = function () {
// // The archive is set : go back to home page to start searching
// $("#btnHome").click();
// }
// selectedArchive.callLibzimWorker({ action: "init", files: selectedArchive._file._files }).then(function (worker) {
// $("#btnHome").click();
// });
}, function (message, label) {
zimArchiveLoader.loadArchiveFromFiles(files, archiveReadyCallback, function (message, label) {
// callbackError which is called in case of an error
uiUtil.systemAlert(message, label);
});
Expand Down Expand Up @@ -1673,7 +1662,7 @@ function populateListOfArticles (dirEntryArray, reportingSearch) {
// Info: encodeURIComponent encodes all characters except A-Z a-z 0-9 - _ . ! ~ * ' ( )
var dirEntryStringId = encodeURIComponent(dirEntry.toStringId());
articleListDivHtml += '<a href="#" dirEntryId="' + dirEntryStringId +
'" class="list-group-item">' + dirEntry.getTitleOrUrl() + '</a>';
'" class="list-group-item">' + dirEntry.getTitleOrUrl() + '</a>';
}

// innerHTML required for this line
Expand All @@ -1682,11 +1671,11 @@ function populateListOfArticles (dirEntryArray, reportingSearch) {
// and prevents this event from firing; note that touch also triggers mousedown
document.querySelectorAll('#articleList a').forEach(function (link) {
link.addEventListener('mousedown', function (e) {
// Cancel search immediately
appstate.search.status = 'cancelled';
handleTitleClick(e);
return false;
});
// Cancel search immediately
appstate.search.status = 'cancelled';
handleTitleClick(e);
return false;
});
});
if (!stillSearching) document.getElementById('searchingArticles').style.display = 'none';
document.getElementById('articleListWithHeader').style.display = '';
Expand Down Expand Up @@ -1735,7 +1724,7 @@ function isDirEntryExpectedToBeDisplayed (dirEntry) {

if (expectedArticleURLToBeDisplayed !== curArticleURL) {
console.debug('url of current article :' + curArticleURL + ', does not match the expected url :' +
expectedArticleURLToBeDisplayed);
expectedArticleURLToBeDisplayed);
return false;
}
return true;
Expand Down Expand Up @@ -2256,30 +2245,30 @@ function displayArticleContentInIframe (dirEntry, htmlArticle) {
function insertMediaBlobsJQuery () {
var iframe = iframeArticleContent.contentDocument;
Array.prototype.slice.call(iframe.querySelectorAll('video, audio, source, track'))
.forEach(function (mediaSource) {
var source = mediaSource.getAttribute('src');
source = source ? uiUtil.deriveZimUrlFromRelativeUrl(source, baseUrl) : null;
// We have to exempt text tracks from using deriveZimUrlFromRelativeurl due to a bug in Firefox [kiwix-js #496]
source = source || decodeURIComponent(mediaSource.dataset.kiwixurl);
if (!source || !regexpZIMUrlWithNamespace.test(source)) {
if (source) console.error('No usable media source was found for: ' + source);
return;
}
var mediaElement = /audio|video/i.test(mediaSource.tagName) ? mediaSource : mediaSource.parentElement;
// 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', '');
selectedArchive.getDirEntryByPath(source).then(function (dirEntry) {
return selectedArchive.readBinaryFile(dirEntry, function (fileDirEntry, mediaArray) {
var mimeType = mediaSource.type ? mediaSource.type : dirEntry.getMimetype();
var blob = new Blob([mediaArray], { type: mimeType });
mediaSource.src = URL.createObjectURL(blob);
// In Firefox and Chromium it is necessary to re-register the inserted media source
// but do not reload for text tracks (closed captions / subtitles)
if (/track/i.test(mediaSource.tagName)) return;
mediaElement.load();
});
.forEach(function (mediaSource) {
var source = mediaSource.getAttribute('src');
source = source ? uiUtil.deriveZimUrlFromRelativeUrl(source, baseUrl) : null;
// We have to exempt text tracks from using deriveZimUrlFromRelativeurl due to a bug in Firefox [kiwix-js #496]
source = source || decodeURIComponent(mediaSource.dataset.kiwixurl);
if (!source || !regexpZIMUrlWithNamespace.test(source)) {
if (source) console.error('No usable media source was found for: ' + source);
return;
}
var mediaElement = /audio|video/i.test(mediaSource.tagName) ? mediaSource : mediaSource.parentElement;
// 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', '');
selectedArchive.getDirEntryByPath(source).then(function (dirEntry) {
return selectedArchive.readBinaryFile(dirEntry, function (fileDirEntry, mediaArray) {
var mimeType = mediaSource.type ? mediaSource.type : dirEntry.getMimetype();
var blob = new Blob([mediaArray], { type: mimeType });
mediaSource.src = URL.createObjectURL(blob);
// In Firefox and Chromium it is necessary to re-register the inserted media source
// but do not reload for text tracks (closed captions / subtitles)
if (/track/i.test(mediaSource.tagName)) return;
mediaElement.load();
});
});
});
}
}

Expand Down

0 comments on commit d0d037a

Please sign in to comment.