This widget fetches the Top 25 leaderboard from the Abalon database.
Usage:
<script> (function() {
// URL to your PHP script - UPDATE THIS TO YOUR ACTUAL URL const scriptUrl = 'https://d20studios.com/abalon/services/abalonStatBot.php';
fetch(scriptUrl, {
method: 'POST',
headers: { 'Content-Type: application/json' },
body: JSON.stringify({ type: 'leaderboardTop', limit: 25 })
})
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
let html = '
'; html += ''; data.topPlayers.forEach((player, index) => {
html += ``;
});
html += '| Placement | Username | Score |
|---|---|---|
| #${index + 1} | ${player.playerName} | ${Number(player.score).toLocaleString()} |
';
document.getElementById('leaderboard-container').innerHTML = html;
} else {
document.getElementById('leaderboard-container').innerHTML = 'Error loading leaderboard data.';
}
})
.catch(error => {
console.error('Error:', error);
document.getElementById('leaderboard-container').innerHTML = 'Failed to connect to the leaderboard service.';
});
})(); </script>