Update Tester.HTML

This commit is contained in:
Dangrainage 2024-04-25 08:55:32 +02:00 committed by GitHub
parent e4d0ffdb1b
commit 04b924b867
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -40,14 +40,13 @@
} else { } else {
let resultList = document.createElement('ul'); let resultList = document.createElement('ul');
results.forEach(result => { results.forEach(result => {
console.log('Result:', result); // Log the result object
let listItem = document.createElement('li'); let listItem = document.createElement('li');
let link = document.createElement('a'); let link = document.createElement('a');
link.textContent = `${result.title} (${result.year})`; link.textContent = `${result.title} (${result.year})`;
link.href = "#"; // Set a placeholder href link.href = "#"; // Set a placeholder href
link.addEventListener('click', function(event) { link.addEventListener('click', function(event) {
event.preventDefault(); event.preventDefault();
generateDynamic(result.link); generateDynamic(result.href);
}); });
listItem.appendChild(link); listItem.appendChild(link);
resultList.appendChild(listItem); resultList.appendChild(listItem);
@ -57,8 +56,8 @@
} }
function generateDynamic(href) { function generateDynamic(href) {
if (href) { if (href && href.startsWith('/')) {
fetch(`https://filmer.anorak01.top/vid/${href.split("//")[1]}`) fetch(`https://filmer.anorak01.top/vid/${href.split("/")[1]}`)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (data.url) { if (data.url) {