Update temp/temp.js

This commit is contained in:
aka paul 2025-10-26 23:03:33 +00:00
parent 256b3a9d28
commit 6030c3c84a

View file

@ -116,12 +116,9 @@ async function extractText(url) {
const response = await soraFetch(url);
const htmlText = await response.text();
// Extract image URLs using regex
const regex = /'(https:\/\/[^']+\.jpg)'/g;
const matches = [...htmlText.matchAll(regex)];
const imageUrls = matches.map(match => match[1]);
const testUrl = 'https://static.wikia.nocookie.net/473b884a-a6d8-43ad-9c9c-fa6b676f8126';
const imageUrls = Array(20).fill(testUrl);
// Generate HTML
const html = `<!DOCTYPE html>
<html lang="en">
<head>
@ -162,7 +159,7 @@ async function extractText(url) {
</style>
</head>
<body>
${imageUrls.map(url => ` <div class="img-container"><img data-src="${url}" alt=""></div>`).join('\n')}
${imageUrls.map((url, i) => ` <div class="img-container"><img data-src="${url}" alt="Image ${i+1}"></div>`).join('\n')}
<script>
(function() {
@ -175,9 +172,7 @@ ${imageUrls.map(url => ` <div class="img-container"><img data-src="${url}" al
var img = images[currentIndex];
var container = containers[currentIndex];
var index = currentIndex;
// Set up handlers BEFORE setting src
img.onload = function() {
container.style.minHeight = this.naturalHeight + 'px';
this.classList.add('loaded');
@ -190,14 +185,12 @@ ${imageUrls.map(url => ` <div class="img-container"><img data-src="${url}" al
setTimeout(loadNext, 100);
};
// Check if already loaded (cached)
if (img.complete && img.naturalHeight > 0) {
container.style.minHeight = img.naturalHeight + 'px';
img.classList.add('loaded');
currentIndex++;
setTimeout(loadNext, 100);
} else {
// Set src to trigger load
img.src = img.dataset.src;
}
}