ChapterSlides.js: Difference between revisions
From Illustrations in German Translations of Mark Twain's Works
Created page with "// Acht feste Illustratoren definieren const illustrators = [ "Kemble", "Schroedter", "Hirth", "Busoni", "Kellerer", "Harder", "Trier", "Bebié" ]; // Bildlisten und aktuelle Indizes let slides = {}; let currentIndex = {}; illustrators.forEach(name => { slides[name] = []; currentIndex[name] = 0; }); // Eingabe verarbeiten function loadSlideshowsByChapter() { const chapterInput = document.getElementById("chapterInput").value.trim(); const chapte..." |
No edit summary |
||
| Line 58: | Line 58: | ||
if (slides[name].length === 0) { | if (slides[name].length === 0) { | ||
imageElement.src = "https://illus.twainframe.org/images/ | imageElement.src = "https://illus.twainframe.org/images/2/2b/ChapterPlaceholder.png"; | ||
imageElement.title = "Keine passenden Bilder gefunden."; | imageElement.title = "Keine passenden Bilder gefunden."; | ||
} else { | } else { | ||
Revision as of 20:30, 2 September 2025
// Acht feste Illustratoren definieren
const illustrators = [
"Kemble",
"Schroedter",
"Hirth",
"Busoni",
"Kellerer",
"Harder",
"Trier",
"Bebié"
];
// Bildlisten und aktuelle Indizes
let slides = {};
let currentIndex = {};
illustrators.forEach(name => {
slides[name] = [];
currentIndex[name] = 0;
});
// Eingabe verarbeiten
function loadSlideshowsByChapter() {
const chapterInput = document.getElementById("chapterInput").value.trim();
const chapterNumber = parseInt(chapterInput, 10);
if (isNaN(chapterNumber) || chapterNumber < 1 || chapterNumber > 43) {
alert("Bitte eine Zahl zwischen 1 und 43 eingeben.");
return;
}
const chapterTag = "ch" + String(chapterNumber).padStart(3, "0");
// Tabelle durchsuchen
const rows = document.querySelectorAll("#catalog tbody tr");
illustrators.forEach(name => {
slides[name] = [];
currentIndex[name] = 0;
const imageElement = document.getElementById("slide-" + name);
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
const illustratorCell = row.cells[2];
const idCell = row.cells[8];
const illustratorText = illustratorCell ? illustratorCell.textContent.trim().toLowerCase() : "";
const idLink = idCell ? idCell.getElementsByTagName("a")[0] : null;
const idText = idLink ? idLink.textContent.trim().toLowerCase() : "";
if (
illustratorText.indexOf(name.toLowerCase()) !== -1 &&
idText.indexOf(chapterTag) !== -1
) {
slides[name].push(idText);
}
}
if (slides[name].length === 0) {
imageElement.src = "https://illus.twainframe.org/images/2/2b/ChapterPlaceholder.png";
imageElement.title = "Keine passenden Bilder gefunden.";
} else {
showSlide(name, 0);
}
});
}
// Ein Bild anzeigen
function showSlide(illustrator, index) {
const imageElement = document.getElementById("slide-" + illustrator);
const slideArray = slides[illustrator];
if (!imageElement || slideArray.length === 0) return;
currentIndex[illustrator] = (index + slideArray.length) % slideArray.length;
const imageId = slideArray[currentIndex[illustrator]];
imageElement.src = "/index.php/Special:Redirect/file/" + imageId + ".jpg";
imageElement.alt = imageId;
imageElement.title = imageId;
}
// Buttons
function nextSlide(illustrator) {
showSlide(illustrator, currentIndex[illustrator] + 1);
}
function prevSlide(illustrator) {
showSlide(illustrator, currentIndex[illustrator] - 1);
}