Remove usage of jszip
This commit is contained in:
		
							parent
							
								
									59e8a34882
								
							
						
					
					
						commit
						9864439b70
					
				|  | @ -187,23 +187,23 @@ const updateProgress = (lufiFile) => { | ||||||
|   document.getElementById("pbt").innerHTML = `${percent}%`; |   document.getElementById("pbt").innerHTML = `${percent}%`; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const showZipContent = (blob) => { | const showZipContent = (zipFile) => { | ||||||
|   const showZipContentDOM = document.getElementById("showZipContent"); |   const showZipContentDOM = document.getElementById("showZipContent"); | ||||||
| 
 | 
 | ||||||
|   const showZipContentDOMListener = () => { |   const showZipContentDOMListener = () => { | ||||||
|     JSZip.loadAsync(blob).then((zip) => { |     lufi.decompress(zipFile).andThen((files) => { | ||||||
|       const newElement = document.createElement("div"); |       const newElement = document.createElement("div"); | ||||||
| 
 | 
 | ||||||
|       let innerHTML = `<h3>${i18n.zipContent}</h3><ul>`; |       let innerHTML = `<h3>${i18n.zipContent}</h3><ul>`; | ||||||
| 
 | 
 | ||||||
|       zip.forEach(function (_relativePath, zipEntry) { |       files.forEach((file) => { | ||||||
|         innerHTML += `<li>
 |         innerHTML += `<li>
 | ||||||
|                                   ${escapeHtml(zipEntry.name)} |                                   ${escapeHtml(file.name)} | ||||||
|                                   (${filesize(zipEntry._data.uncompressedSize, { |                                   (${filesize(file.size, { | ||||||
|                                     base: 10, |                                     base: 10, | ||||||
|                                   })}) |                                   })}) | ||||||
|                                   <a href="#" |                                   <a href="#" | ||||||
|                                      download="${escapeHtml(zipEntry.name)}" |                                      download="${escapeHtml(file.name)}" | ||||||
|                                      class="download-zip-content" |                                      class="download-zip-content" | ||||||
|                                      title="${i18n.download}"> |                                      title="${i18n.download}"> | ||||||
|                                        <i class="mdi-file-file-download"></i> |                                        <i class="mdi-file-file-download"></i> | ||||||
|  | @ -217,17 +217,16 @@ const showZipContent = (blob) => { | ||||||
| 
 | 
 | ||||||
|       pbd.append(newElement); |       pbd.append(newElement); | ||||||
| 
 | 
 | ||||||
|       console.debug(); |  | ||||||
| 
 |  | ||||||
|       document.querySelectorAll(".download-zip-content").forEach((element) => { |       document.querySelectorAll(".download-zip-content").forEach((element) => { | ||||||
|         const elementListener = (e) => { |         const elementListener = (e) => { | ||||||
|           e.preventDefault(); |           e.preventDefault(); | ||||||
|           var filename = element.getAttribute("download"); | 
 | ||||||
|           zip.files[filename].async("blob").then((blob) => { |           const filename = element.getAttribute("download"); | ||||||
|             element.removeEventListener("click", elementListener); |           const file = files.find((file) => file.name === filename); | ||||||
|             element.setAttribute("href", URL.createObjectURL(blob)); | 
 | ||||||
|             element.click(); |           element.removeEventListener("click", elementListener); | ||||||
|           }); |           element.setAttribute("href", URL.createObjectURL(file)); | ||||||
|  |           element.click(); | ||||||
|         }; |         }; | ||||||
|         element.addEventListener("click", elementListener); |         element.addEventListener("click", elementListener); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -161,7 +161,6 @@ | ||||||
| %= javascript '/partial/index.js' | %= javascript '/partial/index.js' | ||||||
| % } | % } | ||||||
| %= javascript '/js/filesize.min.js' | %= javascript '/js/filesize.min.js' | ||||||
| %= javascript '/js/jszip.min.js' |  | ||||||
| %= javascript '/js/lufi-notifications.js' | %= javascript '/js/lufi-notifications.js' | ||||||
| %= javascript '/js/lufi-up.js', type => 'module' | %= javascript '/js/lufi-up.js', type => 'module' | ||||||
| % } | % } | ||||||
|  |  | ||||||
|  | @ -43,7 +43,6 @@ | ||||||
|         </div> |         </div> | ||||||
| %= javascript '/partial/render.js?nbslices='.stash('f')->nbslices.'&file='.stash('f')->short | %= javascript '/partial/render.js?nbslices='.stash('f')->nbslices.'&file='.stash('f')->short | ||||||
| %= javascript '/js/filesize.min.js' | %= javascript '/js/filesize.min.js' | ||||||
| %= javascript '/js/jszip.min.js' |  | ||||||
| %= javascript '/js/lufi-notifications.js' | %= javascript '/js/lufi-notifications.js' | ||||||
| %= javascript '/js/lufi-down.js', type => 'module' | %= javascript '/js/lufi-down.js', type => 'module' | ||||||
|     % } |     % } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Booteille
						Booteille