1window.onload = guardarVisita(); 2window.onload = cargarBanners(); 3window.onload = cargarEncuestas(); 4 5function guardarVisita() 6{ 7 8 $.ajax({ 9 async: true, 10 type : 'POST', 11 data : "", 12 url : 'admin/ajax/guardarVisitaWeb.php', 13 success: function(data){ 14 15 } 16 17 }); 18} 19 20$(document).on('submit', '.nav-search form', function(e) { 21 e.preventDefault(); // evita el envÃo tradicional 22 var valor = $(this).find('input[name="search"]').val().trim(); 23 if (valor !== '') { 24 window.location.href = 'busqueda.php?cod=' + encodeURIComponent(valor); 25 } 26}); 27 28 29function buscarNoticia() 30{ 31 window.location = "busqueda.php?cod="+document.getElementById("busqueda_texto").value; 32 33} 34 35 36function buscarNoticiaMobile() 37{ 38 window.location = "busqueda.php?cod="+document.getElementById("busqueda_texto_mobile").value; 39 40} 41 42function validarFormContactoFooter() 43{ 44 var ok = true; 45 46 if(mensaje_footer.value.replace(/\s/g,'')=="") 47 { 48 campo_mensaje_footer.style.color = "red"; 49 mensaje_footer.focus(); 50 error_mensaje_footer.innerHTML = "Obligatorio"; 51 ok = false; 52 } 53 else 54 { 55 campo_mensaje_footer.style.color = "green"; 56 error_mensaje_footer.innerHTML = ""; 57 } 58 59 60 61 if (email_footer.value.replace(/\s/g,'')=="") 62 { 63 campo_email_footer.style.color = "red"; 64 email_footer.focus(); 65 // error_email_footer.style.color = "fa fa-close form-control-feedback"; 66 error_email_footer.innerHTML = "Obligatorio"; 67 ok = false; 68 } 69 else 70 { 71 var expReg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/; 72 if(!expReg.test(email_footer.value)) 73 { 74 campo_email_footer.style.color = "red"; 75 email_footer.focus(); 76 // error_email_footer.style.color = "fa fa-close form-control-feedback"; 77 error_email_footer.innerHTML = "Formato correcto: [email protected]"; 78 ok = false; 79 } 80 else 81 { 82 campo_email_footer.style.color = "green"; 83 // error_email_footer.style.color = "fa fa-check form-control-feedback"; 84 error_email_footer.innerHTML = ""; 85 } 86 } 87 88 89 90 return ok; 91 } 92 93 94 95function enviarMensajeFooter() 96{ 97 if(validarFormContactoFooter()) 98 { 99 $("#form_contacto_footer").slideUp(); 100 cargando_footer.innerHTML = "<div class='progress progress-striped active' style='height:18px'>"+ 101 "<div class='progress-bar progress-bar-gray' role='progressbar'"+ 102 "aria-valuenow='100' aria-valuemin='0' aria-valuemax='100' style='width: 100%;text-align:center; padding:0'>"+ 103 "<span style='color:#fff; '><b>Enviando...</b></span></div></div>"; 104 105 var formData = new FormData($("#form_contacto_footer")[0]); 106 107 var ruta = "admin/ajax_frontend/enviarMensajeFooter.php"; 108 $.ajax({
109 async: true, 110 url: ruta, 111 type: "POST", 112 data: formData, 113 contentType: false, 114 processData: false, 115 success: function(datos) 116 { 117 // alert(datos); 118 if(datos==1) 119 { 120 //ok 121 cargando_footer.innerHTML = '<div class="alert alert-success" role="alert">'+ 122 '<strong><i class="fa fa-check"></i> ¡Gracias por escribirnos!</strong> Mensaje enviado correctamente.'+ 123 '</div>'; 124 125 $("#cargando_footer").slideDown(); 126 127 128 document.getElementById("form_contacto_footer").reset(); 129 } 130 else if(datos==0) 131 { 132 $("#form_contacto_footer").slideDown(); 133 134 cargando_footer.innerHTML = '<div class="alert alert-danger" role="alert">'+ 135 '<strong>¡Ups!</strong> Ha ocurrido un error. Por favor, vuelva a intentarlo.'+ 136 '</div>'; 137 } 138 else 139 { 140 $("#form_contacto_footer").slideDown(); 141 142 cargando_footer.innerHTML = '<div class="alert alert-danger" role="alert">'+ 143 '<strong>¡Ups!</strong> Error en el servidor. Comuniquese con el administrador.'+ 144 '</div>'; 145 } 146 147 148 } 149 }); 150 } 151 152 153} 154 155function cargarBanners() 156{ 157 158 $.ajax({ 159 async: false, 160 type : 'POST', 161 data : "", 162 url : 'admin/ajax_frontend/cargarBannersPopup.php', 163 dataType: "json", 164 success: function(data){ 165 //alert(data[7]); 166 if(data[0]!=null) 167 168 { 169 170 //Ok 171 172 if (typeof banner_popup != 'undefined') 173 { 174 imagen_banner_popup.innerHTML = data[7]; 175 if(data[7]!=""&&data[7]!=undefined) 176 $("#banner_popup").modal("show"); 177 else 178 $("#banner_popup").modal("hide"); 179 } 180 else 181 $("#banner_popup").modal("hide"); 182 183 184 } 185 } 186 187 }); 188} 189 190function cargarEncuestas() 191{ 192 if (typeof encuestas != 'undefined') 193 { 194 $.ajax({ 195 async: true, 196 type : 'POST', 197 data : "", 198 url : 'admin/ajax_frontend/cargarEncuestas.php', 199 // dataType: "json", 200 success: function(data){ 201 // alert(data); 202 if(data!=null) 203 { 204 //Ok 205 if(data.length>2) 206 { 207 // alert("true"); 208 encuestas.innerHTML = data; 209 } 210 else 211 { 212 encuestas.style.display = "none"; 213 // alert("false"); 214 } 215 } 216 // else 217 // { 218 // tipo = "danger"; 219 // mensaje = "<b><i class='fa fa-times'></i> Error en el servidor. Comuniquese con el administrador.</b>"; 220 // notify(mensaje, tipo,'bottom','right'); 221 // } 222 223 } 224 225 }); 226} 227} 228 229function votar(id_encuesta) 230{ 231 var formData = new FormData($("#form_encuesta")[0]); 232 233 $.ajax({ 234 async: true, 235 type : 'POST', 236 data: formData, 237 contentType: false, 238 processData: false, 239 url : 'admin/ajax_frontend/votarEncuesta.php', 240 // dataType: "json", 241 success: function(data){ 242 // alert(data); 243 if(data==1) 244 { 245 //Ok 246 mostrarResultados(id_encuesta); 247 } 248 // else 249 // { 250 // tipo = "danger"; 251 // mensaje = "<b><i class='fa fa-times'></i> Error en el servidor. Comuniquese con el administrador.</b>"; 252 // notify(mensaje, tipo,'bottom','right'); 253 // } 254 255 } 256 257 }); 258} 259 260function mostrarResultados(id) 261{ 262 263 $.ajax({ 264 async: true, 265 type : 'POST', 266 data : "id="+id, 267 url : 'admin/ajax_frontend/mostrarResultadosEncuesta.php', 268 // dataType: "json", 269 success: function(data){ 270 // alert(data); 271 if(data!=null) 272 { 273 //Ok 274 encuestas.innerHTML = data; 275 276 // Animated Progress Bars 277 //----------------------------------------------- 278 if ($("[data-animate-width]").length>0) { 279 $("[data-animate-width]").each(function() { 280 $(this).appear(function() { 281 $(this).animate({ 282 width: $(this).attr("data-animate-width") 283 }, 800 ); 284 }
284, {accX: 0, accY: -100}); 285 }); 286 }; 287 288 // Animated Progress Bars 289 //----------------------------------------------- 290 if ($(".knob").length>0) { 291 $(".knob").knob(); 292 } 293 } 294 // else 295 // { 296 // tipo = "danger"; 297 // mensaje = "<b><i class='fa fa-times'></i> Error en el servidor. Comuniquese con el administrador.</b>"; 298 // notify(mensaje, tipo,'bottom','right'); 299 // } 300 301 } 302 303 }); 304} 305 306 document.addEventListener('DOMContentLoaded', async () => { 307 if (!localStorage.getItem('notificationsChoice')) { 308 setTimeout(() => { 309 document.getElementById('notificationBackdrop').style.display = 'block'; 310 document.getElementById('notificationModal').style.display = 'block'; 311 }, 3000); 312 } 313}); 314 315async function subscribeToNotifications() { 316 if ('serviceWorker' in navigator && 'PushManager' in window) { 317 try { 318 // Obtener la clave pública desde el archivo JSON 319 const keyResponse = await fetch('admin/notif/keys.json'); 320 const keyData = await keyResponse.json(); 321 const applicationServerKey = urlBase64ToUint8Array(keyData.publicKey); 322 323 // Registrar el Service Worker 324 const registration = await navigator.serviceWorker.register('js/sw.js'); 325 const subscription = await registration.pushManager.subscribe({ 326 userVisibleOnly: true, 327 applicationServerKey: applicationServerKey 328 }); 329 330 // Enviar la suscripción al servidor 331 const response = await fetch('admin/notif/save-subscription.php', { 332 method: 'POST', 333 headers: { 'Content-Type': 'application/json' }, 334 body: JSON.stringify(subscription) 335 }); 336 337 if (response.ok) { 338 console.log('¡Suscripción completada!'); 339 localStorage.setItem('notificationsChoice', 'accepted'); // Guardar preferencia del usuario 340 } else { 341 console.error('Error al suscribirse.'); 342 } 343 } catch (error) { 344 console.error('Error en la suscripción:', error); 345 } 346 } else { 347 console.warn('Tu navegador no soporta notificaciones push.'); 348 } 349 350 closeNotificationModal(); 351} 352 353function closeNotificationModal() { 354 document.getElementById('notificationBackdrop').style.display = 'none'; 355 document.getElementById('notificationModal').style.display = 'none'; 356 localStorage.setItem('notificationsChoice', 'denied'); // Guardar que el usuario rechazó la notificación 357} 358 359function urlBase64ToUint8Array(base64String) { 360 const padding = '='.repeat((4 - base64String.length % 4) % 4); 361 const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/'); 362 const rawData = window.atob(base64); 363 return new Uint8Array([...rawData].map(char => char.charCodeAt(0))); 364}
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.