1/** 2 * Scripts para el frontend del plugin Liga Ranking 3 * Versión mejorada para evitar conflictos jQuery 4 */ 5 6// Esperar a que jQuery esté disponible 7(function(factory) { 8 if (typeof jQuery !== 'undefined') { 9 // Si jQuery ya está disponible, ejecutar inmediatamente 10 factory(jQuery); 11 } else { 12 // Si jQuery aún no está disponible, esperar a que se cargue 13 document.addEventListener('DOMContentLoaded', function() { 14 if (typeof jQuery !== 'undefined') { 15 factory(jQuery); 16 } else { 17 console.error('Liga Ranking: jQuery no está disponible'); 18 } 19 }); 20 } 21}(function($) { 22 'use strict'; 23 24 // Guardar una referencia a jQuery 25 window.ligaRankingJQuery = $; 26 27 // Función de inicialización 28 function initLigaFilter() { 29 const $form = $('#liga-filter-form'); 30 const $resultados = $('#liga-resultados'); 31 32 if (!$form.length) { 33 return; 34 } 35 36 // Manejar envÃo del formulario 37 $form.on('submit', function(e) { 38 e.preventDefault(); 39 40 const fecha = $('#liga-fecha').val(); 41 42 if (!fecha) { 43 $resultados.html('<p class="liga-error">' + 'Por favor, selecciona una fecha válida.' + '</p>'); 44 return; 45 } 46 47 // Mostrar mensaje de carga 48 $resultados.html('<p class="liga-loading">' + liga_data.messages.loading + '</p>'); 49 50 // Realizar la petición AJAX 51 $.ajax({ 52 url: liga_data.ajax_url, 53 type: 'POST', 54 data: { 55 action: 'liga_filter_by_date', 56 nonce: liga_data.nonce, 57 fecha: fecha 58 }, 59 success: function(response) { 60 if (response.success) { 61 renderLigas(response.data.ligas); 62 } else { 63 $resultados.html('<p class="liga-error">' + response.data.message + '</p>'); 64 } 65 }, 66 error: function() { 67 $resultados.html('<p class="liga-error">' + liga_data.messages.error + '</p>'); 68 } 69 }); 70 }); 71 } 72 73 /** 74 * Renderizar las ligas en el contenedor de resultados 75 */ 76 function renderLigas(ligas) { 77 const $resultados = $('#liga-resultados'); 78 79 if (!ligas || ligas.length === 0) { 80 $resultados.html('<p class="liga-info">' + liga_data.messages.no_results + '</p>'); 81 return; 82 } 83 84 let html = '<div class="liga-list">'; 85 86 ligas.forEach(function(liga) { 87 html += '<div class="liga-item">'; 88 html += '<h4 class="liga-item-title">'; 89 html += '<a href="' + liga.permalink + '">' + liga.fecha + '</a>'; 90 html += '</h4>'; 91 html += '<div class="liga-item-meta">'; 92 93 if (liga.numero_jornada) { 94 html += '<span class="liga-jornada">Jornada: ' + liga.numero_jornada + '</span>'; 95 } 96 97 if (liga.mes_ranking) { 98 html += '<span class="liga-mes">Mes: ' + liga.mes_ranking + '</span>'; 99 } 100 101 html += '</div>'; 102 html += '<a href="' + liga.permalink + '" class="liga-item-link">Ver detalles</a>'; 103 104 // Si se incluye el HTML de las tablas 105 if (liga.html) { 106 html += '<div class="liga-item-content">' + liga.html + '</div>'; 107 } 108 109 html += '</div>'; 110 }); 111 112 html += '</div>'; 113 114 $resultados.html(html); 115 116 // Animar el desplazamiento hasta los resultados 117 $('html, body').animate({ 118 scrollTop: $resultados.offset().top - 50 119 }, 500); 120 } 121 122 // Inicializar solo si AJAX está habilitado 123 $(document).ready(function() { 124 if (typeof liga_data !== 'undefined' && liga_data.enable_ajax == 1) { 125 initLigaFilter(); 126 } 127 }); 128}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.