mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-25 05:52:59 -04:00
Removed zimArchive's dependency on uiUtil
This commit is contained in:
parent
ded7bf6b42
commit
b5d6db09ed
@ -1111,6 +1111,9 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
|
||||
settingsStore.setItem("lastSelectedArchive", archiveDirectory, Infinity);
|
||||
// The archive is set : go back to home page to start searching
|
||||
$("#btnHome").click();
|
||||
}, function (message, label) {
|
||||
// callbackError which is called in case of an error
|
||||
uiUtil.systemAlert(message, label);
|
||||
});
|
||||
|
||||
}
|
||||
@ -1199,6 +1202,9 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
|
||||
// The archive is set : go back to home page to start searching
|
||||
$("#btnHome").click();
|
||||
document.getElementById('downloadInstruction').style.display = 'none';
|
||||
}, function (message, label) {
|
||||
// callbackError which is called in case of an error
|
||||
uiUtil.systemAlert(message, label);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1673,12 +1679,12 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
|
||||
Array.prototype.slice.call(iframe.querySelectorAll('a, area')).forEach(function (anchor) {
|
||||
// Attempts to access any properties of 'this' with malformed URLs causes app crash in Edge/UWP [kiwix-js #430]
|
||||
try {
|
||||
var testHref = anchor.href;
|
||||
var href = anchor.href;
|
||||
} catch (err) {
|
||||
console.error('Malformed href caused error:' + err.message);
|
||||
return;
|
||||
}
|
||||
var href = anchor.getAttribute('href');
|
||||
href = anchor.getAttribute('href');
|
||||
if (href === null || href === undefined || /^javascript:/i.test(anchor.protocol)) return;
|
||||
var anchorTarget = href.match(regexpLocalAnchorHref);
|
||||
if (href.length === 0) {
|
||||
|
@ -20,8 +20,8 @@
|
||||
* along with Kiwix (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
'use strict';
|
||||
define(['zimfile', 'zimDirEntry', 'util', 'utf8', 'uiUtil'],
|
||||
function(zimfile, zimDirEntry, util, utf8, uiUtil) {
|
||||
define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
|
||||
function(zimfile, zimDirEntry, util, utf8) {
|
||||
|
||||
/**
|
||||
* ZIM Archive
|
||||
@ -49,8 +49,9 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8', 'uiUtil'],
|
||||
* @param {StorageFirefoxOS|Array<Blob>} storage Storage (in this case, the path must be given) or Array of Files (path parameter must be omitted)
|
||||
* @param {String} path The Storage path for an OS that requires this to be specified
|
||||
* @param {callbackZIMArchive} callbackReady The function to call when the archive is ready to use
|
||||
* @param {callbackZIMArchive} callbackError The function to call when an error occurs
|
||||
*/
|
||||
function ZIMArchive(storage, path, callbackReady) {
|
||||
function ZIMArchive(storage, path, callbackReady, callbackError) {
|
||||
var that = this;
|
||||
that._file = null;
|
||||
that._language = ""; //@TODO
|
||||
@ -91,16 +92,16 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8', 'uiUtil'],
|
||||
} else {
|
||||
if (/.*zim..$/.test(path)) {
|
||||
// split archive
|
||||
that._searchArchiveParts(storage, path.slice(0, -2)).then(function(fileArray) {
|
||||
that._searchArchiveParts(storage, path.slice(0, -2)).then(function (fileArray) {
|
||||
createZimfile(fileArray);
|
||||
}, function(error) {
|
||||
uiUtil.systemAlert("Error reading files in split archive " + path + ": " + error, "Error reading archive files");
|
||||
}).catch(function (error) {
|
||||
callbackError("Error reading files in split archive " + path + ": " + error, "Error reading archive files");
|
||||
});
|
||||
} else {
|
||||
storage.get(path).then(function(file) {
|
||||
storage.get(path).then(function (file) {
|
||||
createZimfile([file]);
|
||||
}, function(error) {
|
||||
uiUtil.systemAlert("Error reading ZIM file " + path + " : " + error, "Error reading archive file");
|
||||
}).catch(function (error) {
|
||||
callbackError("Error reading ZIM file " + path + " : " + error, "Error reading archive file");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -27,21 +27,23 @@ define(['zimArchive', 'jquery', 'uiUtil'],
|
||||
* Create a ZIMArchive from DeviceStorage location
|
||||
* @param {DeviceStorage} storage
|
||||
* @param {String} path
|
||||
* @param {callbackZIMArchive} callback
|
||||
* @param {callbackZIMArchive} callbackReady
|
||||
* @param {callbackZIMArchive} callbackError
|
||||
* @returns {ZIMArchive}
|
||||
*/
|
||||
function loadArchiveFromDeviceStorage(storage, path, callback) {
|
||||
return new zimArchive.ZIMArchive(storage, path, callback);
|
||||
function loadArchiveFromDeviceStorage(storage, path, callbackReady, callbackError) {
|
||||
return new zimArchive.ZIMArchive(storage, path, callbackReady, callbackError);
|
||||
};
|
||||
/**
|
||||
* Create a ZIMArchive from Files
|
||||
* @param {Array.<File>} files
|
||||
* @param {callbackZIMArchive} callback
|
||||
* @param {callbackZIMArchive} callbackReady
|
||||
* @param {callbackZIMArchive} callbackError
|
||||
* @returns {ZIMArchive}
|
||||
*/
|
||||
function loadArchiveFromFiles(files, callback) {
|
||||
function loadArchiveFromFiles(files, callbackReady, callbackError) {
|
||||
if (files.length >= 1) {
|
||||
return new zimArchive.ZIMArchive(files, null, callback);
|
||||
return new zimArchive.ZIMArchive(files, null, callbackReady, callbackError);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user