- D20 Studios Wiki

Leaderboard: Difference between revisions

Created page with "<noinclude> This widget fetches the Top 25 leaderboard from the Abalon database. Usage: {{#widget:Leaderboard}} </noinclude> <div id="leaderboard-container">Loading leaderboard...</div> <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: J..."
 
Blanked the page
Tag: Blanking
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<noinclude>
This widget fetches the Top 25 leaderboard from the Abalon database.
Usage: {{#widget:Leaderboard}}
</noinclude>


<div id="leaderboard-container">Loading leaderboard...</div>
<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 = '<table class="wikitable sortable" style="width:100%; text-align:left;">';
            html += '<tr><th>Placement</th><th>Username</th><th>Score</th></tr>';
           
            data.topPlayers.forEach((player, index) => {
                html += `<tr>
                    <td>#${index + 1}</td>
                    <td>${player.playerName}</td>
                    <td>${Number(player.score).toLocaleString()}</td>
                </tr>`;
            });
           
            html += '</table>';
            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>

Latest revision as of 02:56, 8 February 2026

Chat with us live on DISCORD

Newsletter Signup