Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| js:foliate-js:reader [2024/03/26 13:05] – créée avillepreux | js:foliate-js:reader [2024/03/26 13:52] (Version actuelle) – ancienne révision (2024/03/26 13:27) restaurée avillepreux | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | <JS> | + | <html>< |
| - | import ' | + | import 'https:// |
| - | import { createTOCView } from ' | + | import { createTOCView } from 'https:// |
| - | import { createMenu } from ' | + | import { createMenu } from 'https:// |
| - | import { Overlayer } from ' | + | import { Overlayer } from 'https:// |
| const isZip = async file => { | const isZip = async file => { | ||
| Ligne 20: | Ligne 20: | ||
| const makeZipLoader = async file => { | const makeZipLoader = async file => { | ||
| const { configure, ZipReader, BlobReader, TextWriter, BlobWriter } = | const { configure, ZipReader, BlobReader, TextWriter, BlobWriter } = | ||
| - | await import(' | + | await import(' |
| configure({ useWebWorkers: | configure({ useWebWorkers: | ||
| const reader = new ZipReader(new BlobReader(file)) | const reader = new ZipReader(new BlobReader(file)) | ||
| Ligne 70: | Ligne 70: | ||
| if (file.isDirectory) { | if (file.isDirectory) { | ||
| const loader = await makeDirectoryLoader(file) | const loader = await makeDirectoryLoader(file) | ||
| - | const { EPUB } = await import(' | + | const { EPUB } = await import(' |
| book = await new EPUB(loader).init() | book = await new EPUB(loader).init() | ||
| } | } | ||
| Ligne 77: | Ligne 77: | ||
| const loader = await makeZipLoader(file) | const loader = await makeZipLoader(file) | ||
| if (isCBZ(file)) { | if (isCBZ(file)) { | ||
| - | const { makeComicBook } = await import(' | + | const { makeComicBook } = await import(' |
| book = makeComicBook(loader, | book = makeComicBook(loader, | ||
| } else if (isFBZ(file)) { | } else if (isFBZ(file)) { | ||
| - | const { makeFB2 } = await import(' | + | const { makeFB2 } = await import(' |
| const { entries } = loader | const { entries } = loader | ||
| const entry = entries.find(entry => entry.filename.endsWith(' | const entry = entries.find(entry => entry.filename.endsWith(' | ||
| Ligne 86: | Ligne 86: | ||
| book = await makeFB2(blob) | book = await makeFB2(blob) | ||
| } else { | } else { | ||
| - | const { EPUB } = await import(' | + | const { EPUB } = await import(' |
| book = await new EPUB(loader).init() | book = await new EPUB(loader).init() | ||
| } | } | ||
| } | } | ||
| else if (await isPDF(file)) { | else if (await isPDF(file)) { | ||
| - | const { makePDF } = await import(' | + | const { makePDF } = await import(' |
| book = await makePDF(file) | book = await makePDF(file) | ||
| } | } | ||
| else { | else { | ||
| - | const { isMOBI, MOBI } = await import(' | + | const { isMOBI, MOBI } = await import(' |
| if (await isMOBI(file)) { | if (await isMOBI(file)) { | ||
| - | const fflate = await import(' | + | const fflate = await import(' |
| book = await new MOBI({ unzlib: fflate.unzlibSync }).open(file) | book = await new MOBI({ unzlib: fflate.unzlibSync }).open(file) | ||
| } else if (isFB2(file)) { | } else if (isFB2(file)) { | ||
| - | const { makeFB2 } = await import(' | + | const { makeFB2 } = await import(' |
| book = await makeFB2(file) | book = await makeFB2(file) | ||
| } | } | ||
| Ligne 106: | Ligne 106: | ||
| if (!book) throw new Error(' | if (!book) throw new Error(' | ||
| const view = document.createElement(' | const view = document.createElement(' | ||
| - | document.body.append(view) | + | document.querySelector("# |
| await view.open(book) | await view.open(book) | ||
| return view | return view | ||
| Ligne 299: | Ligne 299: | ||
| const open = async file => { | const open = async file => { | ||
| - | document.body.removeChild($('# | + | document.querySelector("# |
| const reader = new Reader() | const reader = new Reader() | ||
| globalThis.reader = reader | globalThis.reader = reader | ||
| Ligne 331: | Ligne 331: | ||
| else dropTarget.style.visibility = ' | else dropTarget.style.visibility = ' | ||
| - | </JS> | + | </script></ |