1// Variables 2let siteUrl; 3const regExpressionEmail = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i; //"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"; 4const regExpressionExpiration = /^\b[0-1]{1}[0-9]{1}[/]{1}[20]{2}[0-9]{2}\b$/i; //"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"; 5const regExpressionCCV = /^\b[0-9]{3,4}\b$/i; //"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"; 6const langCode = 'es-GT'; 7 8$(function () { 9 siteUrl = $('meta[name="site"]').attr('content'); 10 if (siteUrl.substring(siteUrl.length - 1) == '/') { 11 siteUrl = siteUrl.substring(0, siteUrl.length - 1); 12 } 13 if (window.location.href.includes("/tiendavirtual") || window.location.href.includes("/login")) { 14 localStorage.setItem("windowsSize", 0); 15 } 16 let iloader = $('body').find('.loader'); 17 if (iloader.length == 0) { 18 $('body').append('<div class="loader"></div>'); 19 } 20 $(document).bind('ajaxStart', function (event, request, settings) { 21 blockUI(); 22 }).bind('ajaxStop', function (event, request, settings) { 23 unblockUI(); 24 }).bind('ajaxComplete', function (event, request, settings) { 25 if (request.status == 401) { 26 window.location.href = siteUrl + '/login/expired'; 27 } 28 unblockUI(); 29 }); 30 31 $.ajaxSetup({ 32 headers: { 'ajax-request': 'true' } 33 }); 34 35 $('form').on('submit', function (e) { 36 if (e.result) { 37 blockUI(); 38 } 39 }); 40 41 $('[data-bs-toggle="tooltip"]').tooltip() 42 43 LoadTips(); 44 SetWindowsSize(); 45 //header + main 46 let headerHeight = $('header').height() + 'px'; 47 let r = document.querySelector(':root'); 48 r.style.setProperty('--header-height', headerHeight); 49}); 50 51window.addEventListener('resize', function (event) { 52 let headerHeight = $('header').height() + 'px'; 53 let r = document.querySelector(':root'); 54 r.style.setProperty('--header-height', headerHeight); 55 localStorage.setItem("windowsSize", 0); 56 SetWindowsSize(); 57}, true); 58 59function blockUI() { 60 $('.loader').fadeIn('fast'); 61} 62function unblockUI() { 63 $('.loader').fadeOut('slow'); 64} 65function LoadTips() { 66 // Navegación con Enter 67 let list_controls = '.form-next'; 68 let $inp = $(list_controls); 69 $inp.bind('keypress', function (e) { 70 let n = $(list_controls).length; 71 let key = e.which; 72 if (key == 13) { 73 e.preventDefault(); 74 let currentIndex = $inp.index(this); 75 let nextIndex = currentIndex + 1; 76 let currentControl = $(list_controls)[currentIndex]; 77 if ($(currentControl).hasClass('form-submit')) { 78 $('form').submit(); 79 } 80 if ($(currentControl).hasClass('form-enter')) { 81 $(currentControl).click(); 82 } 83 if (nextIndex < n) { 84 $(list_controls)[nextIndex].focus(); 85 } 86 //if ($($inp).hasClass('form-click')) { 87 // $($inp).click(); 88 //} 89 } 90 }); 91 // DatePicker 92 $.each($('.datepicker').not('.ready-datepicker'), function (index, item) { 93 $(item).addClass('ready-datepicker'); 94 DatePicker(item); 95 }); 96 // Mascara 97 $.each($('.mask').not('.ready-mask'), function (index, item) { 98 $(item).addClass('ready-mask'); 99 let maskData = $(item).attr('data-mask'); 100 let maskReverse = true; 101 if (!$(item).attr('data-mask-reverse')) { 102 maskReverse = $(item).attr('data-mask-reverse'); 103 } 104 $(item).mask(maskData, { reverse: maskReverse }); 105 }); 106 //Table 107 $.each($('.table-auto').not('.ready-table'), function (index, item) { 108 $(item).addClass('ready-table'); 109 Table(item); 110 }); 111 $.each($('.table-auto-responsive').not('.ready-table-responsive'), function (index, item) { 112 $(item).addClass('ready-table-responsive'); 113 TableResponsive(item); 114 }); 115 //Iframe Auto 116 $.each($('.iframe-pdf'), function (index, item) { 117 if (!window.matchMedia("(max-width: 767px)").matches) { 118 let urlIframe = $(item).attr('data-url'); 119 $(item).attr('src', urlIframe); 120 } 121 });
122 // Tooltips 123 $.each($('[data-bs-toggle="tooltip"]').not('.ready-tooltip'), function (index, item) { 124 $(item).addClass('ready-tooltip'); 125 $(item).tooltip(); 126 }); 127 // Tooltips 128 $.each($('.zoom').not('.ready-zoom'), function (index, item) { 129 $(item).addClass('ready-zoom'); 130 $(item).zoom({ on: 'click' }); 131 }); 132} 133function numberWithCommas(number) { 134 let numberClean = numberWithOutCommas(number); 135 return new Intl.NumberFormat(langCode, { minimumFractionDigits: 2 }).format(numberClean); 136} 137function numberWithOutCommas(number) { 138 if (number == undefined || number == null || number == '') { 139 return 0; 140 } else { 141 return number.toString().replace(/,/g, ""); 142 } 143} 144function DownloadFile(request, data = null) { 145 $.post(request, data, function (result) { 146 let pom = document.createElement('a'); 147 pom.setAttribute('href', 'data:' + result.mimeType + ';base64,' + result.file); 148 pom.setAttribute('download', result.fileName); 149 if (document.createEvent) { 150 let event = document.createEvent('MouseEvents'); 151 event.initEvent('click', true, true); 152 pom.dispatchEvent(event); 153 } 154 else { 155 pom.click(); 156 } 157 }); 158} 159function DownloadLink(request, data = null) { 160 $.post(request, data, function (result) { 161 let pom = document.createElement('a'); 162 pom.setAttribute('href', result); 163 pom.setAttribute('download', result); 164 pom.setAttribute('target', '_blank'); 165 if (document.createEvent) { 166 let event = document.createEvent('MouseEvents'); 167 event.initEvent('click', true, true); 168 pom.dispatchEvent(event); 169 } 170 else { 171 pom.click(); 172 } 173 }); 174} 175function OpenLink(request) { 176 let pom = document.createElement('a'); 177 pom.setAttribute('href', request); 178 pom.setAttribute('target', '_blank'); 179 if (document.createEvent) { 180 let event = document.createEvent('MouseEvents'); 181 event.initEvent('click', true, true); 182 pom.dispatchEvent(event); 183 } 184 else { 185 pom.click(); 186 } 187} 188function MenuToggle() { 189 $('#navmenu').toggleClass('d-none'); 190 $('#menuLeft').find('.fal').toggleClass('fa-bars'); 191 $('#menuLeft').find('.fal').toggleClass('fa-times'); 192} 193function MenuToggleDescubre() { 194 $('#descubremenu').toggleClass('d-none'); 195} 196function MenuToggleTV() { 197 let isReady = $('#navmenu').attr('data-ready'); 198 if (isReady == 'false') { 199 $('#navmenu').load(siteUrl + '/tiendavirtual/menudinamico', function () { 200 $('#navmenu').toggleClass('d-none'); 201 $('#menuLeft').find('.fal').toggleClass('fa-bars'); 202 $('#menuLeft').find('.fal').toggleClass('fa-times'); 203 $('#navmenu').attr('data-ready', 'true'); 204 205 $('.categoria-titulo').hover(function () { 206 console.log(this); 207 let cod_grupo = $(this).attr('data-group'); 208 $('.categoria-subgrupo').addClass('d-none'); 209 if (cod_grupo != null && cod_grupo != undefined) { 210 $('.categoria-subgrupo[data-group="' + cod_grupo + '"]').removeClass("d-none"); 211 } 212 }); 213 214 }); 215 } else { 216 $('#navmenu').toggleClass('d-none'); 217 $('#menuLeft').find('.fal').toggleClass('fa-bars'); 218 $('#menuLeft').find('.fal').toggleClass('fa-times'); 219 } 220} 221function MenuContainShow(e) { 222 let id_menu = $(e).attr('data-menu'); 223 let actual = $('.menu-contain.active').attr('data-menu'); 224 let selectorMenu = '.menu-main[data-menu="' + id_menu + '"]'; 225 $('.nav-link').removeClass('fw-bold'); 226 $($('.nav-link').parent()).removeClass('bg-oriflame-gray-light'); 227 $('.nav-link').find('i').removeClass('fa-rotate-180'); 228 $('.menu-contain').slideUp('fast'); 229 $('.menu-contain').removeClass('active'); 230 if (id_menu != actual) { 231 $(selectorMenu).addClass('fw-bold'); 232 $(selectorMenu).find('i').addClass('fa-rotate-180'); 233 $($(selectorMenu).parent()).addClass('bg-oriflame-gray-light'); 234 $('.menu-contain[data-menu="' + id_menu + '"]').addClass('active'); 235 $('.menu-contain[data-menu="' + id_menu + '"]').slideDown('fast'); 236 } 237} 238function togglePassword() {
239 let ctrl = $('#password'); 240 if (ctrl.attr('type') == 'text') { 241 ctrl.attr('type', 'password'); 242 $('.toogle-password').find('i').removeClass('fa-eye-slash'); 243 $('.toogle-password').find('i').addClass('fa-eye'); 244 } else { 245 ctrl.attr('type', 'text'); 246 $('.toogle-password').find('i').removeClass('fa-eye'); 247 $('.toogle-password').find('i').addClass('fa-eye-slash'); 248 } 249} 250 251function CatalogoIframe(obj) { 252 let actual = $(obj).attr('data-actual'); 253 let siguiente = $(obj).attr('data-siguiente'); 254 $('.catalogo-selector').removeClass('active'); 255 $('.catalogoactual').attr('href', actual); 256 $('.catalogosiguiente').attr('href', siguiente); 257 setTimeout(function () { 258 $(obj).addClass('active'); 259 }); 260} 261function Pregunta(obj) { 262 let id = $(obj).attr('data-id'); 263 $('#modalMain .modal-body').load(siteUrl + '/public/pregunta', { id }, function () { 264 $('#modalMain').modal('show'); 265 }); 266} 267function Gestion(obj) { 268 let tipo_gestion = $(obj).attr('data-id'); 269 let numero_factura = $('#numero_factura').val(); 270 $('#modalMain .modal-body').load(siteUrl + '/public/GestionAccion', { tipo_gestion, numero_factura }, function () { 271 $('#modalMain').modal('show'); 272 }); 273} 274function GestionEnviar() { 275 let tipo_gestion = $('#txtFactura').attr('data-gestion-id'); 276 let numero_factura = $('#txtFactura').val(); 277 let comentario = $('#txtComentario').val(); 278 let monto = 0.00; 279 if ($('#txtMonto')[0] != null && $('#txtMonto')[0] != undefined) { 280 monto = numberWithOutCommas($('#txtMonto').val()); 281 } 282 $.post(siteUrl + '/public/GestionEnvio', { tipo_gestion, numero_factura, comentario, monto }, function (result) { 283 if (result.resultado) { 284 $('#modalMain').modal('hide'); 285 Alert(result.descripcion, NotifyIcon.success); 286 } else { 287 Alert(result.descripcion, NotifyIcon.warning); 288 } 289 }); 290} 291function OpenNews(obj) { 292 let media = $(obj).attr('data-media'); 293 if (media.includes('issuu.com') || media.includes('mtrbio.com')) { 294 OpenLink(media); 295 } 296 else { 297 if (media.includes('.jpg') || media.includes('.png')) { 298 $('#modalMain .modal-body').html('<button class="btn btn-dismiss-modal text-white" data-bs-dismiss="modal"><i class="fal fa-times fa-2x"></i></button><div class="row"><div class="col-12 text-center"><img src="' + media + '" rel="noopener noreferrer" class="vh-100 object-fit-contain img-fluid mx-auto iframe-news" title="News" /></div></div>'); 299 } else { 300 $('#modalMain .modal-body').html('<button class="btn btn-dismiss-modal text-white" data-bs-dismiss="modal"><i class="fal fa-times fa-2x"></i></button><iframe src="' + media + '" rel="noopener noreferrer" class="w-100 vh-100 border-0 iframe-news" title="News"></iframe>'); 301 } 302 $('#modalMain').modal('show'); 303 } 304} 305 306function CargaFoto() { 307 $('#modalMain .modal-body').load(siteUrl + '/main/foto', function () { 308 $('#modalMain').modal('show'); 309 }); 310} 311function CargarFotoPerfil() { 312 $('#fotografia').click(); 313 $("#fotografia").change(function () { 314 CargaFotoNueva(); 315 }); 316} 317function CargaFotoNueva() { 318 var fileNew = $('#fotografia').prop("files"); 319 console.log(fileNew); 320 if (fileNew != null && fileNew != undefined) { 321 var form = new FormData(); 322 form.append("files", fileNew[0]); 323 324 $.ajax({
325 type: 'Post', 326 url: siteUrl + '/main/foto', 327 data: form, 328 cache: false, 329 contentType: false, 330 processData: false, 331 success: function (result) { 332 if (result.resultado) { 333 $('.fotoUsuarioActivo').attr('src', result.descripcion) 334 $('#modalMain').modal('hide'); 335 Alert('Imagen actualizada', NotifyIcon.success); 336 } 337 else { 338 Alert(result.descripcion, NotifyIcon.warning); 339 } 340 }, 341 error: function (err) { 342 console.log(err) 343 } 344 }); 345 } 346} 347function InputNumber(e) { 348 var key = window.event ? e.which : e.keyCode; 349 if (!((key >= 48 && key <= 57) || (key >= 96 && key <= 105) || key == 8 || key == 13 || key == 9)) { 350 e.preventDefault(); 351 } 352} 353function scrollToTop() { 354 $([document.documentElement, document.body]).animate({ 355 scrollTop: 0 356 }, 500); 357 window.scrollTo(0, 0); 358} 359function scrollToControl(objID) { 360 $([document.documentElement, document.body]).animate({ 361 scrollTop: $(objID).offset().top - 100 362 }, 500); 363 $(objID).focus(); 364 $(objID).select(); 365} 366function scrollToRequired(objID) { 367 scrollToControl(objID); 368 $(objID).addClass('border border-2 border-danger'); 369 $(objID).on('blur', function () { cleanBorder(objID); }); 370} 371function cleanBorder(objID) { 372 let valor = $(objID).val(); 373 if ($(objID).hasClass('dropdown-toggle')) { 374 valor = $(objID).attr('title'); 375 } 376 377 if (valor != undefined && valor != null && valor.length > 0) { 378 $(objID).removeClass('border border-2 border-danger'); 379 } 380} 381function SetTarjeta(obj) { 382 383 $.each($('input[type="checkbox"][name="tarjeta"]').not(obj), function (index, item) { 384 $(item).prop('checked', false); 385 }); 386 387 let card_number = $(obj).attr('data-number'); 388 let card_expiration = $(obj).attr('data-expiration'); 389 $('#card_number').val(card_number); 390 $('#card_exp').val(card_expiration); 391} 392 393function InitializeDateAirpicker(letter) { 394 let f = new Date(); 395 let fechaStart = f.setDate(1); 396 var fechaEnd = new Date(f.getFullYear(), f.getMonth() + 1, 0); 397 398 if (letter == 'E') 399 return fechaEnd; 400 else 401 return fechaStart; 402} 403 404function setMaxLengthByCodEmp(cod_emp, inputId) { 405 let maxLength = 8; 406 switch (parseInt(cod_emp)) { 407 case 1: // GUA 408 case 2: // SAL 409 case 3: // HON 410 case 4: // NIC 411 case 5: // COS 412 maxLength = 8; 413 break; 414 case 8: // DOM 415 maxLength = 10; 416 break; 417 } 418 $("#" + inputId).attr("maxlength", maxLength); 419} 420function SetWindowsSize() { 421 let size = window.innerWidth; 422 let windowsSize = localStorage.getItem("windowsSize"); 423 424 if (windowsSize == 0 || !windowsSize) { 425 $.post(siteUrl + '/home/WindowsSize', { size }, function () { 426 localStorage.setItem("windowsSize", size); 427 }); 428 } 429} 430function ViewAyuda() { 431 $('#modalMain .modal-body').load(siteUrl + '/public/ayuda', function () { 432 $('#modalMain').modal('show'); 433 }); 434} 435function ChangeAyuda(obj) { 436 let url = $(obj).attr('data-url'); 437 $('.ayuda-item').removeClass('text-primary'); 438 $(obj).addClass('text-primary'); 439 $('#iframeAyuda').attr('src', url); 440}
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.