cbz fixes

This commit is contained in:
AppleTheGolden 2025-10-11 17:50:01 +02:00
parent 076bf52c13
commit e9c855e1f8
No known key found for this signature in database
GPG key ID: F6AC8A62154C42AA
2 changed files with 15 additions and 17 deletions

View file

@ -171,7 +171,7 @@ window.baguetteBox = (function () {
}; };
var imageItem = { var imageItem = {
eventHandler: imageElementClickHandler, eventHandler: imageElementClickHandler,
imageElement: imageElement imageElement: imageElement,
}; };
bind(imageElement, 'click', imageElementClickHandler); bind(imageElement, 'click', imageElementClickHandler);
gallery.push(imageItem); gallery.push(imageItem);
@ -210,6 +210,9 @@ window.baguetteBox = (function () {
} }
function fillCbzGallery(gallery, cbzElement, eventHandler) { function fillCbzGallery(gallery, cbzElement, eventHandler) {
if (gallery.length !== 0) {
return Promise.resolve();
}
var href = cbzElement.href var href = cbzElement.href
var zlsHref = href + (href.indexOf("?") === -1 ? "?" : "&") + "zls"; var zlsHref = href + (href.indexOf("?") === -1 ? "?" : "&") + "zls";
console.log("pre-fetch") console.log("pre-fetch")
@ -221,7 +224,7 @@ window.baguetteBox = (function () {
&& cbz_pics.indexOf(name.split(".").pop()) !== -1 && cbz_pics.indexOf(name.split(".").pop()) !== -1
).sort(); ).sort();
imagesList.forEach((imageName) => { imagesList.forEach((imageName, index) => {
var imageHref = href var imageHref = href
+ (href.indexOf("?") === -1 ? "?" : "&") + (href.indexOf("?") === -1 ? "?" : "&")
+ "zget=" + "zget="
@ -718,7 +721,7 @@ window.baguetteBox = (function () {
}, 50); }, 50);
if (options.onChange && !url_ts) if (options.onChange && !url_ts)
options.onChange(currentIndex, imagesElements.length); options.onChange.call(currentGallery, currentIndex, imagesElements.length);
url_ts = null; url_ts = null;
documentLastFocus = document.activeElement; documentLastFocus = document.activeElement;
@ -850,7 +853,7 @@ window.baguetteBox = (function () {
is_vid = re_v.test(imageSrc), is_vid = re_v.test(imageSrc),
thumbnailElement = imageElement.querySelector('img, video'), thumbnailElement = imageElement.querySelector('img, video'),
imageCaption = typeof options.captions === 'function' ? imageCaption = typeof options.captions === 'function' ?
options.captions.call(currentGallery, imageElement) : options.captions.call(currentGallery, imageElement, index) :
imageElement.getAttribute('data-caption') || imageElement.title; imageElement.getAttribute('data-caption') || imageElement.title;
imageSrc = addq(imageSrc, 'cache'); imageSrc = addq(imageSrc, 'cache');
@ -990,7 +993,7 @@ window.baguetteBox = (function () {
unfig(index); unfig(index);
if (options.onChange) if (options.onChange)
options.onChange(currentIndex, imagesElements.length); options.onChange.call(currentGallery, currentIndex, imagesElements.length);
return true; return true;
} }

View file

@ -17552,25 +17552,20 @@ var thegrid = (function () {
afterShow: function () { afterShow: function () {
r.bbox_opts.refocus = true; r.bbox_opts.refocus = true;
}, },
captions: function (g) { captions: function (g, idx) {
var idx = -1, var h = '' + g;
h = '' + g;
for (var a = 0; a < r.bbox.length; a++)
if (r.bbox[a].imageElement == g)
idx = a;
return '<a download href="' + h + return '<a download href="' + h +
'">' + (idx + 1) + ' / ' + r.bbox.length + ' -- ' + '">' + (idx + 1) + ' / ' + this.length + ' -- ' +
esc(uricom_dec(h.split('/').pop())) + '</a>'; esc(uricom_dec(h.split('/').pop())) + '</a>';
}, },
onChange: function (i) { onChange: function (i, maxIdx) {
if (r.bbox[i]) { if (this[i].imageElement) {
sethash('g' + r.bbox[i].imageElement.getAttribute('ref') + getsort()); sethash('g' + this[i].imageElement.getAttribute('ref') + getsort());
} }
} }
}); });
r.bbox = br[0][0]; r.bbox = true;
r.bbox_opts = br[1]; r.bbox_opts = br[1];
}; };