Update Tester.HTML

This commit is contained in:
Dangrainage 2024-04-25 08:41:31 +02:00 committed by GitHub
parent ff756ffafd
commit 813788bcc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,22 +38,14 @@
if (results.length === 0) { if (results.length === 0) {
searchResultsDiv.textContent = 'No results found.'; searchResultsDiv.textContent = 'No results found.';
} else { } else {
let resultList = document.createElement('ul');
results.forEach(result => { results.forEach(result => {
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 = result.link ? result.link : '#'; // If link is not available, set href to '#' link.href = result.link;
link.onclick = function() { link.style.display = 'block';
if (result.link) { link.style.marginBottom = '10px';
window.location.href = result.link; searchResultsDiv.appendChild(link);
}
};
console.log("Link:", result.link); // Log link to console for debugging
listItem.appendChild(link);
resultList.appendChild(listItem);
}); });
searchResultsDiv.appendChild(resultList);
} }
} }
</script> </script>