|
|
|
@ -99,7 +99,8 @@ kthoom.setSettings = function() {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var createURLFromArray = function(array, mimeType) {
|
|
|
|
|
var offset = array.byteOffset, len = array.byteLength;
|
|
|
|
|
var offset = array.byteOffset;
|
|
|
|
|
var len = array.byteLength;
|
|
|
|
|
var url;
|
|
|
|
|
var blob;
|
|
|
|
|
|
|
|
|
@ -137,11 +138,13 @@ var createURLFromArray = function(array, mimeType) {
|
|
|
|
|
kthoom.ImageFile = function(file) {
|
|
|
|
|
this.filename = file.filename;
|
|
|
|
|
var fileExtension = file.filename.split(".").pop().toLowerCase();
|
|
|
|
|
var mimeType = fileExtension === "png" ? "image/png" :
|
|
|
|
|
this.mimeType = fileExtension === "png" ? "image/png" :
|
|
|
|
|
(fileExtension === "jpg" || fileExtension === "jpeg") ? "image/jpeg" :
|
|
|
|
|
fileExtension === "gif" ? "image/gif" : fileExtension == 'svg' ? 'image/xml+svg' : undefined;
|
|
|
|
|
this.dataURI = createURLFromArray(file.fileData, mimeType);
|
|
|
|
|
if ( this.mimeType !== undefined) {
|
|
|
|
|
this.dataURI = createURLFromArray(file.fileData, this.mimeType);
|
|
|
|
|
this.data = file;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -169,7 +172,9 @@ function loadFromArrayBuffer(ab) {
|
|
|
|
|
unarchiver.addEventListener(bitjs.archive.UnarchiveEvent.Type.PROGRESS,
|
|
|
|
|
function(e) {
|
|
|
|
|
var percentage = e.currentBytesUnarchived / e.totalUncompressedBytesInArchive;
|
|
|
|
|
if (totalImages === 0) {
|
|
|
|
|
totalImages = e.totalFilesInArchive;
|
|
|
|
|
}
|
|
|
|
|
updateProgress(percentage *100);
|
|
|
|
|
lastCompletion = percentage * 100;
|
|
|
|
|
});
|
|
|
|
@ -180,8 +185,10 @@ function loadFromArrayBuffer(ab) {
|
|
|
|
|
var f = e.unarchivedFile;
|
|
|
|
|
// add any new pages based on the filename
|
|
|
|
|
if (imageFilenames.indexOf(f.filename) === -1) {
|
|
|
|
|
var test = new kthoom.ImageFile(f);
|
|
|
|
|
if ( test.mimeType !== undefined) {
|
|
|
|
|
imageFilenames.push(f.filename);
|
|
|
|
|
imageFiles.push(new kthoom.ImageFile(f));
|
|
|
|
|
imageFiles.push(test);
|
|
|
|
|
// add thumbnails to the TOC list
|
|
|
|
|
$("#thumbnails").append(
|
|
|
|
|
"<li>" +
|
|
|
|
@ -191,12 +198,16 @@ function loadFromArrayBuffer(ab) {
|
|
|
|
|
"</a>" +
|
|
|
|
|
"</li>"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// display first page if we haven't yet
|
|
|
|
|
if (imageFiles.length === currentImage + 1) {
|
|
|
|
|
updatePage(lastCompletion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
totalImages--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
unarchiver.addEventListener(bitjs.archive.UnarchiveEvent.Type.FINISH,
|
|
|
|
|
function() {
|
|
|
|
|