1/* Parámetros de URL*/ 2const urlParams = new URLSearchParams(window.location.search); 3const texto = urlParams.get("texto") || ""; 4const dependenciaID = urlParams.get("dependencia") || 0; 5 6/* Obtener fecha actual*/ 7const currentDate = new Date().toISOString().split('T')[0]; 8 9const fechaIni = urlParams.get("fechaini") || "2023-11-04"; 10const fechaFin = urlParams.get("fechafin") || currentDate; 11 12var dependencia; 13 14/* Formatear fecha */ 15function formatDate(tmp){ 16 const date = new Date(tmp); 17 const meses = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]; 18 return `${date.getDate()} de ${meses[date.getMonth()]} de ${date.getUTCFullYear()}`; 19} 20 21/* Petición */ 22$(document).ready(() => { 23 $.ajax({ 24 url: 'https://aplicativos.ags.gob.mx/wsPrensa/api/Info/ListadoDependencias', 25 type: 'GET', 26 dataType: "json", 27 success: function(data) { 28 if (dependenciaID != 0) { 29 const dependenciaExits = data.find(d => d.idDependencia == dependenciaID); 30 if (dependenciaExits) { 31 dependencia = dependenciaExits.nombre; 32 } 33 } 34 for (let i = 0; i < data.length; i++){ 35 $('#select-dep').append($('<option>', { 36 value: data[i].idDependencia, 37 text: data[i].nombre 38 })) 39 } 40 actualizaFiltros(); 41 inicializarTabla(texto, dependenciaID, fechaIni, fechaFin); 42 }, 43 error: function (data) { 44 console.log("Error al traer lista dependencias:"); 45 console.log(data); 46 } 47 }); 48}); 49 50/* 51function titulo() { 52 if (texto || dependenciaID) { 53 inicializarTabla(texto, dependenciaID, fechaIni, fechaFin); 54 } 55 if(texto != "" && dependenciaID != "") { 56 $("#tituloBusqueda").append( "<h1>Boletines y noticias de <span style='color: #ff8600'>"+dependencia+"</span> que contienen <span style='color: #ff8600'>"+texto+"</span></h1>" ); 57 } else if(texto != "") { 58 $("#tituloBusqueda").append( "<h1>Boletines y noticias que contienen: <span style='color: #ff8600'>"+texto+"</span></h1>" ); 59 } else if(dependenciaID != "") { 60 $("#tituloBusqueda").append( "<h1>Boletines y noticias de: <span style='color: #ff8600'>"+dependencia+"</span></h1>" ); 61 } else { 62 $("#tituloBusqueda").append( "<h1>Ocirrió un error al realizar la búsqueda</h1>" ); 63 } 64 65 $("#tituloBusqueda").css("display", "block"); 66}*/ 67 68/* actualizar filtros */ 69function actualizaFiltros() { 70 if (texto != "") { 71 $("#txt_bsqTexto").val(texto); 72 } 73 74 if (dependenciaID != "") { 75 $("#select-dep").val(dependenciaID); 76 } 77 78 $("#date1").val(fechaIni); 79 $("#date2").val(fechaFin);
80} 81 82 83/* Pintar DataTable */ 84function inicializarTabla(txt, dep, fechaInicio, fechaFin) { 85 var fechaFinEnvio= sumarDias(fechaFin); 86 87 if ($.fn.DataTable.isDataTable("#TablaPublicaciones")) { 88 $("#TablaPublicaciones").DataTable().destroy(); 89 } 90 91 const busquedaParam = 92 txt === null || txt === undefined || txt === "" 93 ? " " 94 : txt; 95 96 $("#TablaPublicaciones").DataTable({ 97 processing: true, 98 serverSide: false, 99 deferRender: true, 100 101 ajax: function (_dtParams, callback) { 102 103 const params = { 104 Busqueda: busquedaParam, 105 fecha_inicio: fechaInicio, 106 fecha_fin: fechaFinEnvio, 107 IdDependencia: dep 108 }; 109 110 $.ajax({ 111 url: "https://aplicativos.ags.gob.mx/wsPrensa/api/Info/PublicacionBusquedaRangoFecha2", 112 type: "GET", 113 dataType: "json", 114 115 data: $.param(params), 116 117 success: function (resp) { 118 callback({ 119 data: Array.isArray(resp) ? resp : [] 120 }); 121 }, 122 123 error: function (xhr) { 124 console.error("Error API:", xhr.responseText); 125 callback({ data: [] }); 126 } 127 }); 128 }, 129 130 columns: [ 131 { 132 data: "idPublicacion", 133 render: id => ` 134 <div class="banner-placeholder" data-id="${id}"> 135 <span class="loader">Cargandoâ¦</span> 136 </div> 137 ` 138 }, 139 { 140 data: null, 141 render: row => ` 142 <a href="./publicacion.html?id=${row.idPublicacion}" target="_blank"> 143 <p> 144 <span class="publicaciones-tit">${row.titulo}</span><br> 145 <span class="publicaciones-subtit mov-hide">${row.subtitulo || ""}...</span> 146 <br> 147 <span style="color:#01a5ae">Ver más</span><br> 148 <span style="color:#423e3f;font-size:11pt"> 149 ${formatDate(row.fechaAlta)} 150 </span> 151 </p> 152 </a> 153 ` 154 } 155 ], 156 157 createdRow: (row, data) => { 158 cargarBannerAsync(data, $(row)); 159 }, 160 161 order: [], 162 language: { 163 url: "./external/DataTables/es.json" 164 } 165 }); 166} 167 168/* Carga asÃncrona de banners */ 169async function cargarBannerAsync(data, $row) { 170 171 const id = data.idPublicacion; 172 const $contenedor = $row.find(`.banner-placeholder[data-id="${id}"]`); 173 174 try { 175 const imagenes = await $.ajax({
176 url: "https://aplicativos.ags.gob.mx/wsPrensa/api/Info/ObtenerImagenesBanner", 177 type: "GET", 178 dataType: "json", 179 data: { ID_PUBLICACION: id } 180 }); 181 182 if (!imagenes || !imagenes.length) { 183 $contenedor.empty(); 184 return; 185 } 186 187 //const bg = ``; 188 189 $contenedor.html(` 190 <a href="./publicacion.html?id=${id}" target="_blank"> 191 <div class="banner-notas marcador-destacada" style="background-size:cover"></div> 192 </a> 193 `); 194 195 $contenedor.find(".banner-notas").css( 196 "background-image", 197 `url(data:image/png;base64,${imagenes[0]})` 198 ); 199 200 } catch (error) { 201 console.error(`Error banner ID ${id}`, error); 202 $contenedor.empty(); 203 } 204} 205 206function bsqFiltro() { 207 console.log("Enviando filtro..."); 208 filtroTxt = $("#txt_bsqTexto").val(); 209 filtroDep = $("#select-dep").val(); 210 filtroFechaIni = $("#date1").val(); 211 filtroFechaFin = $("#date2").val(); 212 window.location.href = "https://ags.gob.mx/trabajamos/busqueda3.html?texto="+filtroTxt+"&dependencia="+filtroDep+"&fechaini="+filtroFechaIni+"&fechafin="+filtroFechaFin; 213} 214 215/* Sumer 1 dÃa para traer hasta las 11:59pm del dÃa final*/ 216function sumarDias(fechaStr, dias = 1) { 217 const [year, month, day] = fechaStr.split('-').map(Number); 218 const fecha = new Date(year, month - 1, day); 219 fecha.setDate(fecha.getDate() + dias); 220 const yyyy = fecha.getFullYear(); 221 const mm = String(fecha.getMonth() + 1).padStart(2, '0'); 222 const dd = String(fecha.getDate()).padStart(2, '0'); 223 224 return `${yyyy}-${mm}-${dd}`; 225}
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.