From e9c855e1f851f48146d98b646fc76bbd584333a4 Mon Sep 17 00:00:00 2001 From: AppleTheGolden Date: Sat, 11 Oct 2025 17:50:01 +0200 Subject: [PATCH] cbz fixes --- copyparty/web/baguettebox.js | 13 ++++++++----- copyparty/web/browser.js | 19 +++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js index 712e487e..97c7e38d 100644 --- a/copyparty/web/baguettebox.js +++ b/copyparty/web/baguettebox.js @@ -171,7 +171,7 @@ window.baguetteBox = (function () { }; var imageItem = { eventHandler: imageElementClickHandler, - imageElement: imageElement + imageElement: imageElement, }; bind(imageElement, 'click', imageElementClickHandler); gallery.push(imageItem); @@ -210,6 +210,9 @@ window.baguetteBox = (function () { } function fillCbzGallery(gallery, cbzElement, eventHandler) { + if (gallery.length !== 0) { + return Promise.resolve(); + } var href = cbzElement.href var zlsHref = href + (href.indexOf("?") === -1 ? "?" : "&") + "zls"; console.log("pre-fetch") @@ -221,7 +224,7 @@ window.baguetteBox = (function () { && cbz_pics.indexOf(name.split(".").pop()) !== -1 ).sort(); - imagesList.forEach((imageName) => { + imagesList.forEach((imageName, index) => { var imageHref = href + (href.indexOf("?") === -1 ? "?" : "&") + "zget=" @@ -718,7 +721,7 @@ window.baguetteBox = (function () { }, 50); if (options.onChange && !url_ts) - options.onChange(currentIndex, imagesElements.length); + options.onChange.call(currentGallery, currentIndex, imagesElements.length); url_ts = null; documentLastFocus = document.activeElement; @@ -850,7 +853,7 @@ window.baguetteBox = (function () { is_vid = re_v.test(imageSrc), thumbnailElement = imageElement.querySelector('img, video'), imageCaption = typeof options.captions === 'function' ? - options.captions.call(currentGallery, imageElement) : + options.captions.call(currentGallery, imageElement, index) : imageElement.getAttribute('data-caption') || imageElement.title; imageSrc = addq(imageSrc, 'cache'); @@ -990,7 +993,7 @@ window.baguetteBox = (function () { unfig(index); if (options.onChange) - options.onChange(currentIndex, imagesElements.length); + options.onChange.call(currentGallery, currentIndex, imagesElements.length); return true; } diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 319dc889..e663016d 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -17552,25 +17552,20 @@ var thegrid = (function () { afterShow: function () { r.bbox_opts.refocus = true; }, - captions: function (g) { - var idx = -1, - h = '' + g; - - for (var a = 0; a < r.bbox.length; a++) - if (r.bbox[a].imageElement == g) - idx = a; + captions: function (g, idx) { + var h = '' + g; return '' + (idx + 1) + ' / ' + r.bbox.length + ' -- ' + + '">' + (idx + 1) + ' / ' + this.length + ' -- ' + esc(uricom_dec(h.split('/').pop())) + ''; }, - onChange: function (i) { - if (r.bbox[i]) { - sethash('g' + r.bbox[i].imageElement.getAttribute('ref') + getsort()); + onChange: function (i, maxIdx) { + if (this[i].imageElement) { + sethash('g' + this[i].imageElement.getAttribute('ref') + getsort()); } } }); - r.bbox = br[0][0]; + r.bbox = true; r.bbox_opts = br[1]; };