Made Downloads Live updating

This commit is contained in:
Pengu 2025-04-05 11:48:38 -05:00
parent 1ba6726d41
commit fb9450a4d0
2 changed files with 30 additions and 2 deletions

View File

@ -20,7 +20,7 @@
<body>
<div class="content">
<img src="media/Downloads-Text (Small).png">
<h1>88k+ Downloads</h1>
<h1 id="downloads-text">Loading downloads...</h1> <!-- Changed to have an id for JavaScript -->
</div>
<div class="content">
<div class="links">
@ -36,6 +36,20 @@
<script src="static/js/home.js" async></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/page-accelerator/0.1.1/page-accelerator.min.js" integrity="sha512-YZMsq9hQOwRuYLHDE3xu5Fuqc7dsw8JW93koppkyK4dxD963sMKZkZQFF62HpQIA74nmG8mK4lzKQf0IpFOU2Q==" crossorigin="anonymous"></script>
<script>
// Fetch the download count from the provided API URL
fetch('https://lethunderstore.lethal-extended.com/api/downloads')
.then(response => response.json())
.then(data => {
const downloadCount = data.downloads;
document.getElementById('downloads-text').innerText = `${downloadCount.toLocaleString()} Downloads`;
})
.catch(error => {
console.error('Error fetching download count:', error);
document.getElementById('downloads-text').innerText = 'Failed to load download count';
});
</script>
</body>
</html>

View File

@ -20,7 +20,7 @@
<body>
<div class="content">
<img src="media/Downloads-Text (Small).png">
<h1>8k+ Downloads</h1>
<h1 id="downloads-text">Loading downloads...</h1> <!-- Changed to have an id for JavaScript -->
</div>
<div class="content">
<div class="links">
@ -36,6 +36,20 @@
<script src="static/js/home.js" async></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/page-accelerator/0.1.1/page-accelerator.min.js" integrity="sha512-YZMsq9hQOwRuYLHDE3xu5Fuqc7dsw8JW93koppkyK4dxD963sMKZkZQFF62HpQIA74nmG8mK4lzKQf0IpFOU2Q==" crossorigin="anonymous"></script>
<script>
// Fetch the download count from the provided API URL
fetch('https://rrthunderstore.lethal-extended.com/api/downloads')
.then(response => response.json())
.then(data => {
const downloadCount = data.downloads;
document.getElementById('downloads-text').innerText = `${downloadCount.toLocaleString()} Downloads`;
})
.catch(error => {
console.error('Error fetching download count:', error);
document.getElementById('downloads-text').innerText = 'Failed to load download count';
});
</script>
</body>
</html>