diff --git a/src/sidebar.js b/src/sidebar.js index f6da62e..def1284 100644 --- a/src/sidebar.js +++ b/src/sidebar.js @@ -1,5 +1,3 @@ -document.body.style.border = "5px solid red"; - function onError(error) { console.error(`Error: ${error}`); $('#error-message').text(`Error: ${error}`); @@ -46,33 +44,6 @@ function extractBookId(url){ } } -// class MiniWebServer{ - -// constructor() { -// this.url = "http://127.0.0.1:8080/test.zip" -// } - -// downloadTestZip(){ -// console.info(`Downloading ${this.url}`) -// return fetch(this.url, { -// credentials: 'include' -// }).then((res) => { -// console.log(`Getting blob.`) -// return res.blob() -// }).then(JSZip.loadAsync) -// .then((zip) => { -// this.zip = zip -// }) - -// } - -// fetchUrl(url){ -// let name = "meta/"+url.replace(/[^a-z0-9]/gi, '_').toLowerCase() -// this.zip.file(name) -// . -// } -// } - class Book{ constructor(book_id, epub) { @@ -162,30 +133,6 @@ class Book{ return Promise.all(downloads) } - downloadMetaContent(){ - let downloads = [] - // downloads.push(this.downloadResource(this.book_info.cover)) - downloads.push( - this.downloadJson(this.book_info.toc) - .then((json)=>{ - this.book_toc=json - })) - downloads.push( - this.downloadJson(this.book_info.flat_toc) - .then((json)=>{ - this.book_flattoc=json - })) - downloads.push( - Promise.map(this.book_info.chapters, (chapter) => { - return this.downloadJson(chapter) - .then((json) => { - return this.extractChapterAssets(json) - }) - },{concurrency: 1})) - - return Promise.all(downloads) - } - extractChapterAssets(json){ if (!json.asset_base_url @@ -198,7 +145,8 @@ class Book{ url: json.content, file: json.full_path, context: null, - mime: null + mime: null, + content: null, }) // List of images. for (let idx in json.images){ @@ -272,7 +220,8 @@ function onDownloadBookClicked(){ .then(() => { renderInfo(book); }) .then(() => { return book.downloadChapterList(); }) .then(() => { return renderChapterList(book); }) - .then(() => { return book.downloadContent(); }) + .then(() => { return book.downloadMetaContent(); }) + // .then(() => { return book.downloadContent(); }) .then(() => { return createEpub(book, epub); }) .then(() => { return epub.generateAsync(); }) .then((file) => {