Manejo de cookies
This commit is contained in:
+45
-39
@@ -1,36 +1,36 @@
|
||||
$(document).ready(function () {
|
||||
cargarRanking();
|
||||
cargarRanking();
|
||||
});
|
||||
|
||||
function cargarRanking() {
|
||||
$.ajax({
|
||||
url: 'controladores/controladorUsuario.php',
|
||||
type: 'POST',
|
||||
data: { orden: 'obtenerRanking' },
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
if (response.exito && response.ranking.length > 0) {
|
||||
renderizarTablaRanking(response.ranking);
|
||||
} else {
|
||||
$('#ranking-container').html(`
|
||||
$.ajax({
|
||||
url: "controladores/controladorUsuario.php",
|
||||
type: "POST",
|
||||
data: { orden: "obtenerRanking" },
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
if (response.exito && response.ranking.length > 0) {
|
||||
renderizarTablaRanking(response.ranking);
|
||||
} else {
|
||||
$("#ranking-container").html(`
|
||||
<div class="alert alert-info my-3">
|
||||
<i class="fa-solid fa-info-circle me-2"></i>Aún no hay partidas registradas para mostrar el ranking.
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('#ranking-container').html(`
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#ranking-container").html(`
|
||||
<div class="alert alert-danger my-3">
|
||||
<i class="fa-solid fa-exclamation-triangle me-2"></i>Error al cargar la clasificación.
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function renderizarTablaRanking(jugadores) {
|
||||
let html = `
|
||||
let html = `
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover align-middle mb-0 text-center">
|
||||
<thead class="table-dark">
|
||||
@@ -46,24 +46,29 @@ function renderizarTablaRanking(jugadores) {
|
||||
<tbody>
|
||||
`;
|
||||
|
||||
jugadores.forEach((jugador, index) => {
|
||||
let posicion = index + 1;
|
||||
let medalla = '';
|
||||
jugadores.forEach((jugador, index) => {
|
||||
let posicion = index + 1;
|
||||
let medalla = "";
|
||||
|
||||
// Medallas para el Top 3
|
||||
if (posicion === 1) {
|
||||
medalla = '<i class="fa-solid fa-medal text-warning fa-lg" title="1º Puesto"></i>';
|
||||
} else if (posicion === 2) {
|
||||
medalla = '<i class="fa-solid fa-medal text-secondary fa-lg" title="2º Puesto"></i>';
|
||||
} else if (posicion === 3) {
|
||||
medalla = '<i class="fa-solid fa-medal text-brown fa-lg" style="color: #cd7f32;" title="3º Puesto"></i>';
|
||||
} else {
|
||||
medalla = `<span class="fw-bold text-muted">${posicion}</span>`;
|
||||
}
|
||||
// Medallas para el Top 3
|
||||
if (posicion === 1) {
|
||||
medalla =
|
||||
'<i class="fa-solid fa-medal text-warning fa-lg" title="1º Puesto"></i>';
|
||||
} else if (posicion === 2) {
|
||||
medalla =
|
||||
'<i class="fa-solid fa-medal text-secondary fa-lg" title="2º Puesto"></i>';
|
||||
} else if (posicion === 3) {
|
||||
medalla =
|
||||
'<i class="fa-solid fa-medal text-brown fa-lg" style="color: #cd7f32;" title="3º Puesto"></i>';
|
||||
} else {
|
||||
medalla = `<span class="fw-bold text-muted">${posicion}</span>`;
|
||||
}
|
||||
|
||||
let avatarImg = jugador.avatar ? jugador.avatar : 'img/avatars/defaultProfile.jpeg';
|
||||
let avatarImg = jugador.avatar
|
||||
? jugador.avatar
|
||||
: "img/avatars/defaultProfile.jpeg";
|
||||
|
||||
html += `
|
||||
html += `
|
||||
<tr>
|
||||
<td class="fw-bold fs-5">${medalla}</td>
|
||||
<td class="text-start fw-bold">
|
||||
@@ -78,18 +83,19 @@ function renderizarTablaRanking(jugadores) {
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
});
|
||||
|
||||
html += `
|
||||
html += `
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#ranking-container').removeClass('text-center p-4 ranking-placeholder').html(html);
|
||||
$("#ranking-container")
|
||||
.removeClass("text-center p-4 ranking-placeholder")
|
||||
.html(html);
|
||||
}
|
||||
|
||||
|
||||
function escapeHtml(texto) {
|
||||
return $('<div>').text(texto).html();
|
||||
}
|
||||
return $("<div>").text(texto).html();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user