1window.formatDate = function (timestamp) { 2 var d = new Date(timestamp), 3 yyyy = d.getFullYear(), 4 mm = ('0' + (d.getMonth() + 1)).slice(-2), 5 dd = ('0' + d.getDate()).slice(-2), 6 hh = d.getHours(), 7 h = hh, 8 min = ('0' + d.getMinutes()).slice(-2), 9 ampm = 'AM'; 10 11 if (hh > 12) { 12 h = hh - 12; 13 ampm = 'PM'; 14 } else if (hh === 12) { 15 h = 12; 16 ampm = 'PM'; 17 } else if (hh == 0) { 18 h = 12; 19 } 20 21 return yyyy + '-' + mm + '-' + dd + ', ' + h + ':' + min + ' ' + ampm; 22} 23 24window.VerifyToken = function () { 25 var myInterval; 26 var interval_delay = 5000; 27 var is_interval_running = false; //Optional 28 $(document).ready(function () { 29 $(window).focus(function () { 30 clearInterval(myInterval); // Clearing interval if for some reason it has not been cleared yet 31 if (!is_interval_running) //Optional 32 myInterval = setInterval(interval_function, interval_delay); 33 }).blur(function () { 34 clearInterval(myInterval); // Clearing interval on window blur 35 is_interval_running = false; //Optional 36 }); 37 }); 38 var interval_function = function () { 39 is_interval_running = true; //Optional 40 var token = $("#kay").val(); 41 if (token) { 42 $.ajax({ 43 type: "GET", 44 url: "/verify_token/" + token, 45 dataType: "json", 46 success: function (response) { 47 if (response.valid_token == false) { 48 $('#verify_token').foundation('open'); 49 $("#kay").val(""); 50 } 51 } 52 53 }); 54 } 55 }; 56 $(".refresh-button").on("click", function () { 57 window.location.reload(true); 58 }); 59} 60 61window.CargarCkEditor = function () { 62 class Base64UploadAdapter { 63 constructor(loader) { 64 this.loader = loader; 65 } 66 67 upload() { 68 return this.loader.file 69 .then(file => new Promise((resolve, reject) => { 70 const reader = new FileReader(); 71 72 reader.onload = function () { 73 resolve({ default: reader.result }); 74 }; 75 76 reader.onerror = function (error) { 77 reject(error); 78 }; 79 80 reader.onabort = function () { 81 reject(); 82 }; 83 84 reader.readAsDataURL(file); 85 })); 86 } 87 88 abort() { 89 } 90 } 91 92 class ServerUploadAdapter { 93 constructor(loader) { 94 this.loader = loader; 95 } 96 97 upload() { 98 return this.loader.file 99 .then(file => new Promise((resolve, reject) => { 100 this._initRequest(); 101 this._initListeners(resolve, reject, file); 102 this._sendRequest(file); 103 })); 104 } 105 106 abort() { 107 if (this.xhr) { 108 this.xhr.abort(); 109 } 110 } 111 112 _initRequest() { 113 const xhr = this.xhr = new XMLHttpRequest(); 114 xhr.open('POST', '/ckeditor/pictures', true); 115 xhr.setRequestHeader('X-CSRF-Token', document.querySelector('meta[name="csrf-token"]').getAttribute('content')); 116 xhr.responseType = 'json'; 117 } 118 119 _initListeners(resolve, reject, file) { 120 const xhr = this.xhr; 121 const loader = this.loader; 122 const genericErrorText = `No se pudo subir el archivo: ${file.name}.`; 123 124 xhr.addEventListener('error', () => reject(genericErrorText)); 125 xhr.addEventListener('abort', () => reject()); 126 xhr.addEventListener('load', () => { 127 const response = xhr.response; 128 129 if (!response || response.error) { 130 return reject(response && response.error ? response.error.message : genericErrorText); 131 } 132 133 resolve({ 134 default: response.url 135 }); 136 }); 137 138 if (xhr.upload) { 139 xhr.upload.addEventListener('progress', evt => { 140 if (evt.lengthComputable) { 141 loader.uploadTotal = evt.total; 142 loader.uploaded = evt.loaded; 143 } 144 }); 145 } 146 } 147 148 _sendRequest(file) { 149 const data = new FormData(); 150 data.append('upload', file); 151 this.xhr.send(data); 152 } 153 } 154 155 function CkeditorUploadAdapterPluginBase64(editor) { 156 editor.plugins.get('FileRepository').createUploadAdapter = (loader) => { 157 return new Base64UploadAdapter(loader); 158 }; 159 } 160 161 function CkeditorUploadAdapterPluginServidor(editor) { 162 editor.plugins.get('FileRepository').createUploadAdapter = (loader) => { 163 return new ServerUploadAdapter(loader); 164 }; 165 } 166 167 var allEditors = document.querySelectorAll('.ckeditor5'); 168 169 for (var i = 0; i < allEditors.length; ++i) { 170 ClassicEditor 171 .create(allEditors[i], { 172 extraPlugins: [ 173 allEditors[i].classList.contains("servidor") 174 ? CkeditorUploadAdapterPluginServidor 175 : CkeditorUploadAdapterPluginBase64 176 ], 177 heading: { 178 options: [ 179 { model: 'paragraph', title: 'Párrafo', class: 'ck-heading_paragraph' }, 180 { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' }, 181 { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }, 182 { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' }, 183 { model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4' }, 184 { model: 'heading5', view: 'h5', title: 'Heading 5', class: 'ck-heading_heading5' } 185 ] 186 }, 187 removePlugins: [], 188 toolbar: { 189 items: [ 190 'undo', 'redo', '|', 191 'heading', '|', 192 'fontFamily', 'fontSize', 'fontColor', 'fontBackgroun
192dColor', 'highlight', '|', 193 'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', '|', 194 'alignment', '|', 195 'numberedList', 'bulletedList', '|', 196 'outdent', 'indent', '|', 197 'todoList', 'link', 'imageInsert', 'mediaEmbed', 'blockQuote', '|', 198 'insertTable', 'tableColumn', 'tableRow', 'mergeTableCells', '|', 199 'code', 'codeBlock', 'htmlEmbed', '|', 200 'specialCharacters', 'horizontalLine', 'pageBreak', '|', 201 'findAndReplace', 'selectAll', '|', 202 'textPartLanguage', '|', 203 'sourceEditing' 204 ], 205 shouldNotGroupWhenFull: true 206 }, 207 language: 'es', 208 image: { 209 toolbar: [ 210 'imageTextAlternative', 211 'toggleImageCaption', 212 '|', 213 'imageStyle:inline', 214 'imageStyle:wrapText', 215 'imageStyle:breakText', 216 '|', 217 'resizeImage', 218 '|', 219 'imageInsert' 220 ] 221 }, 222 table: { 223 contentToolbar: [ 224 'tableColumn', 225 'tableRow', 226 'mergeTableCells', 227 'tableCellProperties', 228 'tableProperties' 229 ] 230 }, 231 fontSize: { 232 options: [ 233 'default', 234 9, 11, 13, 17, 19, 21, 27, 35, 235 40, 45, 50, 55, 60, 70, 80, 90, 100 236 ], 237 supportAllValues: true, 238 unit: 'px' 239 }, 240 fontFamily: { 241 options: [ 242 'default', 243 'Arial, Helvetica, sans-serif', 244 'Courier New, Courier, monospace', 245 'Georgia, serif', 246 'Lucida Sans Unicode, Lucida Grande, sans-serif', 247 'Tahoma, Geneva, sans-serif', 248 'Times New Roman, Times, serif', 249 'Trebuchet MS, Helvetica, sans-serif', 250 'Verdana, Geneva, sans-serif' 251 ], 252 supportAllValues: true 253 }, 254 fontColor: { 255 columns: 5, 256 documentColors: 10 257 },
258 fontBackgroundColor: { 259 columns: 5, 260 documentColors: 10 261 }, 262 highlight: { 263 options: [ 264 { model: 'yellowMarker', class: 'marker-yellow', title: 'Amarillo', color: 'var(--ck-highlight-marker-yellow)', type: 'marker' }, 265 { model: 'greenMarker', class: 'marker-green', title: 'Verde', color: 'var(--ck-highlight-marker-green)', type: 'marker' }, 266 { model: 'pinkMarker', class: 'marker-pink', title: 'Rosa', color: 'var(--ck-highlight-marker-pink)', type: 'marker' } 267 ] 268 }, 269 htmlSupport: { 270 allow: [ 271 { 272 name: /.*/, 273 attributes: true, 274 classes: true, 275 styles: true 276 } 277 ] 278 }, 279 link: { 280 decorators: { 281 isExternal: { 282 mode: 'manual', 283 label: 'Open in a new tab', 284 attributes: { 285 target: '_blank' 286 } 287 } 288 } 289 } 290 }) 291 .then(editor => { 292 editor.editing.view.change(writer => { 293 if ($(".editor_tk").length > 0) { 294 writer.setStyle('min-height', '300px !important', editor.editing.view.document.getRoot()); 295 } 296 }); 297 298 editor.model.document.on('change:data', () => { 299 }); 300 301 const clipboard = editor.plugins.get('ClipboardPipeline'); 302 // Preserve CKEditor's native paste pipeline and only strip background styles. 303 clipboard.on('inputTransformation', (evt, data) => { 304 const dataTransfer = data.dataTransfer; 305 306 if (!dataTransfer || (dataTransfer.files && dataTransfer.files.length > 0) || !data.content) { 307 return; 308 } 309 310 editor.editing.view.change(writer => { 311 const removeBackgroundColor = (element) => { 312 if (element.is('element')) { 313 writer.removeStyle('background-color', element); 314 writer.removeStyle('background', element); 315 } 316 317 if (element.is('element') || element.is('documentFragment')) { 318 for (const child of element.getChildren()) { 319 removeBackgroundColor(child); 320 } 321 } 322 }; 323 324 removeBackgroundColor(data.content); 325 }); 326 }); 327 328 editor.on('afterUndoImage', function () { 329 alert("123"); 330 }); 331 332 editor.on('afterCommandExec', function () { 333 alert("222"); 334 }); 335 336 console.log(editor); 337 }) 338 .catch(error => { 339 console.error(error); 340 }); 341 } 342} 343 344window.EventoOcultarLocationDevice = function () { 345 $(".direccion_devices").unbind().on("change", function () { 346 var direccion = $(this).val() 347 if (direccion == "EMPRESA") { 348 $(this).parent().parent().find(".employee_devices").removeClass("large-4"); 349 $(this).parent().parent().find(".employee_devices").addClass("large-2"); 350 $(this).parent().parent().find(".location_devices").removeClass("hide"); 351 } else { 352 $(this).parent().parent().find(".location_devices").addClass("hide"); 353 $(this).parent().parent().find(".employee_devices").removeClass("large-2"); 354 $(this).parent().parent().find(".employee_devices").addClass("large-4"); 355 } 356 }) 357} 358 359window.imageToBlob = function (imageURL) { 360 const img = new Image; 361 const c = document.createElement("canvas"); 362 const ctx = c.getContext("2d"); 363 img.crossOrigin = ""; 364 img.src = imageURL; 365 return new Promise(resolve => { 366 img.onload = function () {
367 c.width = this.naturalWidth; 368 c.height = this.naturalHeight; 369 ctx.drawImage(this, 0, 0); 370 c.toBlob((blob) => { 371 // here the image is a blob 372 resolve(blob) 373 }, "image/png", 0.75); 374 }; 375 }) 376} 377 378window.VerImagenModal = function () { 379 $(".copiar-imagen").unbind().on("click", async function (e) { 380 try { 381 e.preventDefault(); 382 var _this = $(this); 383 var src = $(this).data("url"); 384 var img = new Image(); 385 img.src = src; 386 var text = '<img src=" ' + img.src + '" />'; 387 //const blob = await imageToBlob(src) 388 var type = "text/html"; 389 var blob = new Blob([text], { type }); 390 var data = [new ClipboardItem({ [type]: blob })]; 391 //const item = new window.ClipboardItem({ "text/html": src }); 392 navigator.clipboard.write(data); 393 _this.html("<i class='fa fa-check-circle'></i> Copiado") 394 setTimeout(function () { 395 _this.html("<i class='fa fa-clipboard'></i>") 396 }, 3000) 397 } catch (e) { 398 399 } 400 401 }) 402 $(".ver-imagen").unbind().on("click", function (e) { 403 var src = $(this).data("url"); 404 $("#preview-imagen").find('.loading').show(); 405 $("#preview-imagen").find("img").prop('src', ""); 406 $("#preview-imagen").foundation('open'); 407 var img = new Image(); 408 img.src = src; 409 img.onload = function () { 410 $("#preview-imagen").find("img").prop('src', img.src); 411 $("#preview-imagen").find('.loading').hide(); 412 } 413 e.preventDefault(); 414 }) 415 $(".ver-pdf").unbind().on("click", function (e) { 416 var src = $(this).data("url"); 417 var name = $(this).data("nombre"); 418 $("#preview-pdf").find(".force_download").attr("data-nombre", name) 419 $("#preview-pdf").find(".force_download").attr("data-url", src) 420 $("#preview-pdf").foundation('open') 421 render_all_pdf(src) 422 e.preventDefault(); 423 }) 424 $("iframe#preview-document-iframe").unbind().on("load", function () { 425 $("iframe#preview-document-iframe").show() 426 $("#preview-pdf").find(".loading").hide(); 427 }); 428} 429 430window.loadAttachmentsOld = function (token, employee = false, tipo = null) { 431 console.log("Iniciando loadAttachments con:", { token, employee, tipo }); 432 433 // Utilidad para prevenir reinicialización de componentes Foundation 434 function safeFoundation() { 435 // Guarda el método original de Foundation 436 var originalFoundationPlugin = $.fn.foundation; 437 438 // Reemplaza temporalmente el método para evitar re-inicializaciones 439 $.fn.foundation = function (plugin) { 440 if (this.data(plugin)) { 441 return this; 442 } 443 return originalFoundationPlugin.apply(this, arguments); 444 }; 445 446 // Inicializa Foundation 447 $(document).foundation(); 448 449 // Restaura el método original 450 $.fn.foundation = originalFoundationPlugin; 451 452 // Ejecutar solo VerImagenModal si está definida 453 if (typeof VerImagenModal === 'function') { 454 VerImagenModal(); 455 } 456 } 457 458 459 if (employee) { 460 var tipos = ["documento-identidad", "curriculum", "antecedente-policial-penal", "consulta-deuda", "competencia", "acuerdo-confidencialidad", "contrato-trabajo"]; 461 462 for (var i = 0; i < tipos.length; i++) { 463 var tipo = tipos[i]; 464 console.log("Procesando tipo:", tipo); 465 466 var authSelector = $('#authenticity_token_' + token + "_" + tipo); 467 var modeloSelector = $('#modelo_' + token + "_" + tipo); 468 var dropZoneSelector = $('#drop-zone-attachments_' + token + "_" + tipo); 469 470 471 var authenticity_token = authSelector.val(); 472 var modelo = modeloSelector.val(); 473 var modelo_token = token; 474 475 dropZoneSelector.attr("authenticity_token", authenticity_token); 476 477 // Verificar si hay una instancia previa 478 479 try { 480 dropZoneSelector.filePicker({ 481 url: '/attachments/upload', 482 data: { 483 "authenticity_token": authenticity_token, 484 "modelo": modelo, 485 "modelo_token": modelo_token, 486 "tipo": tipo 487 }, 488 dropZone: $('.drop-aqui-' + modelo_token + "_" + tipo), 489 dropWindow: '.drop-windows', 490 autoLoad: true, 491 acceptFileTypes: /(\.|\/)(pdf|gif|jpe?g|png|doc|docx|xl
491s|xlsx|zip|txt|xml|json)$/i, 492 maxFileSize: 10485760, //(= 10MB) 493 plugins: ['ui', 'drop', 'crop'], 494 messages: { 495 uploadFallback: 'El navegador no soporta subir archivos.', 496 minFileSize: 'El archivo no debe ser menor a :min KB.', 497 maxFileSize: 'El archivo no debe ser mayor a 10MB', 498 postMaxSize: 'El archivo excede el lÃmite de tamaño máximo de :max MB.', 499 invalidFileType: 'El tipo de archivo no está soportado. Formatos permitidos: PDF, JPEG, PNG, GIF, DOC, XLS, ZIP, TXT, XML, JSON.', 500 error: 'Oops! Ocurrio un error.', 501 abort: 'La operación fue abortada.', 502 processing: 'Procesando...', 503 deleteFail: 'No se puede eliminar :file.', 504 }, 505 ui: { 506 perPage: 50, // Aumentar para asegurar que todos los archivos se muestren 507 autoLoad: true, 508 selectors: { 509 filesList: '.files-' + modelo_token + "_" + tipo 510 } 511 }, 512 crop: { 513 container: $('.crop-container') 514 } 515 }).on('done.filepicker', function (e, data) { 516 console.log("Upload completado:", data); 517 518 if (data.files && data.files.length > 0 && data.files[0].tipo) { 519 var filesList = $('#files-' + data.files[0].modelo_token + "_" + data.files[0].tipo); 520 if (filesList.length) { 521 filesList.find(".download-template").each(function (i, tr) { 522 if ($(tr).attr("name") == data.files[0].name) { 523 $(tr).remove(); 524 } 525 }); 526 } else { 527 console.warn("No se encontró el elemento para la lista de archivos:", '.files-' + data.files[0].modelo_token + "_" + data.files[0].tipo); 528 } 529 } 530 }).on('renderdone.filepicker', function (e, data) { 531 console.log("Render completado:", data); 532 safeFoundation(); 533 }).on('fail.filepicker', function (e, data) { 534 console.error("Error en filepicker:", data); 535 var errorMsg = "No se pudieron cargar los documentos, intente más tarde."; 536 if (data.xhr) { 537 if (data.xhr.responseJSON) { 538 errorMsg = data.xhr.responseJSON.error || data.xhr.responseJSON; 539 } else if (data.xhr.responseText) { 540 try { 541 var json = JSON.parse(data.xhr.responseText); 542 errorMsg = json.error || json; 543 } catch (e) { 544 console.warn("ResponseText is not JSON", data.xhr.responseText); 545 } 546 } else if (data.xhr.status === 413) { 547 errorMsg = "El archivo es demasiado grande. Intente comprimirlo o reduzca su tamaño."; 548 } else if (data.xhr.statusText) { 549 errorMsg = "Error del servidor: " + data.xhr.statusText; 550 } 551 } else if (data.message) { 552 errorMsg += " Error: " + data.message; 553 } 554 alert(errorMsg); 555 }).on('load.filepicker', function (e, data) { 556 console.log("Carga de archivos iniciada:", data); 557 }).on('loaddone.filepicker', function (e, data) { 558 console.log("Carga de archivos completada:", data); 559 560 if (data.files && data.files.length === 0) { 561 console.warn("No se encontraron archivos para mostrar en " + tipo); 562 } else if (data.files && data.files.length > 0) { 563 console.log(`Se encontraron ${data.files.length} archivos para mostrar en ${tipo}`); 564 var filesContainer = $('.files-' + modelo_token + "_" + tipo); 565 checkAndRenderFiles(filesContainer, dropZoneSelector, tipo, token); 566 } 567 }).on('delete.filepicker', function (e, data) { 568 data.token = data.token_file; 569 }).on('deletedone.filepicker', function (e, data) { 570 console.log("Archivo eliminado:", data); 571 }).on('deleteall.filepicker', function (e) { 572 if (!confirm("Está seguro de eliminar TODOS los archivos?, esta acción no se puede deshacer.")) { 573 return false;
574 } 575 }); 576 } catch (e) { 577 console.error("Error al inicializar FilePicker para tipo " + tipo + ":", e); 578 } 579 } 580 } else { 581 console.log("Procesando sin employee, tipo:", tipo); 582 var suffix = tipo ? ("_" + tipo) : ""; 583 584 var authSelector = $('#authenticity_token_' + token + suffix); 585 var modeloSelector = $('#modelo_' + token + suffix); 586 var dropZoneSelector = $('#drop-zone-attachments_' + token + suffix); 587 588 if (!authSelector.length || !modeloSelector.length || !dropZoneSelector.length) { 589 console.error("No se encontraron selectores necesarios:", { 590 auth: authSelector.length, 591 modelo: modeloSelector.length, 592 dropZone: dropZoneSelector.length 593 }); 594 return; // Salir si faltan selectores 595 } 596 597 var authenticity_token = authSelector.val(); 598 var modelo = modeloSelector.val(); 599 var modelo_token = token; 600 601 dropZoneSelector.attr("authenticity_token", authenticity_token); 602 603 // Verificar si hay una instancia previa 604 if (dropZoneSelector.data('filePicker')) { 605 console.log(`FilePicker ya inicializado, reinicializando...`); 606 try { 607 dropZoneSelector.filePicker('destroy'); 608 } catch (e) { 609 console.error("Error al destruir instancia previa:", e); 610 } 611 } 612 613 try { 614 dropZoneSelector.filePicker({ 615 url: '/attachments/upload', 616 data: function () { 617 return { 618 "authenticity_token": authenticity_token, 619 "modelo": modelo, 620 "modelo_token": modelo_token, 621 "tipo": tipo 622 } 623 }, 624 dropZone: $('.drop-aqui-' + modelo_token + suffix), 625 dropWindow: '.drop-windows', 626 autoLoad: true, 627 acceptFileTypes: /(\.|\/)(pdf|gif|jpe?g|png|doc|docx|xls|xlsx|zip|txt|xml|json)$/i, 628 maxFileSize: 10485760, //(= 10MB) 629 plugins: ['ui', 'drop', 'crop'], 630 messages: { 631 uploadFallback: 'El navegador no soporta subir archivos.', 632 minFileSize: 'El archivo no debe ser menor a :min KB.', 633 maxFileSize: 'El archivo no debe ser mayor a 10MB', 634 postMaxSize: 'El archivo excede el lÃmite de tamaño máximo de :max MB.', 635 invalidFileType: 'El tipo de archivo no está soportado. Formatos permitidos: PDF, JPEG, PNG, GIF, DOC, XLS, ZIP, TXT, XML, JSON.', 636 error: 'Oops! Ocurrio un error.', 637 abort: 'La operación fue abortada.', 638 processing: 'Procesando...', 639 deleteFail: 'No se puede eliminar :file.', 640 }, 641 ui: { 642 perPage: 50, // Aumentar para asegurar que todos los archivos se muestren 643 autoLoad: true, 644 selectors: { 645 filesList: '.files-' + modelo_token + suffix 646 } 647 }, 648 crop: { 649 container: $('.crop-container') 650 } 651 }).on('done.filepicker', function (e, data) { 652 console.log("Upload completado:", data); 653 }).on('renderdone.filepicker', function (e, data) { 654 console.log("Render completado:", data); 655 safeFoundation(); 656 }).on('fail.filepicker', function (e, data) { 657 console.error("Error en filepicker:", data); 658 alert("No se pudieron cargar los documentos, intente más tarde. Error: " + (data.message || "Desconocido")); 659 }).on('load.filepicker', function (e, data) { 660 console.log("Carga de archivos iniciada:", data); 661 }).on('loaddone.filepicker', function (e, data) { 662 console.log("Carga de archivos completada:", data); 663 664 if (data.files && data.files.length === 0) { 665 console.warn("No se encontraron archivos para mostrar"); 666 } else if (data.files && data.files.length > 0) { 667 console.log(`Se encontraron ${data.files.length} archivos para mostrar`); 668 var filesContainer = $('.files-' + modelo_token + suffix); 669 checkAndRenderFiles(filesContainer, dropZoneSelector, tipo, token); 670 } 671 }).on('delete.filepicker', function (e, data) { 672 data.token = data.token_file; 673 }).on('deletedone.filepicker', function (e, data) { 674 console.log("Archivo eliminado:", data); 675 }).on('deleteall.filepicker', function (e) { 676 if (!confirm("Está seguro de eliminar TODOS los archivos?, esta acción no se puede deshacer.")) { 677 return false;
678 } 679 }); 680 } catch (e) { 681 console.error("Error al inicializar FilePicker:", e); 682 } 683 } 684} 685 686window.loadAttachments = function (token, employee = false, tipo = null) { 687 688 $('.filepickerInstance').each(function () { 689 const instance = $(this).data('filePicker'); 690 if (instance) { 691 instance.destroy(); 692 $(this).removeData('filePicker'); 693 } 694 }); 695 if (employee) { 696 var tipos = ["documento-identidad", "curriculum", "antecedente-policial-penal", "consulta-deuda", "competencia", "acuerdo-confidencialidad", "contrato-trabajo", "documentos-baja", "otros-archivos"] 697 for (var i = 0; i <= tipos.length - 1; i++) { 698 var tipo = tipos[i] 699 console.log(tipo) 700 var authenticity_token = $('#authenticity_token_' + token + "_" + tipo).val(); 701 var modelo = $('#modelo_' + token + "_" + tipo).val(); 702 var modelo_token = token; 703 704 //$('#drop-zone-attachments_' + token + "_" + tipo).find('input[type="file"]').addClass(`fileinput-${modelo_token}_${tipo}`); 705 706 $('#drop-zone-attachments_' + token + "_" + tipo).attr("authenticity_token", authenticity_token) 707 try { 708 var $dropZone = $('#drop-zone-attachments_' + token + "_" + tipo); 709 if ($dropZone.data('filePicker')) { 710 $dropZone.filePicker('destroy'); 711 } 712 $dropZone.off('.filepicker'); 713 714 $dropZone.filePicker({ 715 url: '/attachments/upload', 716 data: { 717 718 "authenticity_token": authenticity_token, 719 "modelo": modelo, 720 "modelo_token": modelo_token, 721 "tipo": tipo 722 723 }, 724 dropZone: $('.drop-aqui-' + modelo_token + "_" + tipo), 725 dropWindow: '.drop-windows', 726 autoLoad: true, 727 acceptFileTypes: /(\.|\/)(pdf|gif|jpe?g|png|doc|docx|xls|xlsx|zip|txt|xml|json)$/i, 728 maxFileSize: 10485760, //(= 10MB) 729 plugins: ['ui', 'drop', 'crop'], 730 messages: { 731 uploadFallback: 'El navegador no soporta subir archivos.', 732 minFileSize: 'El archivo no debe ser menor a :min KB.', 733 maxFileSize: 'El archivo no debe ser mayor a 10MB', 734 postMaxSize: 'El archivo excede el lÃmite de tamaño máximo de :max MB.', 735 postMaxSize: 'El archivo excede el lÃmite de tamaño máximo de :max MB.', 736 invalidFileType: 'El tipo de archivo no está soportado.', 737 error: 'Oops! Ocurrio un error.', 738 abort: 'La operación fue abortada.', 739 // UI plugin 740 processing: 'Procesando...', 741 deleteFail: 'No se puede eliminar :file.', 742 }, 743 ui: { 744 perPage: 20, 745 autoLoad: true, 746 747 }, 748 crop: { 749 container: $('.crop-container') 750 } 751 }).on('done.filepicker', function (e, data) { 752 if (tipo) { 753 $('#files-' + data.files[0].modelo_token + "_" + data.files[0].tipo).find(".download-template").each(function (i, tr) { 754 console.log($(tr)) 755 if ($(tr).attr("name") == data.files[0].name) { 756 $(tr).remove() 757 } 758 }) 759 } 760 }).on('renderdone.filepicker', function (e, data) { 761 $(document).foundation(); 762 VerImagenModal(); 763 764 }).on('fail.filepicker', function (e, data) { 765 console.log(data) 766 alert("No se pudieron cargar los documentos, intente mas tarde") 767 }).on('delete.filepicker', function (e, data) { 768 data.token = data.token_file 769 }).on('deletedone.filepicker', function (e, data) { 770 771 }).on('deleteall.filepicker', function (e) { 772 if (!confirm("Está seguro de eliminar TODOS los archivos?, esta acción no se puede deshacer.")) { 773 return false;
774 } 775 }); 776 } catch (e) { 777 778 } 779 } 780 } else { 781 console.log(tipo) 782 783 var authenticity_token = $('#authenticity_token_' + token + (tipo ? ("_" + tipo) : "")).val(); 784 var modelo = $('#modelo_' + token + (tipo ? ("_" + tipo) : "")).val(); 785 var modelo_token = token; 786 $('#drop-zone-attachments_' + token + (tipo ? ("_" + tipo) : "")).attr("authenticity_token", authenticity_token) 787 //$('#drop-zone-attachments_' + token + (tipo ? ("_" + tipo) : "")).find('input[type="file"]').addClass(`fileinput-${modelo_token}${(tipo ? ("_" + tipo) : "")}`); 788 789 try { 790 var $dropZone = $('#drop-zone-attachments_' + token + (tipo ? ("_" + tipo) : "")); 791 if ($dropZone.data('filePicker')) { 792 $dropZone.filePicker('destroy'); 793 } 794 $dropZone.off('.filepicker'); 795 796 $dropZone.filePicker({ 797 url: '/attachments/upload', 798 data: function () { 799 return { 800 "authenticity_token": authenticity_token, 801 "modelo": modelo, 802 "modelo_token": modelo_token, 803 "tipo": tipo 804 } 805 }, 806 dropZone: $('.drop-aqui-' + modelo_token + (tipo ? ("_" + tipo) : "")), 807 dropWindow: '.drop-windows', 808 autoLoad: true, 809 acceptFileTypes: /(\.|\/)(pdf|gif|jpe?g|png|doc|docx|xls|xlsx|zip|txt|xml|json)$/i, 810 maxFileSize: 10485760, //(= 10MB) 811 plugins: ['ui', 'drop', 'crop'], 812 messages: { 813 uploadFallback: 'El navegador no soporta subir archivos.', 814 minFileSize: 'El archivo no debe ser menor a :min KB.', 815 maxFileSize: 'El archivo no debe ser mayor a 10MB', 816 postMaxSize: 'El archivo excede el lÃmite de tamaño máximo de :max MB.', 817 postMaxSize: 'El archivo excede el lÃmite de tamaño máximo de :max MB.', 818 invalidFileType: 'El tipo de archivo no está soportado.', 819 error: 'Oops! Ocurrio un error.', 820 abort: 'La operación fue abortada.', 821 // UI plugin 822 processing: 'Procesando...', 823 deleteFail: 'No se puede eliminar :file.', 824 }, 825 ui: { 826 perPage: 20, 827 autoLoad: true, 828 selectors: { 829 830 } 831 }, 832 crop: { 833 container: $('.crop-container') 834 } 835 }).on('done.filepicker', function (e, data) { 836 console.log("done") 837 }).on('renderdone.filepicker', function (e, data) { 838 $(document).foundation(); 839 VerImagenModal(); 840 console.log("renderdone") 841 }).on('fail.filepicker', function (e, data) { 842 console.log(data) 843 var errorMsg = "No se pudieron cargar los documentos, intente mas tarde"; 844 if (data.xhr && data.xhr.responseJSON) { 845 errorMsg = data.xhr.responseJSON.error || data.xhr.responseJSON; 846 } else if (data.xhr && data.xhr.status === 413) { 847 errorMsg = "El archivo es demasiado grande. Intente comprimirlo o reduzca su tamaño."; 848 } else if (data.xhr && data.xhr.statusText) { 849 errorMsg = "Error del servidor: " + data.xhr.statusText; 850 } 851 alert(errorMsg) 852 }).on('delete.filepicker', function (e, data) { 853 data.token = data.token_file 854 }).on('deletedone.filepicker', function (e, data) { 855 856 }).on('deleteall.filepicker', function (e) { 857 if (!confirm("Está seguro de eliminar TODOS los archivos?, esta acción no se puede deshacer.")) { 858 return false; 859 } 860 }); 861 } catch (e) { 862 863 } 864 } 865 866 867} 868 869window.BindModalDescripTicket = function () { 870 $("#cerrar_modal_descripcion_ticket").unbind().on("click", function () { 871 $('#modal_ver_descripcion').foundation('close'); 872 $('#modal_ver_descripcion').html('') 873 }); 874 875} 876 877$(function () { 878 view_password(); 879 $("#view_password").click(view_password); 880}); 881 882function view_password() { 883 if ($('#view_password').is(':checked')) { 884 $('.password').attr('type', 'text'); 885 } else { 886 $('.password').attr('type', 'password'); 887 } 888} 889 890window.openShowModal = function (t, funcOK) { 891 $.ajax(t).done(function (t) { 892 $("#show").html(t).foundation("open") 893 funcOK(); 894 }); 895} 896 897window.SelectNested = function () { 898 $("select.faq_service").on("change", function () { 899 900 var id = $(this).val(); 901 var name = "input#" + $(this).attr("id").toString().replace("service_id", "faq_category_id") 902 $(name).find('option').remove(); 903 $(name).val(0);
904 $(name).attr("term", 0) 905 $(name).attr("condicional", id) 906 SelectTwoAjax(); 907 908 }); 909} 910 911window.ValidateEmail = function (input) { 912 const validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; 913 return validRegex.test(input); 914} 915 916window.SelectTwo = function () { 917 918 $('select.select2').select2({ 919 placeholder: "Buscar", 920 placeholder: function () { 921 $(this).data('placeholder'); 922 }, 923 allowClear: true, 924 minimumResultsForSearch: 0 925 }) 926}; 927 928var currgeocoder; 929 930window.getLocation = function () { 931 932 function successLocation(position) { 933 //console.log("entro:") 934 var geo_loc = processGeolocationResult(position); 935 var currLatLong = geo_loc.split(","); 936 initializeCurrent(currLatLong[0], currLatLong[1]); 937 } 938 939 function errorLocation(error) { 940 var html = ""; 941 if (error.code == 1) 942 html = (`Error: <br>Codigo: ${error.code} - La geolocalización falló porque la página no tiene permiso para hacerlo. Por favor habilitalo`) 943 else if (error.code == 2) 944 html = (`Error: <br>Codigo: ${error.code} - La geolocalización falló. Por favor verifica que tienes activado tu GPS y con permisos para YANAPA`) 945 else if (error.code == 3) 946 html = (`Error: <br>Codigo: ${error.code} - El tiempo de esperá alcanzado (Timeout). Reintenta (RECARGANDO LA PÃGINA) y si el error persiste comunicate con SOPORTE`) 947 else 948 html = ("Ocurrió un error no DOCUMENTADO, consulta con SOPORTE") 949 950 if (error.code == 1 || error.code == 2) { 951 document.cookie = "lt=" + btoa(0); 952 document.cookie = "ln=" + btoa(0); 953 } 954 $("#message_marcar").html(html) 955 $(".validate_lat_row").html(`<div class="large-4 medium-4 large-centered medium-centered columns"> 956 <div class="callout warning text-center bold red">${html} 957 </div> 958 </div>`) 959 960 $("#solicitar_auth").addClass("hide"); 961 $(".load_lat").addClass("hide"); 962 } 963 964 //Set geo location of lat and long 965 $("#solicitar_auth").addClass("hide"); 966 if (navigator.geolocation) { 967 968 $(".load_lat").removeClass("hide"); 969 navigator.geolocation.getCurrentPosition(successLocation, errorLocation, { 970 timeout: 45000, 971 enableHighAccuracy: true, 972 }); 973 navigator.geolocation.watchPosition(successLocation); 974 975 976 } else { 977 $("#message_marcar").text("DEBE ACTIVAR LA LOCALIZACIÃN") 978 $("#solicitar_auth").addClass("hide"); 979 $(".load_lat").addClass("hide"); 980 } 981 982 983 //Get geo location result 984 985 function processGeolocationResult(position) { 986 var html5Lat = position.coords.latitude; //Get latitude 987 var html5Lon = position.coords.longitude; //Get longitude 988 var html5TimeStamp = position.timestamp; //Get timestamp 989 var html5Accuracy = position.coords.accuracy; //Get accuracy in meters 990 return (html5Lat).toFixed(8) + ", " + (html5Lon).toFixed(8); 991 } 992 993 //Check value is present or not & call google api function 994 995 function initializeCurrent(latcurr, longcurr) { 996 997 //currgeocoder = new google.maps.Geocoder(); 998 //console.log(latcurr + "-- ######## --" + longcurr); 999 $(".load_lat").addClass("hide"); 1000 if (latcurr != '' && longcurr != '') { 1001 document.cookie = "lt=" + btoa(latcurr); 1002 document.cookie = "ln=" + btoa(longcurr); 1003 var metro = distance(parseFloat($(".geo-lat").val()), parseFloat($(".geo-lon").val()), latcurr, longcurr); 1004 //console.log(metro) 1005 $(".validar_lat").removeClass("hide"); 1006 1007 1008 } 1009 } 1010 1011 1012} 1013 1014function get_cookie(name) { 1015 var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); 1016 if (match) { 1017 return match[2]; 1018 } else { 1019 return null 1020 } 1021} 1022 1023function distance(lat1, lon1, lat2, lon2, unit) { 1024 if ((lat1 == lat2) && (lon1 == lon2)) { 1025 return 0; 1026 } else { 1027 var radlat1 = Math.PI * lat1 / 180; 1028 var radlat2 = Math.PI * lat2 / 180; 1029 var theta = lon1 - lon2; 1030 var radtheta = Math.PI * theta / 180; 1031 var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.
1031cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta); 1032 if (dist > 1) { 1033 dist = 1; 1034 } 1035 dist = Math.acos(dist); 1036 dist = dist * 180 / Math.PI; 1037 dist = dist * 60 * 1.1515; 1038 if (unit == "K") { 1039 dist = dist * 1.609344 1040 } 1041 if (unit == "N") { 1042 dist = dist * 0.8684 1043 } 1044 return dist; 1045 } 1046} 1047 1048window.SelectTwoAjax = function () { 1049 1050 $('.select2-ajax').each(function () { 1051 var controller = $(this).attr("controller"); 1052 var key = $(this).attr("key"); 1053 var tipo = $(this).attr("tipo"); 1054 // condicional es para alguna condición que se necesite 1055 var condicional = $(this).attr("condicional"); 1056 1057 $(this).select2({ 1058 placeholder: "Buscar " + tipo, 1059 initSelection: function (element, callback) { 1060 return $.ajax({ 1061 url: "/" + controller + "/find_ajax.json", 1062 dataType: 'json', 1063 data: { 1064 term: $(element).val(), 1065 key: key, 1066 condicional: condicional 1067 }, 1068 success: function (data) { 1069 } 1070 }).done(function (data) { 1071 return callback(data); 1072 }); 1073 }, 1074 formatNoMatches: function () { 1075 return 'No existe'; 1076 }, 1077 formatSearching: function () { 1078 return 'Buscando...'; 1079 }, 1080 formatInputTooShort: function () { 1081 return "Ingresa 1 letra"; 1082 }, 1083 id: function (object) { 1084 if (key == "key") { 1085 return object.key; 1086 } else if (key == "id") { 1087 return object.id; 1088 } else if (key == "codigo") { 1089 return object.codigo; 1090 } else if (key == "token") { 1091 return object.token; 1092 } 1093 }, 1094 minimumInputLength: 1, 1095 ajax: { 1096 url: "/" + controller + "/all_ajax.json", 1097 dataType: 'json', 1098 quietMillis: 300, 1099 data: function (search) { 1100 return { 1101 term: search, 1102 key: key, 1103 condicional: condicional 1104 }; 1105 }, 1106 results: function (data) { 1107 return { results: data.all_ajax }; 1108 } 1109 }, 1110 formatResult: searchFormatResult, 1111 formatSelection: searchFormatSelection, 1112 dropdownCssClass: "bigdrop" 1113 }).on("select2-opening", function () { 1114 1115 }); 1116 1117 function searchFormatResult(all) { 1118 return (all.full); 1119 } 1120 1121 function searchFormatSelection(all) { 1122 return (all.full); 1123 } 1124 }); 1125} 1126 1127window.EventoNumeroReunionCircle = function () { 1128 $(".get_google_meet_circle").unbind().on("change", function () { 1129 var selects = document.querySelectorAll("select.get_google_meet_circle") 1130 var code = [] 1131 selects.forEach(function (e) { 1132 code.push($(e).val()) 1133 }) 1134 1135 var codigo = $("#meeting_codigo").val(); 1136 $.ajax({ 1137 url: "/meetings/get_google_meet_circle", 1138 type: "POST", 1139 data: { 1140 circles_code: code.join(","), 1141 codigo: codigo 1142 }, 1143 success: function (e) { 1144 if (e.success) { 1145 //$("#meeting_google_meet").val(e.google_meet); 1146 if (e.codigo) 1147 $("#proximo-numero-meeting").text("Número de reunión: " + e.numero_reunion); 1148 else 1149 $("#proximo-numero-meeting").text(""); 1150 } 1151 }, 1152 error: function (e) { 1153 1154 } 1155 }) 1156 }); 1157} 1158 1159window.markjs = function () { 1160 1161 // Read the keyword 1162 var keyword = []; 1163 $(".mark_search").each(function () { 1164 if ($(this).hasClass("select2-ajax")) { 1165 var value = $(this).select2('data'); 1166 if (value) { 1167 for (var i = 0; i <= value.full.split(" ").length - 1; i++) { 1168 if (value.full.split(" ")[i]) 1169 keyword.push(value.full.split(" ")[i]) 1170 } 1171 } 1172 1173 } else if ($(this).hasClass("select2")) { 1174 var value = $(this).select2('data'); 1175 if (value) { 1176 for (var i = 0; i <= value.text.split(" ").length - 1; i++) { 1177 if (value.text.split(" ")[i]) 1178 keyword.push(value.text.split(" ")[i]) 1179 } 1180 } 1181 1182 } else { 1183 var value = $(this).val(); 1184 if (value) { 1185 keyword.push(value) 1186 } 1187 } 1188 1189 1190 }) 1191
1192 if (keyword == null || keyword == "") { 1193 1194 keyword = new URLSearchParams(window.location.search).get('search') 1195 } 1196 // Determine selected options 1197 var options = {}; 1198 1199 var context = document.querySelector(".markjs"); 1200 if (context) { 1201 var instance = new Mark(context); 1202 instance.unmark() 1203 if (keyword) { 1204 instance.mark(keyword, { 1205 accuracy: "partially" 1206 }); 1207 } 1208 1209 } 1210 1211 1212}; 1213 1214window.ConsultarRucEvents = function () { 1215 $(".consultar_ruc").unbind().on('click', function () { 1216 this_form = $(this).parents("form"); 1217 var _this = $(this); 1218 var numero_doc = $('.estract_this_ruc').val(); 1219 var nombre_class = _this.data("target-nombre"); 1220 var tipo_class = _this.data("target-tipo"); 1221 var dir_class = _this.data("target-direccion"); 1222 var dep_class = _this.data("target-departamento"); 1223 var pro_class = _this.data("target-provincia"); 1224 var dis_class = _this.data("target-distrito"); 1225 1226 consultar_ruc(this_form, numero_doc, 1227 tipo_class ? "." + tipo_class : "", 1228 "." + nombre_class, 1229 dir_class ? "." + dir_class : "", 1230 dep_class ? "." + dep_class : "", 1231 pro_class ? "." + pro_class : "", 1232 dis_class ? "." + dis_class : "") 1233 1234 }); 1235} 1236 1237window.ExtraerRuc = function () { 1238 $('.estract_this_ruc').on('keyup input load', function () { 1239 var target_tipo = $(this).data("target-tipo") 1240 var target_nombre = $(this).data("target-nombre") 1241 var target_direccion = $(this).data("target-direccion") 1242 var target_departamento = $(this).data("target-departamento") 1243 var target_provincia = $(this).data("target-provincia") 1244 var target_distrito = $(this).data("target-distrito") 1245 estract_this_ruc = $('.estract_this_ruc').val() || 0; 1246 if (estract_this_ruc.length > 0) { 1247 if (ruc_verify(estract_this_ruc)) { 1248 $("#modal-extraer-documento").foundation('open'); 1249 $("#extraer-ruc").addClass("consultar_ruc"); 1250 $("#extraer-ruc").data("target-tipo", target_tipo) 1251 $("#extraer-ruc").data("target-nombre", target_nombre) 1252 $("#extraer-ruc").data("target-direccion", target_direccion) 1253 $("#extraer-ruc").data("target-departamento", target_departamento) 1254 $("#extraer-ruc").data("target-provincia", target_provincia) 1255 $("#extraer-ruc").data("target-distrito", target_distrito) 1256 $("#tipo-extraer").text("Ingresaste un RUC, deseas importar los datos desde SUNAT?") 1257 ConsultarRucEvents(); 1258 1259 1260 $('.ruc_error').hide(); 1261 $('.ruc_correct').show(); 1262 $('.estract_this_ruc').removeClass('with_error'); 1263 $('.estract_this_ruc_button').removeAttr('disabled'); 1264 } else { 1265 $('.ruc_error').show(); 1266 $('.ruc_correct').hide(); 1267 $('.estract_this_ruc').addClass('with_error'); 1268 $('.estract_this_ruc_button').prop('disabled', 'disabled'); 1269 } 1270 } else { 1271 $('.ruc_error').hide(); 1272 $('.ruc_correct').hide(); 1273 $('.estract_this_ruc_button').prop('disabled', 'disabled'); 1274 } 1275 }); 1276} 1277 1278window.consultar_ruc = function (this_form, numero_doc, target_type, target_name, target_dir, target_dep, target_prov, target_dist) { 1279 $.ajax({ 1280 url: '/consultar_ruc', 1281 type: 'POST', 1282 data: { numero_doc: numero_doc, tipo: numero_doc.length == 8 ? 'dni' : 'ruc' }, 1283 success: function (data) { 1284 if (data.success) { 1285 if (!data.denominacion) { 1286 show_message("warning", "No se encontró ningun registro con el " + (numero_doc.length == 8 ? 'DNI' : 'RUC') + " ingresado") 1287 1288 return 1289 } 1290 show_message("success", (numero_doc.length == 8 ? 'DNI' : 'RUC') + " encontrado"); 1291 $(target_name).val(data.denominacion); 1292 if (target_dir) 1293 $(target_dir).val(data.direccion); 1294 if (target_dep) 1295 (data.departamento == "-") ? $(target_dep).val("") : $(target_dep).val(data.departamento); 1296 if (target_prov) 1297 (data.provincia == "-") ? $(target_prov).val("") : $(target_prov).val(data.provincia); 1298 if (target_dist) 1299 (data.distrito == "-") ? $(target_dist).val("") : $(target_dist).val(data.distrito); 1300 if (target_type) { 1301 if ($(target_type).find("option:contains('1')").length) { 1302 if (numero_doc.length == 8) { 1303 $(target_type).val("2") 1304 } else 1305 $(target_type).val("1") 1306 } else if ($(target_type).find("option:contains('RUC')").length) { 1307 if (numero_doc.length == 8) { 1308 $(target_type).val("DNI") 1309 } else 1310 $(target_type).val("RUC") 1311 } 1312 } 1313
1314 if ($("#modal-extraer-documento").attr("aria-hidden") == "false") { 1315 $("#modal-extraer-documento").foundation("close"); 1316 } 1317 } 1318 //this_form.foundation("validateForm"); 1319 }, 1320 error: function (e) { 1321 1322 } 1323 }) 1324} 1325 1326window.ruc_verify = function (valor) { 1327 valor = window.trim(valor) 1328 if (esnumero(valor)) { 1329 if (valor.length == 8) { 1330 var suma = 0 1331 for (var i = 0; i < valor.length - 1; i++) { 1332 var digito = valor.charAt(i) - '0'; 1333 if (i == 0) suma += (digito * 2) 1334 else suma += (digito * (valor.length - i)) 1335 } 1336 var resto = suma % 11; 1337 if (resto == 1) resto = 11; 1338 if (resto + (valor.charAt(valor.length - 1) - '0') == 11) { 1339 return true 1340 } 1341 1342 } else if (valor.length == 11) { 1343 var suma = 0 1344 var x = 6 1345 for (var i = 0; i < valor.length - 1; i++) { 1346 if (i == 4) x = 8 1347 var digito = valor.charAt(i) - '0'; 1348 x-- 1349 if (i == 0) suma += (digito * x) 1350 else suma += (digito * x) 1351 } 1352 var resto = suma % 11; 1353 resto = 11 - resto 1354 1355 if (resto >= 10) resto = resto - 10; 1356 if (resto == valor.charAt(valor.length - 1) - '0') { 1357 return true 1358 } 1359 } 1360 1361 1362 } 1363 return false 1364} 1365 1366window.trim = function (cadena) { 1367 var cadena2 = ""; 1368 var len = cadena.length; 1369 for (var i = 0; i <= len; i++) if (cadena.charAt(i) != " ") { 1370 cadena2 += cadena.charAt(i); 1371 } 1372 return cadena2; 1373} 1374 1375window.esnumero = function (campo) { 1376 return (!(isNaN(campo))); 1377} 1378 1379window.show_message = function (type, message) { 1380 $("#messages").html(`<div class="large columns"> 1381<div data-closable class="callout text-center ${type}"> 1382${message} 1383<button class="close-button" type="button" data-close> 1384 <span aria-hidden="true">×</span> 1385 </button> 1386</div> 1387</div>`); 1388 setTimeout(function () { 1389 $("#messages").fadeOut() 1390 }, 7000) 1391} 1392 1393 1394window.show_params_tracking = function (type, message) { 1395 // Escuchamos el evento de clic en los enlaces de parámetros 1396 document.querySelectorAll('.load-params').forEach(link => { 1397 link.addEventListener('click', function (e) { 1398 e.preventDefault(); 1399 1400 const trackingId = this.dataset.id; 1401 const targetContainer = document.getElementById(`content-desc${trackingId}`); 1402 1403 // Solo hacemos la petición si no se ha cargado antes 1404 if (targetContainer.innerText === "Cargando...") { 1405 fetch(`/trackings/${trackingId}/params_details`) 1406 .then(response => response.text()) 1407 .then(data => { 1408 targetContainer.innerText = data; 1409 }) 1410 .catch(error => { 1411 targetContainer.innerText = "Error al cargar los datos."; 1412 console.error('Error:', error); 1413 }); 1414 } 1415 }); 1416 }); 1417} 1418 1419$(document).on('open.zf.reveal', '.internal-note-modal', function () { 1420 var $modal = $(this); 1421 var $tx = $modal.find('textarea'); 1422 $tx.val(''); 1423 setTimeout(function () { $tx.focus(); }, 50); 1424}); 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438
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.