From 356503257173430bfa3953160de467106aba8738 Mon Sep 17 00:00:00 2001 From: Illia Maier Date: Thu, 8 Aug 2024 08:31:51 +0300 Subject: [PATCH 1/4] Ad image viewer. Update archive name on download --- index.html | 92 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 5ccbf84..ca07fed 100644 --- a/index.html +++ b/index.html @@ -77,7 +77,9 @@ integrity="sha384-HqC294x+jARmk/wUrzXlnRpiZrmiHJ4BIKph0mrcMJ/cLuMkNDHY0IjbDanCNhcU" crossorigin="anonymous"> - + + + @@ -377,11 +385,14 @@

- > + + + + + const initialHashValueParams = new URLSearchParams(initialHashValue.replace(/^.*?(\?|$)/, '')) // preview mode if (initialHashValueParams.get('preview')) { - document.getElementById('app').remove() - document.getElementById('preview').style.display = 'block' - const filePath = initialHashValue.replace(/\?.*$/, '') const fileUrl = urlFromFilePath(filePath) const previewFormat = initialHashValueParams.get('preview') - const previewElement = document.querySelector(`#preview > #preview-${previewFormat}`); - ;// remove all other preview elements - [...document.querySelectorAll('#preview > *')] - .filter(element => element.id !== previewElement?.id) - .forEach(element => element.remove()) - // set source of preview element - switch (previewFormat) { - case 'markdown': - previewElement.src = fileUrl - break - default: - alert(`Unsupported preview for ${previewFormat} files!`) - } + + switch (previewFormat) { + case 'markdown': + document.getElementById('preview').style.display = 'block' + document.querySelector(`#preview-markdown`).src = fileUrl + break + case 'images': + app.showImagePreview(fileUrl) + break + default: + alert(`Unsupported preview for ${previewFormat} files!`) + } function urlFromFilePath(filePath) { return `${(config.bucketMaskUrl || config.bucketUrl).replace(/\/*$/, '')}/${encodePath(filePath)}` @@ -803,6 +817,32 @@

this.refresh() } }, + showImagePreview(fileUrl) { + this.previewImages = this.pathContentTableData + .filter(item => ['jpg', 'jpeg', 'png'].includes(item.name.split('.').pop().toLowerCase())) + .map(item => ({ + url: decodeURIComponent(item.url), // Розкодовуємо URL + caption: item.name // Додаємо назву як підпис + })); + + console.log("Preview images:", this.previewImages); // Перевірка масиву зображень + + this.$nextTick(() => { + Fancybox.show(this.previewImages.map(image => ({ + src: image.url, + caption: image.caption + })), { + on: { + ready: (fancybox) => { + const index = fancybox.items.findIndex(item => item.src === decodeURIComponent(fileUrl)); + if (index !== -1) { + fancybox.jumpTo(index); + } + } + } + }); + }); + }, async downloadAllFiles() { const archiveFiles = this.pathContentTableData .filter(item => item.type === 'content') @@ -820,6 +860,16 @@

let totalContentLength = 0; let totalReceivedLength = 0; + let archiveName = 'archive'; + + try { + const firstUrl = archiveFiles[0]; + archiveName = decodeURIComponent(firstUrl.split('/').slice(-2, -1)[0]); + if (!archiveName) throw new Error('Folder name is empty'); + } catch (error) { + console.error('Error determining folder name, using default name:', error); + } + await Promise.all(archiveFiles.map(async (url) => { console.debug(`downloading ${url}...`); @@ -849,7 +899,7 @@

const objectUrl = window.URL.createObjectURL(archiveBlob); const link = document.createElement('a'); link.href = objectUrl; - link.download = `archive.zip`; + link.download = `${archiveName}.zip`; link.click(); window.URL.revokeObjectURL(objectUrl); From f704bea04b0d853cfd995d05c05e6948f711b5bb Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Thu, 8 Aug 2024 17:27:58 +0200 Subject: [PATCH 2/4] Update index.html --- index.html | 111 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/index.html b/index.html index 62a6296..d9b4450 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + @@ -78,8 +78,10 @@ crossorigin="anonymous"> - - + + @@ -386,17 +388,12 @@