You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<script>
// Function to update the leaderboard
function updateLeaderboard() {
console.log('Updating leaderboard...');
// Make the asynchronous GET request to retrieve leaderboard data from the API
$.getJSON('https://school.aipad-techs.com/api/leaderboardUser/getMaxScore')
.done(function (data) {
// Clear the current leaderboard on update
$('#recentGames').empty();
// Add labels to the leaderboard table
var labelsRow = '' +
'Name' +
'Score' +
'Date' +
'Locations' +
'Total Distance' +
'';
$('#recentGames').append(labelsRow);
// Adds the new data to the leaderboard from the API response
data.forEach(function (entry) {
var name = entry.name;
var score = entry.score;
var date = entry.dateG;
var locations = Array.isArray(entry.locations) ? entry.locations.join(', ') : '';
var totalDistance = entry.tot_distance;
var row = '' +
'' + name + '' +
'' + score + '' +
'' + date + '' +
'' + locations + '' +
'' + totalDistance + '' +
'';
$('#recentGames').append(row);
});
console.log('Leaderboard updated.');
})
.fail(function (error) {
console.log('Error:', error);
});
}
setInterval(updateLeaderboard, 1000);
</script>