1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00

core zip functionality

This commit is contained in:
Fred Chasen 2012-10-27 11:44:49 -07:00
parent d6b1482e40
commit 855308972a
18 changed files with 7146 additions and 44 deletions

51
js/app/app.js Normal file
View file

@ -0,0 +1,51 @@
FP.namespace('app').init = (function($){
function init(){
var fileInput = document.getElementById("file-input");
var bookFiles = [],
bookImages = [],
bookCSS = [];
//-- Tell zip where it is located
zip.workerScriptsPath = "/js/libs/";
//-- Listen for the Input Change
fileInput.addEventListener('change', function(){
//-- Grab first file
var file = fileInput.files[0];
//-- Get all Entries in Zip file
FP.core.loadZip.getEntries(file, function(entries) {
//-- Split Entries into xhtml, images, css
entries.forEach(function(entry) {
if(entry.filename.search(".xhtml") != -1){
bookFiles.push(entry);
}
if(entry.filename.search(".jpg") != -1 || entry.filename.search(".png") != -1){
bookImages.push(entry);
}
if(entry.filename.search(".css") != -1){
bookCSS.push(entry);
}
});
bookFiles.forEach(function(file) {
//Blob or File
FP.core.loadZip.getEntryFile(file, "Blob", function(blobURL, revokeBlobURL) {
console.log(file.filename, blobURL)
});
});
//console.log(bookFiles, bookImages, bookCSS)
});
});
}
return init;
})(jQuery);