1var general_charDecimal="."; 2var general_chatMiles=","; 3var Txt_general_aviso="Notice"; 4var Txt_Dialog_Cerrar="Close"; 5var Txt_Dialog_CerrarNoRecordar="Close and don´t remember"; 6var Txt_Media_VerENYotube="Visualizar en YouTube"; 7var Txt_Media_IcoYoutube="Icono Youtube"; 8var UrlCalendario= "/dynt3/Calendario/en/calenHTML.htm"; 9var ArrMonths = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; 10var ArrWeekDay= ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]; 11var ArrWeekDayJS=["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; 12var ArrWeekDayLong= ["Sunday", "Monday", "Twesday", "Wednesday", "Thursday", "Friday", "Saturday"]; 13var ArrCalendarTextos=["Yesterday","Today","Tomorrow","No publication available","Multiple Publications","Loading","Error on loading publication data","Publications","ICal","Go to previous month","Go to next month"]; 14var Txt_Desplegar="Unfold" 15var Txt_Plegar="Fold" 16var txt_cabecera_AvisoCookie="This site uses cookies to offer you a better browsing experience. Find out more on <a href=\"/dyngs/AYU/en/index.htm?cid=302\">how we use cookies.</a>"; 17var txt_SeleccionarAlgo="You must select an option"; 18var Txt_ariaLabel_AddVideo="Link to YouTube video titled "; 19var Txt_ventanaNueva="Open new window"; 20var Txt_alternativa_AddVideo="Watch INE video"; 21var Txt_Campo_Vacio = "This field cannot be empty"; 22 23var general_numLoadUrl = 0; 24 25 26function getAgente(){ 27 var agt=''; 28 if (typeof navigator.userAgent!=="undefined" ){ 29 agt = navigator.userAgent; 30 } 31 if (typeof navigator.userAgentData!=="undefined" ){ 32 agt+= ' ' +navigator.appCodeName + ' ' + navigator.userAgentData.platform; 33 if (navigator.userAgentData.mobile) 34 agt +=' ' + 'Mobile'; 35 var arr=navigator.userAgentData.brands; 36 for (i=0;i<arr.length;i++) 37 agt+=arr[i].brand + '/' + arr[i].version; 38 } 39 return agt.toLowerCase(); 40} 41 42function Is () 43{ 44 var agt=getAgente(); 45 46 // --- BROWSER VERSION --- 47 this.major = parseInt(navigator.appVersion); 48 this.minor = parseFloat(navigator.appVersion); 49 50 this.nav = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1))); 51 this.nav2 = (this.nav && (this.major == 2)); 52 this.nav3 = (this.nav && (this.major == 3)); 53 this.nav4 = (this.nav && (this.major == 4)); 54 this.nav5 = (this.b=="ns" && this.v==5) 55 56 57 this.ie = (agt.indexOf("msie") != -1) || (agt.indexOf("trident") != -1); 58 this.ie3 = (this.ie && (this.major == 2)); 59 this.ie4 = (this.ie && (this.major == 4)); 60 this.ie5 = (agt.indexOf('msie 5')>0); 61 62 if (this.ie){ 63 pos=0; 64 size=0; 65 if (agt.indexOf('msie')!=-1){ 66 pos=agt.indexOf('msie'); 67 size=5; 68 }else{ 69 pos=agt.indexOf('trident'); 70 pos=agt.indexOf('rv',pos); 71 size=3; 72 } 73 pos=pos+size; 74 fin=agt.indexOf(';',pos)-pos; 75 if (fin<0) 76 fin=agt.indexOf(')',pos)-pos; 77 else 78 fin=agt.length-pos; 79 80 aux=parseInt(agt.substr(pos,fin)); 81 this.ieVersion = parseInt(aux); 82 }else{ 83 this.ieVersion = null; 84 } 85 86 this.opera = (agt.indexOf("opera") != -1); 87 this.NN = this.nav && (this.major >= 4); 88 this.IE = this.ie && (this.major >= 4); 89 90 if (this.ie5) 91 this.v = 5 92 this.min = (this.NN||this.IE) 93 94} 95 96var isMobile = { 97 Android: function() { 98 return getAgente().match(/Android/i)!=null; 99 }, 100 BlackBerry: function() { 101 return getAgente().match(/BlackBerry/i); 102 }, 103 iOS: function() { 104 return getAgente().match(/iPhone|iPad|iPod/i); 105 }, 106 Opera: function() { 107 return getAgente().match(/Opera Mini/i); 108 }, 109 Mobile: function() { 110 return getAgente().match(/Mobile/i); 111 }, 112 GooglebotMobile: function() { 113 return getAgente().match(/Googlebot-Mobile/i); 114 }, 115 Windows: function() { 116 return getAgente().match(/IEMobile/i); 117 }, 118 any: function() { 119 return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || isMobile.Mobile() || isMobile.GooglebotMobile()); 120 } 121}; 122 123function findObj(n, d) { 124 var p,i,x; 125 if(!d) d=document; 126 if((p=n.indexOf("?"))>0 && parent.frames.length) 127 { 128 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 129 if(!(x=d[n])&&d.all) x=d.all[n]; 130 for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
131 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x; 132} 133if (Menu_TituloFavoritos==null) 134 var Menu_TituloFavoritos="INE"; 135 136if (Menu_UrlFavoritos==null) 137 var Menu_UrlFavoritos="www.ine.es"; 138 139function AgregarFavoritos(titulo,url){ 140 title =titulo; 141 url = url; 142 try{ 143 if (window.sidebar) { // Mozilla Firefox Bookmark 144 window.sidebar.addPanel(title, url,""); 145 } else if( window.external ) { // IE Favorite 146 window.external.AddFavorite( url, title); 147 } else if(window.opera && window.print) { // Opera Hotlist 148 return true; } 149 }catch(e) { 150 151 } 152} 153 154function Mensaje (fichero,scroll,ancho,alto) { 155 156 var w=ancho; 157 var h=alto; 158 var t=(screen.height-h)/2 159 var l=(screen.width-w)/2 160 if (scroll==0){ 161 prop='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,top='+t+',left='+l+',width='+w+',height='+h 162 msgWindow=window.open(fichero,'legal',prop) 163 } else { 164 prop='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top='+t+',left='+l+',width='+w+',height='+h 165 msgWindow=window.open(fichero,'legal',prop) 166 } 167 168} 169 170function changeBackgroundColor(obj,color){ 171 document.getElementById(obj).style.background=color; 172} 173 174function changeBackgroundColorObj(obj,color){ 175 obj.style.background=color; 176} 177 178function changeColor(obj,color){ 179 document.getElementById(obj).style.color=color; 180} 181 182function changeColorObj(obj,color){ 183 obj.style.color=color; 184} 185 186//Nos devuelve la posicion XY del scroll 187function getScrollXY() { 188 var scrOfX = 0, scrOfY = 0; 189 if( typeof( window.pageYOffset ) == 'number' ) { 190 //Netscape compliant 191 scrOfY = window.pageYOffset; 192 scrOfX = window.pageXOffset; 193 } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { 194 //DOM compliant 195 scrOfY = document.body.scrollTop; 196 scrOfX = document.body.scrollLeft; 197 } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { 198 //IE6 standards compliant mode 199 scrOfY = document.documentElement.scrollTop; 200 scrOfX = document.documentElement.scrollLeft; 201 } 202 return [ scrOfX, scrOfY ]; 203} 204//Usado para evitar las repetidas pulsaciones de boton y que produzcan envio del formulario 205function noRecarga(btn) { 206 destino=btn.form.target; 207 if (destino==null || destino=="undefined" || destino.length==0 || destino.toUpperCase() =="_SELF"){ 208 btn.disabled = true; 209 btn.form.submit(); 210 } 211} 212 213function NVL(val,def){ 214 if(typeof val == 'undefined') 215 return def; 216 else 217 return val; 218} 219 220function isEmpty(value){ 221 return typeof value === 'undefined' || !value || (typeof value == 'String' && value.length == 0 ) 222} 223 224 225String.prototype.countDecimals = function() { 226 if (this.isNaN){ 227 throw new Error('String.prototype.countDecimals: dato(' + this + ') no valido para contar decimales.'); 228 }else{ 229 if(this.length==0 || Math.floor(this.valueOf()).toString() === this.valueOf()) 230 return 0; 231 return this.split(".")[1].length || 0; 232 } 233} 234 235Number.prototype.countDecimals = function() { 236 return this.toString().countDecimals(); 237} 238 239Number.prototype.formatMoney = function (c, d, t) { 240 if(typeof c == "undefined") c = this.countDecimals(); 241 if(typeof d == "undefined") d = typeof general_charDecimal == 'undefined' ? "." : general_charDecimal; 242 if(typeof t == "undefined") t = typeof general_chatMiles == 'undefined' ? "," : general_chatMiles; 243 244 let loc= "es-ES"; 245 if (general_charDecimal==".") 246 loc="en-GB"; 247 248 let opt = {useGrouping:true, maximumFractionDigits: 20} 249 if(c){ opt. minimumFractionDigits= c } 250 251 return Intl.NumberFormat(loc, opt).format(this) 252} 253 254String.prototype.formatMoney = function (c, d, t) { 255 if (isNaN(this)) 256 throw new Error('String.prototype.formatMoney: dato(' + this + ') no reconocido como numérico.'); 257 else{ 258 if (this.length>0){ 259 if(typeof c == "undefined") c = this.countDecimals(); 260 return Number(this).formatMoney(c, d, t); 261 }else 262 return this; 263 } 264} 265 266Number.prototype.formatMoneyLang = Number.prototype.formatMoney; 267String.prototype.formatMoneyLang = String.prototype.formatMoney 268 269String.prototype.ltrim = function() { 270 return this.trimStart(); 271} 272String.prototype.rtrim = function() { 273 return this.trimEnd(); 274} 275String.prototype.capitalize = function() { 276 return this.charAt(0).toUpperCase() + this.slice(1); 277} 278Array.prototype.contain= function(val) { 279 //Esta función a diferencia de includes permite el casting entre tipos int==String 280 for(i = 0; i < this.length; i++) { 281 if(this[i]==val) { 282 return true; 283 } 284 } 285 return false; 286} 287 288if (!Array.prototype.fill) { 289 Object.defineProperty(Array.prototype, 'fill', { 290 value: function(value) { 291 if (this == null) { 292 throw new TypeError('esto es nulo o no definido'); 293 } 294 var O = Object(this); 295 var len = O.length >>> 0; 296 var start = arguments[1]; 297 var relativeStart = start >> 0; 298 var k = relativeStart < 0 ? 299 Math.max(len + relativeStart, 0) : 300 Math.min(relativeStart, len); 301 var end = arguments[2]; 302 var relativeEnd = end === undefined ? 303 len : end >> 0; 304 var final = relativeEnd < 0 ? 305 Math.max(len + relativeEnd, 0) : 306 Math.min(relativeEnd, len); 307 while (k < final) { 308 O[k] = value; 309 k++; 310 } 311 return O; 312 } 313 }); 314} 315 316function alerta(titulo,estilo){ 317 texto="<p class=\"" + estilo + "\">" + titulo + "<p>"; 318 return modalMsg(titulo,'modal-dialog-centered',null,null) 319} 320 321function alerta(titulo,estilo){ 322 texto="<p class=\"" + estilo + "\">" + titulo + "<p>"; 323 return modalMsg(titulo,'modal-dialog-centered',null,null,null) 324} 325 326function aviso(titulo,estilo,cookieName){ 327 aviso(titulo,estilo,cookieName,30) 328} 329 330function aviso(titulo,estilo,cookieName,cookieDias){ 331 if (typeof estilo !="undefined" && estilo !=null) 332 texto="<p class=\"" + estilo + "\">" + titulo + "<p>"; 333 else 334 texto="<p>" + titulo + "<p>"; 335 return modalMsg(titulo,'modal-dialog-centered',null,null,"NoRecordar",cookieName, cookieDias); 336} 337 338function dlgModalLink(elem){ 339 document.querySelector(".modal .close").click() 340 341 if(elem!=null && document.querySelectorAll(elem).length==1){ 342 elem.click(); 343 } 344} 345 346function modalMsgButton(textHtml,hrefButton,textButton,tipoModal,effectIn,effectOut){ 347 try{ 348 tipoModal = effectIn = effectOut = null; // parámetros en desuso 349 document.dialog(Txt_general_aviso, textHtml, { ok: { text: textButton, action: function () { location.href= hrefButton } } }); 350 return false; 351 352 }catch(e){ 353 alert(textHtml); 354 } 355} 356function modalMsg(textHtml,tipoModal,effectIn,effectOut,tipoRespuesta,cookieName){ 357 return modalMsg(textHtml,tipoModal,effectIn,effectOut,tipoRespuesta,cookieName,30) 358} 359 360function modalMsg(textHtml,tipoModal,effectIn,effectOut,tipoRespuesta,cookieName,cookieDias){ 361 try{ 362 if (typeof cookieName!="undefined" && readCookie(cookieName)!=null) return; 363 364 if(tipoRespuesta=='NoRecordar'){ 365 textHtml +=`<button type="button" class="btn btn-secondary">${Txt_Dialog_CerrarNoRecordar}</button>`; 366 } 367 368 tipoModal = effectIn = effectOut = null; // parámetros en desuso 369 document.dialog(Txt_general_aviso, textHtml, { 370 ok: { 371 text: Txt_Dialog_Cerrar, 372 action: function (e) { 373 e.target.closest(".modal-content").querySelector(".close").click() 374 } 375 } 376 }); 377 378 document.querySelector(".modal .btn-secondary").onclick = function() { 379 if(readCookie("politicaCookie") && readCookie("politicaCookie")
379== "accepted") createCookiePath(cookieName,null,"1", cookieDias) 380 document.querySelector(".modal .close").click(); 381 }; 382 383 return false; 384 385 }catch(e){ 386 alert(textHtml); 387 } 388} 389 390//Usada para anadir un video de youtube 391//Insertar el codigo que devuelve youtube directamente da errores de accesibilidad 392//Hay que indicar el title del video ya que es necesario por accesibilidad, el identificador del mismo, el ancho y alto del iframe 393function addVideo(idVideo, titulo, alto, ancho ){ 394 395 if (titulo == null || titulo =="") 396 alert("Es obligatorio indicar un titulo"); 397 try{ 398 if (ancho>480) 399 idxSize=0 400 else if (ancho>320) 401 idxSize=1 402 else if (ancho>120) 403 idxSize=2 404 else 405 idxSize=3 406 407 var div = '<div style="display:inline-block;height:' + (alto + 15) + 'px; width:' + ancho + 'px; margin: 5px 0 35px 15px;">'; 408 div += '<a href="https://www.youtube.com/embed/' + idVideo + '" data-idxresize="2" class="media-youtube embed-responsive-item" target="YouTube" title="' + titulo +' " style="height:' + alto + 'px; width:' + ancho + 'px"><span class="alternativa">' + Txt_alternativa_AddVideo + '</span></a>' 409 div += '<p style="margin-top:5px">' + titulo + ' <a target="_blank" href="https://www.youtube.com/watch?v=' + idVideo + '&t=1s&cc_load_policy=1" aria-label="' + Txt_ariaLabel_AddVideo + titulo +'" title="' + Txt_ventanaNueva + '"><i class="ii ii-external-link"></i></a></p>'; 410 div += '</div>' 411 412 document.write(div); 413 }catch(e){ 414 alert(e); 415 } 416} 417 418 419 420var urlObjectLoaded; 421 422if (urlObjectLoaded==null) 423 urlObjectLoaded= new Array(); 424function IsAllLoaded(){ 425 try{ 426 if(getHoldReady()==0){ 427 var objeto=null; 428 for(i=0;i<urlObjectLoaded.length;i++){ 429 objeto=urlObjectLoaded[i]; 430 if (objeto.tagName.toUpperCase()=="LINK") 431 aux=objeto.tagName + '[href="' + objeto.url + '"]'; 432 else 433 aux=objeto.tagName + '[src="' + objeto.url + '"]'; 434 elem = document.querySelectorAll(aux); 435 if (elem.length>0){ 436 var elemLoaded=null; 437 for (var j = 0; j < elem.length; j++) { 438 if (typeof elem[j].loaded !== "undefined" && !elem[j].loaded){ 439 return false; 440 } 441 } 442 } 443 } 444 return true; 445 }else{ 446 return false; 447 } 448 }catch(ex){ 449 return true; 450 } 451} 452 453function loadJsExist(url) { 454 var element=document.querySelectorAll('script[src="' + url + '"]'); 455 return element.length >0?element:null; 456} 457 458//var numHoldReady=0; 459function getHoldReady(){ 460 if(typeof window.nHoldReady === "undefined" || isNaN(window.nHoldReady)){ 461 window.nHoldReady=0; 462 } 463 return window.nHoldReady; 464} 465function incHoldReady(type){ 466 if(typeof getHoldReady() !== "undefined"){ 467 return window.nHoldReady++; 468 } 469} 470function decHoldReady(type){ 471 if(typeof getHoldReady() !== "undefined"){ 472 return --window.nHoldReady; 473 474 } 475} 476 477function loadUrlObject(objeto,callback,charset,forceCallback){ 478 var elem=null; 479 var aux=null; 480 if (objeto.tagName.toUpperCase()=="LINK") 481 aux=objeto.tagName + '[href="' + objeto.url + '"]'; 482 else
483 aux=objeto.tagName + '[src="' + objeto.url + '"]'; 484 objeto.callback= new Array(); 485 elem = document.querySelectorAll(aux); 486 var elemLoaded=null; 487 for (var i = 0; i < elem.length; i++) { 488 if (typeof elem[i].loaded !== "undefined"){ 489 elemLoaded=elem[i]; 490 break; 491 } 492 } 493 494 if (elem==null || elem.length==0) { 495 urlObjectLoaded.push(objeto); 496 497 if (typeof callback!= 'undefined' && callback!=null) 498 objeto.callback.push(callback); 499 objeto.forceCallback=forceCallback==true; 500 objeto.loaded=false; 501 objeto.funLoaded=false;//Evitar el caso de cambio de rel y provoque otro load 502 funcLoad= function(){ 503 if(!this.funLoaded){ 504 this.funLoaded=true; 505 var frcCall = this.forceCallback; 506 507 try{ 508 this.loaded=true; 509 if(frcCall){ 510 if (typeof objeto.callback!= 'undefined' && objeto.callback!=null){ 511 for (var i = 0; i < objeto.callback.length; i++) { 512 objeto.callback[i](); 513 } 514 } 515 }else{ 516 this.loaded=true; 517 if (typeof objeto.callback!= 'undefined' && objeto.callback!=null) 518 for (var i = 0; i < objeto.callback.length; i++) { 519 objeto.callback[i](); 520 } 521 } 522 }catch(e){ 523 console.log(e); 524 } 525 } 526 } 527 funcError = function(e,d){ 528 if(!this.funLoaded){ 529 this.funLoaded=true; 530 this.loaded=true; 531 } 532 return false; 533 } 534 if(charset!=null){ 535 if(objeto.tagName.toUpperCase() == "SCRIPT" && objeto.getAttribute('charset') == null) { 536 objeto.setAttribute('charset', charset); 537 } 538 } 539 if (objeto.tagName.toUpperCase()=="LINK" && objeto.getAttribute('rel')=="preload"){ 540 objeto.setAttribute('rel', 'stylesheet'); 541 objeto.removeAttribute("as"); 542 } 543 if (objeto.addEventListener){ 544 objeto.addEventListener('load', funcLoad,false); 545 objeto.addEventListener('error', funcError,false); 546 } else if (objeto.attachEvent){ 547 objeto.attachEvent('load', funcLoad); 548 objeto.attachEvent('error', funcError); 549 } 550 try{ 551 document.head.appendChild(objeto); 552 }catch(e){ 553 document.getElementsByTagName('head')[0].appendChild(objeto); 554 } 555 }else{ 556 if (typeof callback!= 'undefined' && callback!=null){ 557 if (typeof elemLoaded!=="undefined" && elemLoaded!=null ){ 558 if (elemLoaded.loaded) 559 callback() 560 else 561 elemLoaded.callback.push(callback); 562 }else{ 563 callback(); 564 } 565 } 566 } 567} 568 569function loadUrlScriptBase(url,callback,charset,forceCallback,sync){ 570 let scripts; 571 if ((scripts=document.querySelectorAll('script[src*="' + clearUrl(url,true) +'"]')).length==0){ 572 var script = document.createElement('script'); 573 if (typeof HTMLVersion == "undefined" || HTMLVersion<5){ 574 script.setAttribute('type', 'text/javascript'); 575 } 576 if (sync!=null && !sync){ 577 script.setAttribute('async',''); 578 } 579 url=clearUrl(url,false) ; 580 script.setAttribute('src', url); 581 script.url= url; 582 return loadUrlObject(script,callback,charset,forceCallback); 583 }else{ 584 asyncCallback(scripts[0],callback); 585 return true; 586 } 587} 588 589function loadUrlScript(url,callback,charset,forceCallback){ 590 return loadUrlScriptBase(url,callback,charset,forceCallback,null); 591} 592 593function loadUrlScriptSync(url,callback,charset,sync){ 594 return loadUrlScriptBase(url,callback,charset,null,sync); 595} 596 597async function asyncCallback(script,callback){ 598 if (callback){ 599 if (script.callback && !script.loaded){ 600 script.callback.push(callback); 601 }else{ 602 let TimeOut=5; 603 while (TimeOut>0){ 604 try{ 605 callback(); 606 TimeOut=0; 607 }catch(e){ 608 TimeOut--; 609 console.log("callback"+url); 610 } 611 if (TimeOut>0){ 612 await sleep(100); 613 } 614 } 615 } 616 } 617} 618 619function loadUrlStyle(url,callback,charset,forceCallback){ 620 url = clearUrl(url,false); 621 var style = document.createElement('link'); 622 style.url= url; 623 style.setAttribute('href', url); 624 if(!getAgente().match(/(MSIE|Trident\/)/)){ 625 style.setAttribute('rel', 'preload'); 626 style.setAttribute('as', 'style'); 627 } else { 628 style.setAttribute('rel', 'stylesheet'); 629 } 630 loadUrlObject(style,callback,charset,forceCallback); 631} 632 633function clearUrl(url,clearDomain){ 634 let vuelta; 635 if (url.indexOf(location.protocol)==0){ 636 vuelta = url.substr(location.protocol.length+2).replace(/\/+/g, '/'); 637 vuelta = clearDomain ? vuelta.substr(vuelta.indexOf('/')) : location.protocol + "//" + vuelta; 638 }else{ 639 vuelta = url.replace(/\/+/g, '/'); 640 } 641 642 return vuelta; 643} 644 645//Realiza una espera de s milisegundos 646var sleep = async (s) => 647 new Promise((p) => setTimeout(p, (s) | 0)) 648 649//retrasa la ejecucion de un afunciona hasta que el documento esta cargado 650var lstAsyncFunction; 651 652if (lstAsyncFunction==null) 653 lstAsyncFunction= {}; 654 655async function onLoadAsyncTO() { 656 var keys= new Array() 657 let TimeOut=true; 658 659 while (TimeOut){ 660 661 for(var i in lstAsyncFunction) keys.push(parseInt(i)); 662 keys.sort(function(a, b){ 663 return a - b; 664 }); 665 666 TimeOut=false; 667 for(var idx=0; idx<keys.length; idx++){ 668 if (lstAsyncFunction[keys[idx]]!=null){ 669 for(var i = 0; lstAsyncFunction[keys[idx]] != null && i < lstAsyncFunction[keys[idx]].length; i++){ 670 var lstFucnt=lstAsyncFunction[keys[idx]]; 671 funLoad=lstFucnt[i]; 672 if (funLoad!=null){ 673 testJquery = true; 674 if(typeof jQuery != "undefined"){ 675 testJquery = (!funLoad.testJquery || typeof jQuery !== 'undefined' && typeof jQuery.ui !== 'undefined'); 676 } 677
678 if (funLoad.status==0 && testJquery){ 679 lstFucnt[i] = null; 680 lstAsyncFunction[keys[idx]].splice(i, 1); 681 funLoad.fun(); 682 }else if (funLoad.status==1 && (document.readyState == 'complete' || document.readyState == 'interactive') && testJquery ) { 683 lstFucnt[i] = null; 684 lstAsyncFunction[keys[idx]].splice(i, 1); 685 funLoad.fun(); 686 }else if (document.readyState === 'complete' && testJquery && IsAllLoaded) { 687 if (IsAllLoaded()){ 688 lstFucnt[i] = null; 689 funLoad.fun(); 690 }else{ 691 TimeOut=true; 692 break; 693 } 694 }else{ 695 TimeOut=true; 696 break; 697 } 698 } 699 }//for 700 }//if 701 702 }//for keys 703 704 if (TimeOut){ 705 await sleep(100); 706 } 707 } 708 709} 710 711/* 712 * Inicial la carga según el estado reflejado 713 * 0 loading 714 * 1 interactive 715 * 2 complete 716 * 717 * El parámetro testJquery sirve para indicar si verificar el test de jquey y jquery ui, por defecto es true 718 */ 719function onLoadAsync(callbackFunction,estado,testJquery) { 720 estado=(typeof estado!=="undefined" ? estado: 2); 721 if (lstAsyncFunction[estado]==null) 722 lstAsyncFunction[estado]= new Array(); 723 lstAsyncFunction[estado].push({ 724 fun:callbackFunction, 725 status:estado, 726 testJquery:(typeof testJquery!=="undefined" ? testJquery: true), 727 }); 728 onLoadAsyncTO(); 729} 730 731function readParams(query){ 732if (typeof query!= 'undefined' && query!=null && query.length>0){ 733 var objStr =""; 734 var valvalue=""; 735 736 if (query.length>0){ 737 var n=query.split("&"); 738 objStr+="[{"; 739 for (var i=0;i<n.length;i++){ 740 valvalue = n[i].split("="); 741 if (i>0) 742 objStr+=","; 743 objStr+="\"" + valvalue[0] + "\":\"" + valvalue[1]+ "\""; 744 } 745 objStr+="}]"; 746 } 747 748 var obj = JSON.parse(objStr); 749 if( obj.length>0) 750 return obj[0]; 751 else 752 return null; 753}else 754 return null; 755} 756 757function readParamsUrlValue(nameParam){ 758 var lstP=readParams(location.search.substring(1)); 759 if(lstP!=null && lstP[nameParam] != undefined && lstP[nameParam]!= '' ) 760 return lstP[nameParam]; 761} 762 763var urlExists = function(url, callback){ 764 fetch(url, { 765 method: "HEAD" 766 }).then(response => { 767 if(response.status.toString()[0] === 2) callback(true); 768 else callback(false); 769 770 }).catch(error => { 771 callback(false); 772 }); 773} 774 775 776/* ****************** Buscador ********************* */ 777 778function Buscador_Buscar(opcion){ 779 if(Buscador_Valida(opcion)) 780 document.getElementById("cabeceraBuscador").submit(); 781} 782 783function Buscador_Valida(opcion){ 784 let i = document.querySelector("#searchString"); 785 786 if(i.value.trim().length > 0){ 787 i.setCustomValidity(""); 788 i.reportValidity(); 789 return true; 790 } else { 791 i.setCustomValidity(Txt_Campo_Vacio); 792 i.reportValidity(); 793 i.oninput = Buscador_Reset; 794 return false; 795 } 796} 797 798function Buscador_Reset(){ 799 let i = document.querySelector("#searchString"); 800 i.setCustomValidity(""); 801 i.reportValidity(); 802} 803 804/* ************************ Init function ************************** */ 805if (!('getEventListeners' in window)) { 806 getEventListeners = function(el) { 807 var _ev; 808 var _evs = {}; 809 for(var key in el){ 810 if (/^on/.test(key) && (typeof(el[key]) === 'function') && (_ev = key.slice(2))) { 811 if (!_evs[_ev]) 812 _evs[_ev] = []; 813 _evs[_ev].push({ 814 listener: el[key], 815 useCapture: false, 816 passive: false, 817 once: false, 818 type: _ev 819 }); 820 } 821 } 822 return _evs; 823 } 824} 825function setKeyPressToClick(p_selector, p_event){ 826 if(typeof p_event!=="undefined" && p_event != null){ 827 eventoBusq = p_event; 828 }else{ 829 eventoBusq = "click"; 830 } 831 var selector = typeof p_selector==="undefined" ? 'a,button,img,li,div,span,p,td,legend' : p_selector; 832 var items = Array.prototype.slice.call( 833 document.querySelectorAll(selector) 834 ).map(function(element) { 835 var listeners = getEventListeners(element); 836 vuelta = { 837 element: element, 838 listeners: Object.keys(listeners).map(function(k) { 839 if (k==eventoBusq) 840 return { event: k, listeners: listeners[k] }; 841 else 842 return null; 843 }).filter(function(item) { 844 return item!=null; 845 }) 846 }; 847 return vuelta; 848 849 }).filter(function(item) { 850 return item.listeners.length; 851 }); 852 853 for (index = 0; index < items.length; ++index) { 854 it = items[index].element; 855 856 if(it.getAttribute("tabindex")){ 857 it.tabIndex = parseInt(it.getAttribute("tabindex")); 858 } 859 860 if(it.tagName != "INPUT"){ 861 var attr = it.getAttribute('role'); 862 if (typeof attr === typeof undefined || attr === false) { 863 if(it.tagName != "TD"){ 864 it.setAttribute("role", "button"); 865 } 866 } 867 } 868 869 if (it.onkeypress == null){ 870 if(eventoBusq == "mouseover"){ 871 it.addEventListener('focus',focusToMouseover); 872 }else{ 873 it.addEventListener('keypress',keyPressToClick); 874 } 875 } 876 } 877} 878 879function keyPressToClick(event){ 880 if ( event.which == 13 ) { 881 event.target.click(); 882 return false; 883 } 884} 885 886function focusToMouseover(event){ 887 event.target.dispatchEvent(new Event('mouseover')); 888 return false; 889} 890 891function loadSubLibrary(){ 892 893 if (is.IE && is.ieVersion<8){ 894 document.querySelectorAll("label>input:submit").forEach( function(obj) { 895 obj.parentElement.addEventListener("click", function(event){ 896 this.document.querySelector("input:submit").click(); 897 }); 898 }); 899 } 900 901} 902 903function LoadGeneral(){ 904 905 if ( typeof HM_idioma == 'undefined') 906 HM_idioma='es'; 907 908 if ( typeof HM_Menu_Dir == 'undefined') 909 HM_Menu_Dir='/menus/'; 910 911 if ( typeof HM_Menu_DirVersion == 'undefined') 912 HM_Menu_DirVersion=HM_Menu_Dir + '/_b/'; 913 914 915 if ( typeof HM_DirJs == 'undefined') 916 HM_DirJs=HM_Menu_Dir+"/_b/js/"; 917 918 params=readParams(this.location.search.substr(1)); 919 if (params!=null && typeof params.nocab !== 'undefined'){ 920 window.addEventListener("load", (event) => { 921 document.body.classList.add("nocab"); 922 }); 923 } 924 925 onLoadAsync(loadSubLibrary,1,false); 926 onLoadAsync(setKeyPressToClick,9999,false); 927} 928 929function trapFocus(el, nofocus){ 930 var ls = el.querySelectorAll("a"), 931 firstElement = ls[0], 932 lastElement = ls[ls.length-1]; 933 934 function keydownHandler(e) { 935 var evt = e || window.event; 936 var keyCode = evt.which || evt.keyCode; 937 var x = e.target.getBoundingClientRect().x; 938
939 if(evt.target == lastElement && keyCode === 9 && !evt.shiftKey && x >= 0) { 940 if(evt.preventDefault) evt.preventDefault(); 941 else evt.returnValue = false; 942 firstElement.focus(); 943 944 } else if(evt.target == firstElement && keyCode === 9 && evt.shiftKey && x >= 0) { 945 if(evt.preventDefault) evt.preventDefault(); 946 else evt.returnValue = false; 947 lastElement.focus(); 948 } 949 950 } 951 952 firstElement.addEventListener('keydown', keydownHandler, false); 953 lastElement.addEventListener('keydown', keydownHandler, false); 954 955} 956 957window.getTextWidth = function(obj, fontname, width){ 958 if(width){ document.body.style.width = width + "px"; } else { document.body.style.width = ""; } 959 960 var txt = ""; 961 if(typeof obj != 'string'){ 962 txt = obj.innerText; 963 } else { 964 txt = obj; 965 } 966 967 var fontsize = getComputedStyle(obj).fontSize; 968 969 var canvas = document.createElement('canvas'); 970 var ctx = canvas.getContext('2d'); 971 ctx.font = fontsize + ' ' + fontname; 972 973 var aux = ctx.measureText(txt).width; 974 var xCount = 0; 975 976 // El restarle 10 es por el padding del elemento DL 977 while(aux > (obj.offsetWidth - 10) && xCount < 100){ 978 fontsize = parseInt(fontsize); 979 fontsize--; 980 fontsize += "px"; 981 ctx.font = fontsize + ' ' + fontname; 982 983 aux = ctx.measureText(txt).width; 984 985 xCount++; 986 } 987 988 if(width){ document.body.style.width = ""; } 989 990 return fontsize; 991} 992/* ******************************JQUERY PASSIVE*********************************** */ 993if (typeof jQuery !== 'undefined') { 994 jQuery.event.special.touchstart = { 995 setup: function( _, ns, handle ) { 996 this.addEventListener("touchstart", handle, { passive: true }); 997 } 998 }; 999 jQuery.event.special.touchmove = { 1000 setup: function( _, ns, handle ) { 1001 this.addEventListener("touchmove", handle, { passive: true }); 1002 } 1003 }; 1004 jQuery.event.special.wheel = { 1005 setup: function( _, ns, handle ){ 1006 this.addEventListener("wheel", handle, { passive: true}); 1007 } 1008 }; 1009 jQuery.event.special.mousewheel = { 1010 setup: function( _, ns, handle ){ 1011 this.addEventListener("mousewheel", handle, { passive: true}); 1012 } 1013 }; 1014 jQuery.event.special.mousemove = { 1015 setup: function( _, ns, handle ){ 1016 this.addEventListener("mousemove", handle, { passive: true}); 1017 } 1018 }; 1019 jQuery.event.special.mouseout = { 1020 setup: function( _, ns, handle ){ 1021 this.addEventListener("mouseout", handle, { passive: true }); 1022 } 1023 }; 1024 jQuery.event.special.focus = { 1025 setup: function( _, ns, handle ){ 1026 this.addEventListener("focus", handle, { passive: true }); 1027 } 1028 }; 1029 jQuery.event.special.blur = { 1030 setup: function( _, ns, handle ){ 1031 this.addEventListener("blur", handle, { passive: true }); 1032 } 1033 }; 1034 jQuery.event.special.keydown = { 1035 setup: function( _, ns, handle ){ 1036 this.addEventListener("keydown", handle, { passive: true }); 1037 } 1038 }; 1039 jQuery.event.special.wheel = { 1040 setup: function( _, ns, handle ){ 1041 this.addEventListener("wheel", handle, { passive: true }); 1042 } 1043 }; 1044} 1045/* ************************* 1046 * Utilizada en los formularios de /menu/cgi/ir.cgi para enviar el formulario a la página indicada en el campo url 1047 ************************ */ 1048 1049function isValidSelect(select,idxNoValid){ 1050 if (select.selectedIndex==idxNoValid) 1051 return false; 1052 else 1053 return true; 1054} 1055 1056function formIr(){ 1057 try{ 1058 if (!isEmpty(this.prevOnSubmit)) 1059 this.prevOnSubmit(); 1060 let selectURL =this.querySelector("select[name='url']"); 1061 let url= selectURL.options[selectURL.selectedIndex].value; 1062 if (url.indexOf("/")==0 1063 || url.indexOf("http")==0 1064 || url.indexOf(".")>0 1065 ){ 1066 let target = this.target.length>0? this.target : "_self"; 1067 window.open(url,target); 1068 }else{ 1069 alerta(txt_SeleccionarAlgo); 1070 } 1071 }catch(e){ 1072 console.error("Error al tratar el envio del formulario IR con el metodo formIr ") 1073 }finally{ 1074 return false; 1075 } 1076} 1077 1078function initFormIr(){ 1079 let formList = document.querySelectorAll("form[action$='/cgi/ir.cgi']") 1080 formList.forEach((formItem) => { 1081 formItem.prevOnSubmit = formItem.onsubmit; 1082 formItem.onsubmit = formIr; 1083 }); 1084} 1085 1086onLoadAsync(initFormIr,9999,false); 1087 1088/*******************************************************************/ 1089var is = new Is(); 1090LoadGeneral();
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.