1// Establece el alto del menú principal y el alto del NAV (capa donde están los enlaces del menú) contenido en el menú principal. 2$(function(){ 3 $('#menu_principal_desplegable').css({'height':$(window).height()}); 4 $('#menu_principal_desplegable nav').css({'height':$(window).height()-95}); 5}); 6 7// Muestra/Oculta la capa pasándole el ID de la misma (Poner en el elemento pulsable: onclick="toggle('id_capa')") 8function toggle(destino) { 9 $('#'+destino).toggle("blind"); 10} 11 12// Muestra con efecto "fade - aparecer" los tooltips 13function fade_tooltip(destino) { 14 $('.tooltip_general').hide(); 15 if ($('#'+destino).is(':visible')) { 16 $('#'+destino).hide(); 17 } else { 18 $('#'+destino).fadeIn(600); 19 } 20} 21 22// Toggle categorÃas menú 23function toggle_categorias(este, destino) { 24 if ($(este).siblings("."+destino).is(":visible")) { 25 $(este).siblings("."+destino).hide("slow"); 26 $(este).children(".fa-sort-down").addClass("plegado"); 27 } else { 28 $(este).siblings("."+destino).show("slow"); 29 $(este).children(".fa-sort-down").removeClass("plegado"); 30 } 31} 32 33function zfill(number, width) { 34 var numberOutput = Math.abs(number); /* Valor absoluto del número */ 35 var length = number.toString().length; /* Largo del número */ 36 var zero = "0"; /* String de cero */ 37 38 if (width <= length) { 39 if (number < 0) { 40 return ("-" + numberOutput.toString()); 41 } else { 42 return numberOutput.toString(); 43 } 44 } else { 45 if (number < 0) { 46 return ("-" + (zero.repeat(width - length)) + numberOutput.toString()); 47 } else { 48 return ((zero.repeat(width - length)) + numberOutput.toString()); 49 } 50 } 51} 52 53function comprobar_rango_fechas(str_fecha_i, str_fecha_f){ 54 var fecha_i = new Date(str_fecha_i); 55 var fecha_f = new Date(str_fecha_f); 56 if (fecha_i.getTime() > fecha_f.getTime()) return false; 57 return true; 58} 59 60// Funciones cadenas de texto 61function _js_www_isAlphanumeric(str) { 62 // Estricto. Solo permite caracteres alfanumericos 63 // Ej. 64 // hola -> valido 65 // hola. -> no valido 66 // . -> no valido 67 var letters = /^[0-9a-zA-Zá-úÃ-Ã\s]+$/; 68 return (str.match(letters) && str.length > 1 && str.replace(/\s/g, '') !== '') ? true : false; 69} 70 71function _js_www_hasAlphanumeric(str) { 72 // Flexible. Debe tener algun caracter alfanumerico pero se permite incluir otros tipos de caracteres. 73 // Ej. 74 // hola -> valido 75 // hola. -> valido 76 // . -> no valido 77 return (/\d|[A-z]/.test(str) && str.length > 1 && str.replace(/([a-zA-Z0-9 ])/g, "") !== str.replace(/\s/g, '')) ? true : false; // Fix caracter _ como valido. 78} 79 80function _js_www_getAlphanumericLength(str) { 81 return str.length - str.replace(/([a-zA-Z0-9])/g, "").length; 82} 83 84// Validacion formularios. Comprobar campos requeridos 85function _js_www_reset_requeridos (etiqueta_padre) { 86 $("#"+etiqueta_padre+" .js_requerido").removeClass('is-invalid'); 87} 88 89function _js_www_comprobar_requeridos(etiqueta_padre, flag_reset = true){ 90 if (flag_reset) { 91 _js_www_reset_requeridos (etiqueta_padre); 92 } 93 var flag = true; 94 $("#"+etiqueta_padre+" .js_requerido").each(function(){ 95 if ($(this).is(":visible") && ($(this).val() == null || $(this).val().trim() == "" || ($(this).prop('type') == 'checkbox' && $(this).prop('checked') === false))){ 96 flag = false; 97 $(this).addClass('is-invalid'); 98 $("#"+etiqueta_padre).addClass('needs-validation'); 99 } 100 }); 101 return flag; 102} 103 104function _js_www_append_formData(formDataOriginal, formDataAppend) {/* document.getElementById('form_id') */ 105 if (formDataAppend) { 106 let formDataAppend = new FormData(formDataAppend); 107 for (let pair of formDataAppend.entries()) { 108 formDataOriginal.append(pair[0], pair[1]); 109 } 110 } 111} 112 113// Validar DNI - DEVUELVE TRUE O FASLE 114function js_sms_www_checkDni(dni) { 115 var numero, letra, cadena; 116 var expresion_regular_dni = /^[XYZ]?\d{5,8}[A-Z]$/; 117 118 dni = dni.toUpperCase(); 119 120 if(expresion_regular_dni.test(dni) === true){ 121 numero = dni.substr(0,dni.length-1); 122 numero = numero.replace('X', 0); 123 numero = numero.replace('Y', 1); 124 numero = numero.replace('Z', 2); 125 letra = dni.substr(dni.length-1, 1); 126 numero = numero % 23; 127 cadena = 'TRWAGMYFPDXBNJZSQVHLCKET'; 128 cadena = cadena.substring(numero, numero+1); 129 if (cadena != letra) { 130 return false;
131 }else{ 132 return true; 133 } 134 }else{ 135 return false; 136 } 137} 138 139// Activar boostrap tooltip 140function activar_tooltip () { 141 $(function () { 142 $('[data-bs-toggle="tooltip"]').tooltip(); 143 }); 144} 145 146//Mostrar/ocultar contenido de las tarjetas bloque 147$(document).on("click", ".card-desplegable", function(){ 148 $(this).next().toggleClass("d-none"); 149}); 150 151// Mensaje emergente 152function js_sms_www_emergente(tipo = 'info', titulo = 'Información', mensaje = 'Texto de aviso'){ 153 $.toast({ 154 heading: titulo, 155 text: mensaje, 156 position: 'top-center', 157 icon: tipo, 158 hideAfter: 4500 159 }); 160} 161 162function resetInputsModal(modal){ 163 $("#"+modal+" :input").each(function(){ 164 if ($(this).attr('type') != 'button' && $(this).attr('type') != 'submit'){ 165 $(this).val(""); 166 } 167 if ($(this).attr('type') === 'checkbox') { 168 $(this).prop('checked', false); 169 } 170 }); 171} 172 173// Añadir pagina cargando llamadas ajax 174$(document).ajaxSend(function() { 175 $("#recargando_pagina").removeClass("d-none"); 176}); 177$(document).ajaxSuccess(function() { 178 $("#recargando_pagina").addClass("d-none"); 179}); 180$(document).ajaxError(function() { 181 $("#recargando_pagina").addClass("d-none"); 182}); 183 184 185 186function js_www_ajaxForm(url, data, successFunction, errorFunction = "", datatype = "", async = true){ 187 if(errorFunction === "") { 188 errorFunction = (response) => { 189 switch (response.status) { 190 case 401: 191 js_sms_www_emergente("error", "Error", "No autorizado. Por favor, recargue la página."); 192 break; 193 case 419: 194 js_sms_www_emergente("error", "Error", "Tu sesión ha caducado. Recargue la página."); 195 break; 196 default: 197 js_sms_www_emergente("error", "Error", "Error AJAX."); 198 break; 199 } 200 } 201 } 202 203 // Si data es FormData y no tiene el token, lo añadimos 204 if (data instanceof FormData && !data.has('_token')) { 205 data.append('_token', $('meta[name="csrf-token"]').attr('content')); 206 } 207 208 $.ajax({ 209 headers: { 210 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), 211 'X-Requested-With': 'XMLHttpRequest' 212 }, 213 url: url, 214 data: data, 215 type: 'POST', 216 cache: false, 217 enctype: 'multipart/form-data', 218 contentType: false, 219 processData: false, 220 dataType: datatype, 221 async: async, 222 success: successFunction, 223 error: errorFunction 224 }); 225} 226 227function js_www_ajaxBlob(url, data, successFunction, errorFunction = "", datatype = "", async = true){ 228 if(errorFunction === "") { 229 errorFunction = (response) => { 230 switch (response.status) { 231 case 419: 232 js_sms_www_emergente("error", "Error", "Tu sesión ha caducado. Recargue la página."); 233 break; 234 default: 235 js_sms_www_emergente("error", "Error", "Error AJAX."); 236 break; 237 } 238 } 239 } 240 241 $.ajax({ 242 headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, 243 url: url, 244 data: data, 245 type: 'POST', 246 cache: false, 247 enctype: 'multipart/form-data', 248 xhrFields: {responseType: "blob"}, 249 contentType: false, 250 processData: false, 251 datatype: datatype, 252 async: async, 253 success: successFunction, 254 error: errorFunction 255 }); 256} 257 258function js_www_filtrar(url, id_form = "form_filtro") { 259 var formData = new FormData(document.getElementById(id_form)); 260 js_www_ajaxForm(url, formData, 261 (response) => { 262 let obj = JSON.parse(response); 263 if(obj.response === "success") { 264 $("#buscador").html(obj.view); 265 if (typeof activar_tooltip !== "undefined") activar_tooltip(); 266 } 267 else{ 268 js_sms_www_emergente('error', 'ERROR', obj.message); 269 } 270 } 271 ); 272} 273 274function js_sms_www_checkTLF(tlf) { 275var expresion_regular_tlf = /^[+]?\d{5,}$/; 276if(expresion_regular_tlf.test(tlf) === true){ 277 return true; 278}else{ 279 return false;
280} 281} 282 283function js_sms_www_SegundostoHorasMinutos(totalSegundos) { 284 const horas = Math.floor(totalSegundos / 3600); 285 totalSegundos %= 3600; 286 const minutos = Math.floor(totalSegundos / 60); 287 return { 'hora': horas, 'minutos': minutos }; 288} 289 290function minutosToTime(n) { 291 var num = n; 292 var hours = (num / 60); 293 var rhours = Math.floor(hours); 294 var minutes = (hours - rhours) * 60; 295 var rminutes = Math.round(minutes); 296 return rhours + " hora(s) and " + rminutes + " minuto(s)."; 297} 298 299function js_sms_www_secsToHours(totalSegundos) { 300 let horas = Math.floor(totalSegundos / 3600); 301 if(horas < 10) horas = "0" + horas; 302 totalSegundos %= 3600; 303 let segundos = totalSegundos % 60; 304 if(segundos < 10) segundos = "0" + segundos; 305 let minutos = Math.floor(totalSegundos / 60); 306 if(minutos < 10) minutos = "0" + minutos; 307 308 return { 'hora': horas, 'minutos': minutos, 'segundos' : segundos }; 309} 310 311function js_sms_www_LogJavascript(error) { 312 js_www_ajaxBasico("/js/error", 313 { 314 'error': error 315 }, 316 (response) => { 317 let obj = JSON.parse(response); 318 if(obj.response === "success") { 319 js_sms_www_emergente('warning', 'Error JAVASCRIPT registrado en la web.'); 320 } 321 } 322 ); 323} 324 325function js_sms_www_unixToDate(unix_timestamp){ 326 let date = new Date(unix_timestamp * 1000); 327 let dia = date.getDate(); 328 dia = dia.toString().padStart(2, '0'); 329 let mes = date.getMonth() + 1; 330 mes = mes.toString().padStart(2, '0'); 331 let year = date.getFullYear(); 332 return year + '-' + mes + '-' + dia; 333} 334 335function js_sms_www_redirect(url){ window.location.replace(url); } 336 337function checkPassword(){ 338 const password_propuesta = $("#password").val(); 339 _resetMensaje(); 340 if(password_propuesta != ""){ 341 //limpiamos mensajes de errores 342 let flag_tamano = null; 343 let flag_mayusculas = null; 344 let flag_minusculas = null; 345 let flag_caracteres_especiales = null; 346 347 //COMPROBAMOS QUE CUMPLE CON EL NUMERO DE CARACTERES 348 flag_tamano = password_propuesta.length >= 12; 349 350 //COMPROBAMOS QUE CONTENGA AL MENOS UNA MAYUSCULA 351 const patron_mayusculas = /[A-Z]/g; 352 353 flag_mayusculas = !!password_propuesta.match(patron_mayusculas); 354 355 //COMPROBAMOS QUE CONTENGA AL MENOS UNA MINUSCULA 356 const patron_minusculas = /[a-z]/g; 357 358 flag_minusculas = !!password_propuesta.match(patron_minusculas); 359 360 //COMPROBAMOS QUE CONTENGA AL MENOS UN CARACTER ESPECIAL 361 const patron_especial = /[_\W]+/g; 362 363 flag_caracteres_especiales = !!password_propuesta.match(patron_especial); 364 365 let mensaje_error = ''; 366 //mostramos mensajes en el span js_help_passwordUsr 367 if (flag_tamano == false){ 368 mensaje_error += " · La contraseña debe tener al menos 12 caracteres. <br>"; 369 } 370 if (flag_mayusculas == false){ 371 mensaje_error += " · La contraseña debe tener al menos una mayúscula. <br>"; 372 } 373 if (flag_minusculas == false){ 374 mensaje_error += " · La contraseña debe tener al menos una minúscula. <br>"; 375 } 376 if (flag_caracteres_especiales == false){ 377 mensaje_error += " · La contraseña debe tener al menos un carácter especial. <br>"; 378 } 379 380 if (flag_tamano && flag_mayusculas && flag_minusculas && flag_caracteres_especiales){ 381 password_correcta = 1; 382 }else{ 383 password_correcta = 0; 384 _setMensaje('danger', mensaje_error); 385 } 386 } 387} 388 389function _setMensaje(tipo = 'success', mensaje = ''){ 390 let dom__error_msg = $("#error_msg"); 391 $(dom__error_msg).html(mensaje); 392 $(dom__error_msg).removeClass("d-none"); 393 $(dom__error_msg).addClass("alert-"+tipo); 394} 395 396function _resetMensaje(){ 397 $("#error_msg").html(""); 398 $("#error_msg").addClass("d-none"); 399 $("#error_msg").removeClass("alert-success"); 400 $("#error_msg").removeClass("alert-danger"); 401} 402 403function js_sms_print_email(id_email){ 404 js_www_ajaxBasico('/ws/print-email', 405 { 406 'id_email': id_email 407 }, 408 (response) => { 409 let obj = JSON.parse(response); 410 if(obj.response === "success"){ 411 if($("#correo_"+id_email).length > 0){ 412 $("#correo_"+id_email).after(obj.view); 413 $("#correo_"+id_email).remove(); 414 $("#menu_email_"+id_email).remove(); 415 }else{ 416 $("#ver_bandeja_entrada").prepend(obj.view); 417 } 418 $("#correo_"+id_email).addClass("animated"); 419 $("#correo_"+id_email).addClass("flash"); 420 }else if(obj.response === "noshow"){ 421 $("#correo_"+id_email).children().addClass("fondo_naranja_claro"); 422 $("#correo_"+id_email).addClass("efecto_fade_out"); 423 setTimeout(function(){ 424 $("#correo_"+id_email).remove(); 425 $("#menu_email_"+id_email).remove(); 426 }, 3000); 427 }else{ 428 js_sms_www_emergente('danger', 'Error', obj.message); 429 } 430 if(typeof _js_count_emails_pendientes === "function"){ 431 _js_count_emails_pendientes(); 432 } 433 }, "", "", "POST", false 434 ) 435} 436 437function js_sms_mover_email(id_email, contenedor_destino){ 438 js_www_ajaxBasico("/ws/print-email", 439 { 440 'id_email': id_email 441 }, 442 (response) => { 443 let obj = JSON.parse(response); 444 if(obj.response === "success"){ 445 $("#correo_"+id_email).children().addClass((contenedor_destino == 'ver_archivados' || contenedor_destino == 'ver_bandeja_entrada') ? "fondo_verde_claro" : "fondo_naranja_claro"); 446 $("#correo_"+id_email).addClass("efecto_fade_out"); 447 setTimeout(function(){ 448 $("#correo_"+id_email).remove(); 449 $("#menu_email_"+id_email).remove(); 450 $("#"+contenedor_destino).prepend(obj.view); 451 }, 3000); 452 }else{ 453 js_sms_www_emergente('danger', 'Error', obj.message); 454 } 455 if(typeof _js_count_emails_pendientes === "function"){ 456 _js_count_emails_pendientes(); 457 } 458 }, "", "", "POST", false 459 ) 460} 461function js_www_ajaxBasico(url, data, successFunction, errorFunction = "", datatype = "", tipo = 'POST', async = true){ 462 if(errorFunction === "") { 463 errorFunction = (response) => { 464 switch (response.status) { 465 case 419: 466 js_sms_www_emergente("error", "Error", "Tu sesión ha caducado. Recargue la página."); 467 break; 468 default: 469 js_sms_www_emergente("error", "Error", "Error AJAX."); 470 break; 471 } 472 } 473 } 474 475 $.ajax({ 476 headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, 477 url: url, 478 data: data, 479 type: tipo, 480 datatype: datatype, 481 async: async, 482 success: successFunction, 483 error: errorFunction 484 }); 485} 486 487function js_modalConfirmar( 488 title = "Confirmar", 489 text = "Va a proceder a realizar la acción solicitada. ¿Está seguro/a?", 490 confirmButtonText = "Confirmar", 491 cancelButtonText = "Cancelar", 492 confirmButtonClass = "btn btn-success m-2", 493 cancelButtonClass = "btn btn-primary m-2", 494 icon = "warning", 495 input = "", 496 inputAttributes = {}, 497 preConfirm = () => {} 498 ) 499{ 500 501 return Swal.fire({ 502 title, 503 text, 504 icon, 505 showCancelButton: true, 506 confirmButtonText, 507 cancelButtonText, 508 customClass: { 509 confirmButton: confirmButtonClass, 510 cancelButton: cancelButtonClass 511 }, 512 buttonsStyling: false, 513 input: input, 514 inputAttributes: inputAttributes, 515 preConfirm: preConfirm 516 }).then(result => result.isConfirmed); 517}
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.