mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-27 15:03:00 -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);
|
settingsStore.setItem("lastSelectedArchive", archiveDirectory, Infinity);
|
||||||
// The archive is set : go back to home page to start searching
|
// The archive is set : go back to home page to start searching
|
||||||
$("#btnHome").click();
|
$("#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
|
// The archive is set : go back to home page to start searching
|
||||||
$("#btnHome").click();
|
$("#btnHome").click();
|
||||||
document.getElementById('downloadInstruction').style.display = 'none';
|
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) {
|
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]
|
// Attempts to access any properties of 'this' with malformed URLs causes app crash in Edge/UWP [kiwix-js #430]
|
||||||
try {
|
try {
|
||||||
var testHref = anchor.href;
|
var href = anchor.href;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Malformed href caused error:' + err.message);
|
console.error('Malformed href caused error:' + err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var href = anchor.getAttribute('href');
|
href = anchor.getAttribute('href');
|
||||||
if (href === null || href === undefined || /^javascript:/i.test(anchor.protocol)) return;
|
if (href === null || href === undefined || /^javascript:/i.test(anchor.protocol)) return;
|
||||||
var anchorTarget = href.match(regexpLocalAnchorHref);
|
var anchorTarget = href.match(regexpLocalAnchorHref);
|
||||||
if (href.length === 0) {
|
if (href.length === 0) {
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* 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/>
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
define(['zimfile', 'zimDirEntry', 'util', 'utf8', 'uiUtil'],
|
define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
|
||||||
function(zimfile, zimDirEntry, util, utf8, uiUtil) {
|
function(zimfile, zimDirEntry, util, utf8) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ZIM Archive
|
* 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 {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 {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} 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;
|
var that = this;
|
||||||
that._file = null;
|
that._file = null;
|
||||||
that._language = ""; //@TODO
|
that._language = ""; //@TODO
|
||||||
@ -93,14 +94,14 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8', 'uiUtil'],
|
|||||||
// split archive
|
// split archive
|
||||||
that._searchArchiveParts(storage, path.slice(0, -2)).then(function (fileArray) {
|
that._searchArchiveParts(storage, path.slice(0, -2)).then(function (fileArray) {
|
||||||
createZimfile(fileArray);
|
createZimfile(fileArray);
|
||||||
}, function(error) {
|
}).catch(function (error) {
|
||||||
uiUtil.systemAlert("Error reading files in split archive " + path + ": " + error, "Error reading archive files");
|
callbackError("Error reading files in split archive " + path + ": " + error, "Error reading archive files");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
storage.get(path).then(function (file) {
|
storage.get(path).then(function (file) {
|
||||||
createZimfile([file]);
|
createZimfile([file]);
|
||||||
}, function(error) {
|
}).catch(function (error) {
|
||||||
uiUtil.systemAlert("Error reading ZIM file " + path + " : " + error, "Error reading archive file");
|
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
|
* Create a ZIMArchive from DeviceStorage location
|
||||||
* @param {DeviceStorage} storage
|
* @param {DeviceStorage} storage
|
||||||
* @param {String} path
|
* @param {String} path
|
||||||
* @param {callbackZIMArchive} callback
|
* @param {callbackZIMArchive} callbackReady
|
||||||
|
* @param {callbackZIMArchive} callbackError
|
||||||
* @returns {ZIMArchive}
|
* @returns {ZIMArchive}
|
||||||
*/
|
*/
|
||||||
function loadArchiveFromDeviceStorage(storage, path, callback) {
|
function loadArchiveFromDeviceStorage(storage, path, callbackReady, callbackError) {
|
||||||
return new zimArchive.ZIMArchive(storage, path, callback);
|
return new zimArchive.ZIMArchive(storage, path, callbackReady, callbackError);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Create a ZIMArchive from Files
|
* Create a ZIMArchive from Files
|
||||||
* @param {Array.<File>} files
|
* @param {Array.<File>} files
|
||||||
* @param {callbackZIMArchive} callback
|
* @param {callbackZIMArchive} callbackReady
|
||||||
|
* @param {callbackZIMArchive} callbackError
|
||||||
* @returns {ZIMArchive}
|
* @returns {ZIMArchive}
|
||||||
*/
|
*/
|
||||||
function loadArchiveFromFiles(files, callback) {
|
function loadArchiveFromFiles(files, callbackReady, callbackError) {
|
||||||
if (files.length >= 1) {
|
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