Compare commits
2 Commits
f92060603d
...
b7fdcacf77
Author | SHA1 | Date | |
---|---|---|---|
b7fdcacf77 | |||
9cdf6bbd32 |
@ -4,6 +4,24 @@ let heroImages = [];
|
|||||||
let allTags = []; // global tag list
|
let allTags = []; // global tag list
|
||||||
let showOnlyUntagged = false;
|
let showOnlyUntagged = false;
|
||||||
|
|
||||||
|
// --- Fade-in helper ---
|
||||||
|
function applyFadeInImages(container) {
|
||||||
|
const fadeImages = container.querySelectorAll("img.fade-in-img");
|
||||||
|
fadeImages.forEach(img => {
|
||||||
|
const onLoad = () => {
|
||||||
|
img.classList.add("loaded");
|
||||||
|
};
|
||||||
|
if (img.complete && img.naturalHeight !== 0) {
|
||||||
|
onLoad();
|
||||||
|
} else {
|
||||||
|
img.addEventListener("load", onLoad, { once: true });
|
||||||
|
img.addEventListener("error", () => {
|
||||||
|
console.warn("Image failed to load:", img.dataset?.src || img.src);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// --- Load images from server on page load ---
|
// --- Load images from server on page load ---
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
try {
|
try {
|
||||||
@ -94,20 +112,7 @@ function renderGallery() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fade-in effect for loaded images
|
// Fade-in effect for loaded images
|
||||||
const fadeImages = document.querySelectorAll("img.fade-in-img");
|
applyFadeInImages(container);
|
||||||
fadeImages.forEach(img => {
|
|
||||||
const onLoad = () => {
|
|
||||||
img.classList.add("loaded");
|
|
||||||
};
|
|
||||||
if (img.complete && img.naturalHeight !== 0) {
|
|
||||||
onLoad();
|
|
||||||
} else {
|
|
||||||
img.addEventListener("load", onLoad, { once: true });
|
|
||||||
img.addEventListener("error", () => {
|
|
||||||
console.warn("Image failed to load:", img.dataset.src || img.src);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Render tags for a single image ---
|
// --- Render tags for a single image ---
|
||||||
@ -246,11 +251,9 @@ function renderTags(imgIndex, tags) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
input.addEventListener('blur', () => {
|
input.addEventListener('blur', () => {
|
||||||
setTimeout(() => {
|
suggestionBox.style.display = 'none';
|
||||||
suggestionBox.style.display = 'none';
|
input.value = '';
|
||||||
input.value = '';
|
validateBtn.style.display = 'none';
|
||||||
validateBtn.style.display = 'none';
|
|
||||||
}, 150);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- Validate button action ---
|
// --- Validate button action ---
|
||||||
@ -262,9 +265,10 @@ function renderTags(imgIndex, tags) {
|
|||||||
validateBtn.style.display = 'none';
|
validateBtn.style.display = 'none';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
input.focus();
|
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
|
if (!input.value.trim()) {
|
||||||
|
suggestionBox.style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Update tags in galleryImages array ---
|
// --- Update tags in galleryImages array ---
|
||||||
@ -322,6 +326,9 @@ function renderHero() {
|
|||||||
if (removeAllBtnBottom) {
|
if (removeAllBtnBottom) {
|
||||||
removeAllBtnBottom.style.display = heroImages.length > 0 ? 'inline-block' : 'none';
|
removeAllBtnBottom.style.display = heroImages.length > 0 ? 'inline-block' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fade-in effect for loaded images
|
||||||
|
applyFadeInImages(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Save gallery to server ---
|
// --- Save gallery to server ---
|
||||||
|
Reference in New Issue
Block a user