|
|
@ -135,28 +135,43 @@ async function showRandomAnnouncement(groupId, timeInterval) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function hideSponsorOnImageError() { |
|
|
|
const sponsorImages = document.querySelectorAll('.sponsor-image'); |
|
|
|
function handleSponsorImages() { |
|
|
|
const announceRight = document.getElementById('announce-right'); |
|
|
|
if(!announceRight) return; |
|
|
|
|
|
|
|
function hideAnnounceRight() { |
|
|
|
if (announceRight) { |
|
|
|
announceRight.style.display = 'none'; |
|
|
|
} |
|
|
|
} |
|
|
|
const sponsorImages = document.querySelectorAll('.sponsor-image'); |
|
|
|
|
|
|
|
sponsorImages.forEach(function(img) { |
|
|
|
img.addEventListener('error', function() { |
|
|
|
hideAnnounceRight(); |
|
|
|
const imagePromises = Array.from(sponsorImages).map(img => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
if (img.complete && img.naturalHeight !== 0) { |
|
|
|
resolve(); |
|
|
|
} else { |
|
|
|
img.addEventListener('load', () => { |
|
|
|
if (img.naturalHeight !== 0) { |
|
|
|
resolve(); |
|
|
|
} else { |
|
|
|
reject(); |
|
|
|
} |
|
|
|
}); |
|
|
|
img.addEventListener('error', reject); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
Promise.all(imagePromises) |
|
|
|
.then(() => { |
|
|
|
announceRight.style.display = 'block'; |
|
|
|
showRandomAnnouncement('announce-right', 10000); |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
// do nothing
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
async function main() { |
|
|
|
setupTermynal(); |
|
|
|
showRandomAnnouncement('announce-left', 5000) |
|
|
|
showRandomAnnouncement('announce-right', 10000) |
|
|
|
hideSponsorOnImageError(); |
|
|
|
handleSponsorImages(); |
|
|
|
} |
|
|
|
document$.subscribe(() => { |
|
|
|
main() |
|
|
|