https://laopcion.com.mx/__export/sites/laopcion/desktop/scripts/Section.js?v=0.18539000%201790936300
1var hra_header = hra_header || {}; 2 3hra_header.div = document.getElementById( "header" ); 4hra_header.nav = document.getElementById( "nav" ); 5hra_header.scrollTop = 0; 6hra_header.stickyLimit = hra_header.div.offsetTop + 400; 7hra_header.navigation = hra_header.div.querySelector('.header__subnav'); 8hra_header.search = hra_header.div.querySelector('.header__search-form'); 9hra_header.searchAction = hra_header.div.querySelector('.header__search-button'); 10hra_header.searchButton = hra_header.div.querySelector('.hrafa__search_cool'); 11 12hra_header.fn = { 13 start: function() { 14 hra_header.searchAction.addEventListener('click', hra_header.fn.onToggleSearch, false); 15 16 hra_header.navigation.addEventListener('click', hra_header.fn.onToggleSubMenu, false); 17 18 window.addEventListener('scroll', hra_header.fn.onScroll, false); 19 20 hra_header.fn.detectSite(); 21 }, 22 onToggleSearch: function() { 23 if (hra_header.search.classList.contains('header__search-form--active')) { 24 hra_header.search.classList.remove('header__search-form--active'); 25 } else { 26 hra_header.search.classList.add('header__search-form--active'); 27 } 28 }, 29 onToggleSubMenu: function() { 30 if (hra_header.navigation.classList.contains('header__subnav--active')) { 31 hra_header.navigation.classList.remove('header__subnav--active'); 32 } else { 33 hra_header.navigation.classList.add('header__subnav--active'); 34 } 35 }, 36 onScroll: function() { 37 hra_header.scrollTop = window.pageYOffset; 38 39 if( hra_header.scrollTop > hra_header.stickyLimit ){ 40 41 setTimeout(function(){ 42 hra_header.div.classList.add( "header--sticky" ); 43 document.querySelector( "body" ).classList.add( "padding--for--sticky" ); 44 }, 150); 45 } else { 46 if( hra_header.div.classList.contains( "header--sticky" ) ){ 47 setTimeout(function(){ 48 hra_header.div.classList.remove( "header--sticky" ); 49 document.querySelector( "body" ).classList.remove( "padding--for--sticky" ); 50 }, 150); 51 } 52 } 53 }, 54 detectSite: function() { 55 var $_ul = hra_header.nav.querySelector('ul'); 56 var $_li = $_ul.querySelectorAll('li'); 57 58 $_li.forEach((e) => { 59 var $e = e; 60 var $_href = $e.querySelector('a').getAttribute('href'); 61 62 if ($_href == window.location.href) { 63 if ( ! $e.querySelector('a').classList.contains('selected')) { 64 $e.querySelector('a').classList.add('selected'); 65 } 66 } 67 }); 68 69 } 70}; 71 72try { 73 hra_header.fn.start(); 74} catch(e) { 75 console.error('HRA-Header-Error: '+e); 76} 77(function(window, document) { 78 'use strict'; 79 80 var defaults = { 81 paddingTop: 20, 82 paddingBottom: 20, 83 stop: null, 84 events: { 85 onMove: function(){}, 86 onBeforeMove: function(){}, 87 onAfterMove: function(){} 88 } 89 } 90 91 var element = null, 92 elementHeight = null, 93 posElement = null, 94 Settings = null, 95 position = null, 96 elementNodeParent = null, 97 posShim = null, 98 shim = document.createElement('div'), 99 StopElement = null, 100 posSE = null; 101 102 function Constructor(id, Options) { 103 Settings = (Options == null) ? defaults : Options; 104 element = document.getElementById(id); 105 posElement = element.getBoundingClientRect(); 106 elementNodeParent = element.parentNode; 107 StopElement = (Option == null) ? 0 : Options.stop; 108 109 shim.style.height = '1px'; 110 elementHeight = posElement.bottom - posElement.top; 111 112 window.addEventListener('scroll', setSticky, true); 113 } 114 115 var makeSticky = (function(set){ 116 if (set) { 117 elementNodeParent.insertBefore(shim, element); 118 element.style.position = 'fixed'; 119 element.style.top = Settings.paddingTop + 'px'; 120 } else { 121 elementNodeParent.removeChild(shim); 122 element.removeAttribute('style'); 123 } 124 }); 125 126 var updateElementPositions = (function(){ 127 posElement = element.getBoundingClientRect(); 128 posShim = shim.getBoundingClientRect(); 129 posSE = StopElement.getBoundingClientRect(); 130 }); 131
132 var setSticky = (function(){ 133 if (element.style.position != 'fixed') { 134 updateElementPositions(); 135 136 if (posElement.top <= Settings.paddingTop) { 137 makeSticky(true); 138 } 139 } 140 141 if (element.style.position == 'fixed') { 142 updateElementPositions(); 143 144 if (posShim.top >= posElement.top) { 145 makeSticky(false); 146 return; 147 } 148 149 if (posSE.bottom >= Settings.paddingTop) { 150 element.style.top = Settings.paddingTop + 'px'; 151 } 152 153 if (posSE.bottom <= Settings.paddingTop + elementHeight) { 154 var newPosition = posSE.bottom - elementHeight; 155 156 if (posElement.bottom <= 0) { 157 if (posSE.bottom >= posElement.top) { 158 element.style.top = newPosition + 'px'; 159 } 160 161 return; 162 } 163 164 element.style.top = newPosition + 'px'; 165 } 166 } 167 }); 168 169 window.stickyHRA = Constructor; 170})(window, document); 171var hra_lazyload = hra_lazyload || {}; 172 173hra_lazyload.images = []; 174hra_lazyload.config = { rootMargin: '50px 0px', threshold: 0.01 }; 175hra_lazyload.observer = null; 176hra_lazyload.imagePath = null; 177 178hra_lazyload.fn = { 179 start: function() { 180 hra_lazyload.images = document.querySelectorAll('[data-lazyload]:not(.generated)'); 181 182 if (hra_lazyload.images.length == 0) { 183 return; 184 } 185 186 if ('IntersectionObserver' in window) { 187 hra_lazyload.observer = new IntersectionObserver(hra_lazyload.fn.onIntersection, hra_lazyload.config); 188 for (var i = 0, k = hra_lazyload.images.length; i < k; i++) { 189 hra_lazyload.observer.observe(hra_lazyload.images[i]); 190 } 191 } else { 192 hra_lazyload.fn.load(); 193 } 194 }, 195 onIntersection: function(List) { 196 for (var i = 0, k = List.length, image; i < k; i++) { 197 image = List[i]; 198 199 if (image.intersectionRatio > 0) { 200 hra_lazyload.observer.unobserve(image.target); 201 hra_lazyload.fn.set.apply(image.target); 202 } 203 } 204 }, 205 set: function() { 206 hra_lazyload.imagePath = this.getAttribute('data-lazyload'); 207 if (this.classList.contains('generated') || ! hra_lazyload.imagePath) { 208 return; 209 } 210 211 this[this.tagName !== "LINK" ? 'src' : 'href'] = hra_lazyload.imagePath; 212 this.removeAttribute('data-lazyload'); 213 this.classList.add('generated'); 214 }, 215 load: function() { 216 for (var i = 0, k = hra_lazyload.images.length; i < k; i++) { 217 hra_lazyload.fn.set.apply(hra_lazyload.images[i]) 218 } 219 } 220 221}; 222 223try { 224 hra_lazyload.fn.start(); 225} catch (e) { 226 console.error('HRA-LazyLoad-Error: '+ e); 227} 228(function( window ){ 229 'use strict'; 230 231 var int_inner = 0; 232 var Poll = function ( Poll, options ) { 233 234 var defaults = { 235 elements: { 236 button: "[data-pollitem]", 237 buttonSubmit: "[data-pollsubmit]", 238 totalVotes: "[data-totalvotes]", 239 toggle: { 240 toggleButton: "[data-toggleresults]", 241 viewText: "Ver resultados", 242 hideText: "Ocultar resultados" 243 } 244 }, 245 css: { 246 poll:{ 247 generated: "poll--generated", 248 results: "poll--results", 249 loading: "poll--loading", 250 }, 251 item: { 252 selected: "poll__item--selected", 253 bar: "poll__bar", 254 percent: "poll__percent", 255 }, 256 submit: { 257 disabled: "poll__submit--disabled" 258 }, 259 toggle: { 260 results: "poll__toggle" 261 } 262 }, 263 onClickItem: function( poll, item ){}, 264 onClickSubmit: function( poll, button ){}, 265 onSuccess: function( poll ){}, 266 onError: function( poll, error ){}, 267 onLoading: function( poll ){}, 268 onClose: function( poll ){}, 269 onResults: function( poll, buttons, percents, winnerIndex ){}, 270 onReset: function( poll ){} 271 }, 272 _this = this, 273 Settings = extend( defaults, options ), 274 PollItemsSelected; 275 276 function extend() { 277 var extended = {}; 278 var deep = false; 279 var i = 0; 280 var length = arguments.length; 281 282 if ( Object.prototype.toString.call( arguments[0] ) === '[object Boolean]' ) { 283 deep = arguments[0]; 284 i++; 285 } 286 287 var merge = function (obj) { 288 for ( var prop in obj ) { 289 if ( Object.prototype.hasOwnProperty.call( obj, prop ) ) { 290 if ( deep && Object.prototype.toString.call(obj[prop]) === '[object Object]' ) { 291 extended[prop] = extend( true, extended[prop], obj[prop] ); 292 } else { 293 extended[prop] = obj[prop]; 294 } 295 } 296 } 297 }; 298 299 for ( ; i < length; i++ ) { 300 var obj = arguments[i]; 301 merge(obj); 302 } 303 304 return extended; 305 306 }; 307 308 function getCookie( name ){ 309 var name = name + "=", 310 cookies = document.cookie.split(';'); 311 312 for( var i = 0, k = cookies.length; i < k; i++ ){ 313 var cookie = cookies[ i ]; 314 while( cookie.charAt( 0 ) == ' ' ){ 315 cookie = cookie.substring( 1 ); 316 } 317 if( cookie.indexOf( name ) == 0 ){ 318 return cookie.substring( name.length, cookie.length ); 319 } 320 } 321 return false;
322 } 323 324 function setCookie( name, value, days ){ 325 var expires; 326 if( days ){ 327 var date = new Date(); 328 date.setTime( date.getTime() + ( days * 24 * 60 * 60 * 1000 ) ); 329 expires = "; expires=" + date.toGMTString(); 330 }else{ 331 expires = ""; 332 } 333 document.cookie = name + "=" + value + expires + "; path=/"; 334 } 335 336 function isExpired(){ 337 return new Date( Poll.dataset.close ) < new Date(); 338 } 339 340 function isClosed () { 341 return getCookie( Poll.dataset.path ) || Poll.dataset.status == 'cerrada' || Poll.dataset.status == 'inactiva' || isExpired(); 342 } 343 344 function initialize(){ 345 if( Poll.classList.contains( Settings.css.poll.generated ) ){ 346 return; 347 } 348 349 var botones = Poll.querySelectorAll( Settings.elements.button ); 350 if( isClosed () ){ 351 352 var cookiValue = getCookie( Poll.dataset.path ); 353 if( cookiValue !== false ){ 354 cookiValue = cookiValue.split( "," ); 355 356 for( var i = 0, k = botones.length; i < k; i++ ){ 357 if( cookiValue.indexOf( i+"" ) >= 0 ){ 358 botones[ i ].classList.add( Settings.css.item.selected ); 359 } 360 } 361 362 var footer = document.querySelector('.poll__footer'); 363 if( footer && int_inner == 0){ 364 var footerP = footer.querySelector('p'); 365 if( footerP ){ 366 footerP.innerHTML += '<br />Gracias por votar!'; 367 } 368 int_inner++; 369 } 370 } 371 372 Settings.onClose.apply( _this, [ Poll ] ); 373 374 return; 375 } 376 377 for( var i = 0, k = botones.length; i < k; i++ ){ 378 botones[ i ].addEventListener( "click", onClickItem, false ); 379 } 380 var submit = Poll.querySelectorAll( Settings.elements.buttonSubmit ); 381 for( var i = 0, k = submit.length; i < k; i++ ){ 382 submit[ i ].addEventListener( "click", onClickSubmit, false ); 383 } 384 385 386 Poll.classList.add( Settings.css.poll.generated ); 387 } 388 389 function onClickItem(){ 390 if( Poll.classList.contains( Settings.css.poll.results ) || 391 Poll.classList.contains( Settings.css.poll.loading ) ){ 392 return; 393 } 394 this.classList[ this.classList.contains( Settings.css.item.selected )?"remove":"add" ]( Settings.css.item.selected ); 395 Settings.onClickItem.apply( _this, [ Poll, this ] ); 396 } 397 398 function onClickSubmit(){ 399 Settings.onClickSubmit.apply( _this, [ Poll, this ] ); 400 } 401 402 this.submitVote = function(){ 403 404 PollItemsSelected = Poll.querySelectorAll( "."+Settings.css.item.selected ); 405 if(PollItemsSelected.length <= 0) return; 406 var submit = Poll.querySelector( Settings.elements.buttonSubmit ); 407 408 if( submit ){ 409 submit.disabled = true; 410 submit.classList.add( Settings.css.submit.disabled ); 411 } 412 413 Settings.onLoading( Poll ); 414 Poll.classList.add( Settings.css.poll.loading ); 415 416 417 var params = "?path="+Poll.dataset.path, 418 cookieValue = []; 419 420 for (var i = 0; i < PollItemsSelected.length; i++) { 421 PollItemsSelected[i].dataset.votes = (PollItemsSelected[i].dataset.votes*1)+1; 422 params += "&answer="+PollItemsSelected[i].dataset.id; 423 params += "&date="+PollItemsSelected[i].dataset.date; 424 cookieValue.push( PollItemsSelected[i].dataset.id ); 425 } 426 427 var totalPersonVotes = Poll.querySelectorAll( Settings.elements.totalVotes ); 428 for (var i = 0; i < totalPersonVotes.length; i++) { 429 totalPersonVotes[i].innerHTML = parseInt( totalPersonVotes[i].dataset.totalvotes, 10 ) + 1; 430 }; 431 432 var xhttp = new XMLHttpRequest(); 433 xhttp.onreadystatechange = function() { 434 if ( this.readyState == 4 && this.status == 200 ) { 435 var response = JSON.parse( this.responseText ); 436 if( response.result == "success" ){ 437 Settings.onSuccess.apply( _this, [ Poll ] ); 438 setCookie( Poll.dataset.path, cookieValue.join( "," ), 30 ); 439 }else{ 440 Settings.onError.apply( _this, [ Poll, response.message ] ); 441 } 442 Poll.classList.remove( Settings.css.poll.loading ); 443 } else if( this.status != 200 && this.readyState == 4 ){ 444 Settings.onError.apply( _this, [ Poll, this.status ] ); 445 Poll.classList.remove( Settings.css.poll.loading ); 446 } 447 }; 448 xhttp.open( "GET", "/ajax/votePollJSON.html"+params, true ); 449 xhttp.send(); 450 } 451 452 453 this.onResults = function(){ 454 var totalVotes = 0; 455 var votes = []; 456 var arrPercents = []; 457 var winnerIndex = 0; 458 var buttonList = Poll.querySelectorAll( Settings.elements.button ); 459 460 for (var i = 0, curr; i < buttonList.length; i++) { 461 curr = buttonList[i]; 462 totalVotes += +curr.dataset.votes; 463 }; 464 for (var i = 0, curr, currpercent; i < buttonList.length; i++) { 465 curr = buttonList[i]; 466 467 if( (curr.dataset.votes*1) == 0 ){ 468 arrPercents.push( 0 ); 469 }else{ 470 arrPercents.push( parseInt( Math.floor( (curr.dataset.votes*1) / totalVotes * 100 ) ) ); 471 } 472 473 }; 474 475 winnerIndex = arrPercents.indexOf( Math.max.apply(null, arrPercents) ); 476 477 var submit = Poll.querySelector( Settings.elements.buttonSubmit ); 478 if( submit ){ 479 submit.disabled = true; 480 submit.classList.add( Settings.css.submit.disabled ); 481 } 482 483 Settings.onResults.apply( _this, [ Poll, buttonList, arrPercents, winnerIndex ] ); 484 Poll.classList.add( Settings.css.poll.results ); 485 } 486 487 initialize(); 488 }; 489 490 491 window.Poll = Poll; 492})( window ); 493 494(function( window ){ 495 'use strict'; 496 497 var PollsHRA = function ( Selector, callback ) {
498 function init(){ 499 var Polls = document.querySelectorAll( ".hra-poll" ); 500 501 for( var i = 0, k = Polls.length; i < k; i++ ){ 502 generate( Polls[ i ] ); 503 } 504 } 505 506 function generate( Poll ){ 507 if( Poll.classList.contains( "generated" ) ){ 508 return; 509 } 510 511 var Path = Poll.dataset.path, 512 Date = Poll.dataset.date, 513 PollParams = "?path="+Path+"&date="+Date; 514 515 var xhttp = new XMLHttpRequest(); 516 xhttp.onreadystatechange = function() { 517 if ( this.readyState == 4 && this.status == 200 ) { 518 Poll.innerHTML = this.responseText; 519 520 var PollType = Poll.querySelector( "[data-type]" ); 521 522 if( PollType ){ 523 checkAndTrigger( PollType.dataset.type ); 524 }else{ 525 console.error( "Error al cargar la encuesta", Poll ); 526 } 527 }else if( this.readyState == 4 && this.status != 200 ){ 528 console.error( "Error al cargar la encuesta", Path, Template ); 529 } 530 }; 531 xhttp.open( "GET", "/ajax/get_news_body_poll.html"+PollParams, true ); 532 xhttp.send(); 533 534 Poll.classList.add( "generated" ); 535 } 536 537 function checkAndTrigger( Style ){ 538 switch( Style ){ 539 case "simple": PollSimple.reinit(); break; 540 case "versus": PollVersus.reinit(); break; 541 } 542 } 543 544 init(); 545 546 this.reinit = init; 547 }; 548 549 550 window.PollsHRA = new PollsHRA(); 551})( window ); 552 553(function( window, Poll ){ 554 'use strict'; 555 556 var PollSimple = null; 557 558 function __construct(){ 559 PollSimple = document.querySelectorAll( ".poll--simple" ); 560 561 for (var i = 0, k = PollSimple.length; i < k; i++){ 562 new Poll( PollSimple[i], { 563 elements: { 564 button: ".poll__item", 565 buttonSubmit: ".poll__submit", 566 toggle: { 567 toggleButton: ".poll__toggle", 568 viewText: "Ver resultados", 569 hideText: "Ocultar resultados" 570 } 571 }, 572 onClickItem: function( poll, item ){ 573 if( poll.dataset.multiple != "true" ){ 574 this.submitVote(); 575 } 576 }, 577 onClickSubmit: function( poll, item ){ 578 this.submitVote(); 579 }, 580 onSuccess: function( poll ){ 581 this.onResults(); 582 var footer = poll.querySelector('.poll__footer'); 583 if( footer ){ 584 /*var votes = poll.querySelector('.poll__votes'); 585 if( votes ){ 586 votes.textContent = parseInt(votes.textContent) + 1; 587 var vote_kind = poll.querySelector('.poll__kind'), 588 ref_poll = (votes.textContent > 1) ? 'votaron' : 'votó', 589 people_poll = (votes.textContent > 1) ? 'personas' : 'persona', 590 vote_people = poll.querySelector('.poll__people'); 591 592 vote_kind.innerHTML = ref_poll; 593 vote_people.innerHTML = people_poll; 594 } 595 footer.classList.remove('hide');*/ 596 597 var footerP = footer.querySelector('p'); 598 if( footerP ){ 599 footerP.innerHTML += '<br />Gracias por votar!'; 600 } 601 } 602 }, 603 onError: function( poll, error ){ 604 this.onSuccess(); 605 }, 606 onLoading: function( poll ){}, 607 onClose: function(){ 608 this.onResults(); 609 }, 610 onResults: function( poll, buttons, percents, winnerIndex ){ 611 buttons[ winnerIndex ].classList.add( 'poll__item--win' ); 612 var total = 0; 613 614 for ( var i = 0; i < percents.length; i++ ) { 615 total += percents[i]; 616 } 617 618 if ( total == 99 ){ 619 percents[winnerIndex]++; 620 } 621 622 for ( var i = 0; i < percents.length; i++ ) { 623 buttons[ i ].querySelector('.poll__percent').textContent = percents[ i ] + "%"; 624 buttons[ i ].querySelector('.poll__bar').style.transform = 'scaleX('+ (buttons[ i ].offsetWidth * percents[ i ] / 100)+' )'; 625 } 626 }, 627 onReset: function( poll ){ 628 poll.querySelector( '.poll__item--win' ).classList.remove( 'poll__item--win' ); 629 var voteButton = poll.querySelector( '.poll__submit' ); 630 if( voteButton ) { 631 voteButton.classList.remove( 'poll__submit--disabled' ); 632 voteButton.disabled = false; 633 } 634 var percents = poll.querySelectorAll( '.poll__percent' ); 635 var bars = poll.querySelectorAll( '.poll__bar' ); 636 for (var i = 0; i < percents.length; i++) 637 percents[ i ].textContent = ''; 638 for (var i = 0; i < bars.length; i++) 639 bars[i].style.transform = 'scaleX(0)'; 640 } 641 }); 642 643 PollSimple[i].classList.add( "generated" ); 644 645 const buttons = document.querySelectorAll('.poll__items > button'); 646 console.log(buttons); 647 648 buttons.forEach(button => { 649 const imageUrl = button.getAttribute('data-bg'); 650 console.log(imageUrl); 651 if (imageUrl) { 652 button.style.position = 'relative'; 653 button.style.setProperty('--bg-image', `url('${imageUrl}')`); 654 655 // Si necesitas más lógica para manejar los pseudo-elementos, puedes agregarla aquÃ. 656 } 657 }); 658 } 659 } 660 661 __construct.prototype = { 662 reinit: __construct 663 } 664 665 window.PollSimple = new __construct(); 666 667})( window, Poll ); 668 669(function( window, Poll ){ 670 'use strict'; 671 672 var PollVersus = null; 673 674 function __construct(){ 675 PollVersus = document.querySelectorAll( ".poll--versus:not(.generated)" ); 676
677 for (var i = 0, k = PollVersus.length; i < k; i++){ 678 generate( PollVersus[ i ] ); 679 } 680 } 681 682 function generate( CurrentPoll ){ 683 new Poll( CurrentPoll, { 684 elements: { 685 button: ".poll__data", 686 }, 687 onClickItem: function( poll, item ){ 688 this.submitVote(); 689 }, 690 onSuccess: function( poll ){ 691 this.onResults(); 692 }, 693 onError: function( poll, error ){ 694 this.onResults(); 695 }, 696 onLoading: function( poll ){}, 697 onClose: function(){ 698 this.onResults(); 699 }, 700 onResults: function( poll, buttons, percents, winnerIndex ){ 701 poll.querySelectorAll( ".poll__item" )[ winnerIndex ].classList.add( "poll__item--win" ); 702 poll.querySelectorAll( ".poll__data" )[ winnerIndex ].classList.add( "poll__data--win" ); 703 704 var total = 0; 705 706 for ( var i = 0; i < percents.length; i++ ) { 707 total += percents[i]; 708 } 709 710 if ( total == 99 ){ 711 percents[winnerIndex]++; 712 } 713 714 poll.querySelector( ".poll__item--right" ).style.width = percents[ 1 ]+"%"; 715 716 for ( var i = 0; i < percents.length; i++ ) { 717 buttons[ i ].querySelector('.poll__percent').innerHTML = percents[ i ] + "<small>%</small>"; 718 } 719 } 720 }); 721 722 CurrentPoll.classList.add( "generated" ); 723 } 724 725 __construct.prototype = { 726 reinit: __construct 727 } 728 729 window.PollVersus = new __construct(); 730 731})( window, Poll ); 732/*(function(window){ 733 function __construct() { 734 var StopElement = document.querySelector(".limit--sticky"); 735 736 FixedElements = new stickyHRA("sticky-0", { 737 paddingTop: 110, 738 paddingBottom: 20, 739 stop: StopElement 740 }); 741 } 742 743 window.Skycrappers = new __construct(); 744})(window);*/ 745 746(function( window, document ){ 747 'use strcit'; 748 749 var ShowMore = null, 750 ShowMoreText = ""; 751 752 function __construct(){ 753 ShowMore = document.querySelector( "[data-showmore]" ); 754 755 if( ! ShowMore ){ 756 return; 757 758 } else if ( ! ShowMore.dataset.page ){ 759 console.error( "El atributo data-page es requerido", ShowMore ); 760 return; 761 } 762 763 ShowMore.addEventListener( "click", onClick, false ); 764 } 765 766 function serialize( Object ){ 767 var string = []; 768 for( var property in Object ) { 769 if ( Object.hasOwnProperty( property ) ) { 770 string.push( encodeURIComponent( property ) + "=" + encodeURIComponent( Object[property] ) ); 771 } 772 } 773 return string.join("&"); 774 } 775 776 function sendAjax( Button, success, error ){ 777 var microtime = (Date.now() % 1000); 778 var URL = Button.dataset.showmore+"?"+serialize( Button.dataset )+"µtime="+microtime; 779 780 var request = new XMLHttpRequest(); 781 request.onreadystatechange = function() { 782 if ( request.readyState == 4 && request.status == 200){ 783 success( request.responseText ); 784 } else if( request.readyState == 4 && request.status != 200 ){ 785 error(); 786 } 787 } 788 request.open( "GET", URL, true ); 789 request.send(); 790 } 791 792 793 function onClick(){ 794 var Button = this; 795 796 if( Button.classList.contains( "loading" ) ) { 797 return; 798 } 799 800 Button.classList.add( "loading" ); 801 ShowMoreText = Button.textContent; 802 Button.textContent = "Cargando.."; 803 804 sendAjax( Button, function( HTML ){ 805 var buttonParentNode = Button.parentNode, 806 tempHtml = document.createElement( "div" ); 807 808 tempHtml.innerHTML = HTML; 809 810 Button.insertAdjacentHTML( 'beforebegin', HTML ); 811 812 if( tempHtml.querySelector( "[data-showmorelast='true']" ) ){ 813 buttonParentNode.parentNode.removeChild( buttonParentNode ); 814 }else{ 815 Button.classList.remove( "loading" ); 816 Button.textContent = ShowMoreText; 817 Button.dataset.page++; 818 Button.dataset.size = Button.dataset.size + 7; 819 //window.LazyLoad.reinit(); 820 window.hra_lazyload.fn.start(); 821 } 822 }, function(){ 823 Button.classList.remove( "loading" ); 824 Button.textContent = ShowMoreText; 825 }); 826 827 } 828 829 window.ShowMore = new __construct(); 830 831})( window, document ); 832(function( window ){ 833 'use strict'; 834 835 var Triggers = null; 836 var isTemplateGenerated = false; 837 var ModalTemplate = null; 838 var ModalTemplateImage = null; 839 var ModalTemplateSection = null; 840 var ModalTemplateTitle = null; 841 var ModalTemplateFacebook = null; 842 var ModalTemplateTwitter = null; 843 var ModalTemplateEmail = null; 844 var ModalTemplateWhatsapp = null; 845 var LastItemOpened = null; 846 847 /** 848 * Constructor 849 */ 850 function Constructor(){ 851 Triggers = document.querySelectorAll( "[data-sharebtns]:not(.generated)" ); 852 853 for( var i = 0, k = Triggers.length; i < k; i++ ){ 854 Triggers[ i ].addEventListener( "click", onClick, false ); 855 Triggers[ i ].classList.add( "generated" ); 856 } 857 } 858
859 /** 860 * On click 861 */ 862 function onClick() { 863 var _this = this; 864 if( navigator.share ){ 865 navigator.share({ 866 title: this.dataset.title, 867 url: this.dataset.url || window.location.href, 868 }); 869 } else if ( ! isTemplateGenerated ){ 870 createModalTemplate(); 871 setTimeout(function(){ 872 onClick.apply( _this ); 873 }, 10); 874 } else { 875 openModal.apply( _this ); 876 } 877 } 878 879 function openModal(){ 880 if ( this != LastItemOpened ) { 881 configModal( this.dataset ); 882 LastItemOpened = this; 883 } 884 ModalTemplate.classList.add( 'sharemodal--open' ); 885 } 886 887 function closeModal(){ 888 ModalTemplate.classList.remove( 'sharemodal--open' ); 889 } 890 function getFacebookLink( url ) { 891 return "https://www.facebook.com/sharer/sharer.php?u=" + url + '?utm_source=mobile&utm_medium=facebook&utm_campaign=compatir'; 892 } 893 function getTwitterLink( url, title ) { 894 return 'https://twitter.com/intent/tweet?text=' + encodeURIComponent( title ) + '&url=' + encodeURIComponent( url + '?utm_source=mobile&utm_medium=twitter&utm_campaign=compatir' ) + '&via=laopcion&related=laopcion'; 895 } 896 function getWhatsappLink( url, title ) { 897 return 'https://api.whatsapp.com/send?text=' + encodeURIComponent( title + ' ' + url + '?utm_source=mobile&utm_medium=whatsapp&utm_campaign=compatir' ); 898 } 899 function getEmailLink( url, title ) { 900 return 'mailto:?&body=' + encodeURIComponent( title + ' ' + url + '?utm_source=mobile&utm_medium=mail&utm_campaign=compatir' ); 901 } 902 903 function configModal( data ) { 904 data.url = data.url || window.location.href; 905 data.title = data.title || document.title; 906 907 ModalTemplateImage.style.backgroundImage = 'url('+data.image+')'; 908 ModalTemplateSection.textContent = data.section; 909 ModalTemplateTitle.textContent = data.title; 910 ModalTemplateFacebook.href = getFacebookLink( data.url ); 911 ModalTemplateTwitter.href = getTwitterLink( data.url, data.title ); 912 ModalTemplateEmail.href = getEmailLink( data.url, data.title ); 913 ModalTemplateWhatsapp.href = getWhatsappLink( data.url, data.title ); 914 } 915 916 function createElement( type, attributes, children, onClick ) { 917 var el = document.createElement( type ); 918 919 for ( var key in attributes ) { 920 el.setAttribute( key, attributes[ key ] ); 921 } 922 923 if ( typeof onClick == "function" ){ 924 el.addEventListener( 'click', onClick, false ); 925 } 926 927 if ( children ) { 928 for ( var i = 0, k = children.length; i < k; i++ ) { 929 if ( typeof children[i] === 'string' ) { 930 el.appendChild( document.createTextNode( children[i] ) ); 931 } else { 932 el.appendChild( children[i] ); 933 } 934 } 935 } 936 937 return el; 938 } 939 940 function createModalTemplate() { 941 942 var sharemodal = document.createElement( "div" ); 943 sharemodal.classList.add( "sharemodal" ); 944 945 var sharemodal__shadow = document.createElement( "span" ); 946 sharemodal__shadow.classList.add( "sharemodal__shadow" ); 947 sharemodal__shadow.addEventListener( 'click', closeModal, false ); 948 949 var sharemodal__content = document.createElement( "span" ); 950 sharemodal__content.classList.add( "sharemodal__content" ); 951 952 var sharemodal__news = document.createElement( "div" ); 953 sharemodal__news.classList.add( "sharemodal__news" ); 954 955 var sharemodal__newsmedia = document.createElement( "figure" ); 956 sharemodal__newsmedia.classList.add( "sharemodal__newsmedia" ); 957 958 var sharemodal__newsdata = document.createElement( "div" ); 959 sharemodal__newsdata.classList.add( "sharemodal__newsdata" ); 960 961 var sharemodal__newssection = document.createElement( "span" ); 962 sharemodal__newssection.classList.add( "sharemodal__newssection" ); 963 964 var sharemodal__newstitle = document.createElement( "span" ); 965 sharemodal__newstitle.classList.add( "sharemodal__newstitle" ); 966 967 var sharemodal__social = document.createElement( "div" ); 968 sharemodal__social.classList.add( "sharemodal__social" ); 969 970 var sharemodal__iconowhatsapp = document.createElement( "a" ); 971 sharemodal__iconowhatsapp.classList.add( "hrafa", "hrafa__whatsapp" ); 972 sharemodal__iconowhatsapp.setAttribute( "href", "#" ); 973 sharemodal__iconowhatsapp.setAttribute( "target", "_blank" ); 974 sharemodal__iconowhatsapp.setAttribute( "title", "Compartir por Whatsapp" ); 975 976 var sharemodal__iconofacebook = document.createElement( "a" ); 977 sharemodal__iconofacebook.classList.add( "hrafa", "hrafa__facebook" ); 978 sharemodal__iconofacebook.setAttribute( "href", "#" ); 979 sharemodal__iconofacebook.setAttribute( "target", "_blank" ); 980 sharemodal__iconofacebook.setAttribute( "title", "Compartir por facebook" ); 981 982 var sharemodal__iconotwitter = document.createElement( "a" ); 983 sharemodal__iconotwitter.classList.add( "hrafa", "hrafa__twitter" ); 984 sharemodal__iconotwitter.setAttribute( "href", "#" ); 985 sharemodal__iconotwitter.setAttribute( "target", "_blank" ); 986 sharemodal__iconotwitter.setAttribute( "title", "Compartir por twitter" ); 987 988 var sharemodal__iconomail = document.createElement( "a" ); 989 sharemodal__iconomail.classList.add( "hrafa", "hrafa__mail" ); 990 sharemodal__iconomail.setAttribute( "href", "#" ); 991 sharemodal__iconomail.setAttribute( "target", "_blank" ); 992 sharemodal__iconomail.setAttribute( "title", "Compartir por mail" ); 993 994 995 996 sharemodal__social.appendChild( sharemodal__iconowhatsapp ); 997 sharemodal__social.appendChild( sharemodal__iconofacebook ); 998 sharemodal__social.appendChild( sharemodal__iconotwitter ); 999 sharemodal__social.appendChild( sharemodal__iconomail ); 1000 1001 sharemodal__newsdata.appendChild( sharemodal__newssection ); 1002 sharemodal__newsdata.appendChild( sharemodal__newstitle ); 1003 1004 sharemodal__news.appendChild( sharemodal__newsmedia ); 1005 sharemodal__news.appendChild( sharemodal__newsdata ); 1006 1007 sharemodal__content.appendChild( sharemodal__news ); 1008 sharemodal__content.appendChild( sharemodal__social ); 1009 1010 sharemodal.appendChild( sharemodal__shadow ); 1011 sharemodal.appendChild( sharemodal__content ); 1012 1013 document.body.appendChild( sharemodal ); 1014 1015 1016 1017 1018 ModalTemplate = document.querySelector( '.sharemodal' ); 1019 1020 ModalTemplateImage = ModalTemplate.querySelector( '.sharemodal__newsmedia' ); 1021 ModalTemplateSection = ModalTemplate.querySelector( '.sharemodal__newssection' ); 1022 ModalTemplateTitle = ModalTemplate.querySelector( '.sharemodal__newstitle' ); 1023 ModalTemplateFacebook = ModalTemplate.querySelector( '.hrafa__facebook' ); 1024 ModalTemplateTwitter = ModalTemplate.querySelector( '.hrafa__twitter' ); 1025 ModalTemplateEmail = ModalTemplate.querySelector( '.hrafa__mail' ); 1026 ModalTemplateWhatsapp = ModalTemplate.querySelector( '.hrafa__whatsapp' ); 1027 1028 isTemplateGenerated = true; 1029 } 1030 1031 /** 1032 * Prototypes 1033 */ 1034 Constructor.prototype = { 1035 reinit: Constructor 1036 }; 1037 1038 /** 1039 * Export and Init 1040 */ 1041 window.ShareMobilePage = new Constructor(); 1042 1043})( window );var hra_suscribe = hra_suscribe || {}; 1044hra_suscribe.me = null; 1045 1046hra_suscribe.fn = { 1047 start: function() { 1048 hra_suscribe.me = document.querySelectorAll('.form__suscribe'); 1049 1050 for (var i = 0, k = hra_suscribe.me.length; i < k; i++) { 1051 if (hra_suscribe.me[i].classList.contains('generated')) { 1052 return; 1053 } 1054 1055 hra_suscribe.fn.generate(hra_suscribe.me[i]); 1056 } 1057 }, 1058 valid: function(email) {
1059 return /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/.test(email); 1060 }, 1061 generate: function(Suscribe) { 1062 Suscribe.addEventListener('submit', hra_suscribe.fn.onSubmit.bind(Suscribe), false); 1063 Suscribe.classList.add('generated'); 1064 }, 1065 onSubmit: function(e) { 1066 e.preventDefault(); 1067 1068 var Form = this, 1069 Input = Form.querySelector('input'); 1070 1071 if (hra_suscribe.fn.valid(Input.value)) { 1072 hra_suscribe.fn.send(Input.value, function(){ 1073 hra_suscribe.fn.showSuccess(Form, Input); 1074 /*}, function() { 1075 hra_suscribe.fn.showError(Input.parentNode, 'Hubo un error inesperado, intenta nuevamente.'); 1076 });*/ 1077 }, Input.parentNode); 1078 } else { 1079 hra_suscribe.fn.showError(Input.parentNode, 'Debes ingresar un e-mail válido'); 1080 return false; 1081 } 1082 }, 1083 showSuccess: function(Form, Input) { 1084 Form.classList.add('suscribe--success'); 1085 var Button = Form.querySelector( "button" ); 1086 Button.parentNode.removeChild( Button ); 1087 var HraFA = Form.querySelector( ".hrafa" ); 1088 HraFA.parentNode.removeChild( HraFA ); 1089 hra_suscribe.fn.hideError( Input ); 1090 hra_suscribe.fn.addSuccess( Input.parentNode, "Ya te has suscrito a nuestro newsletter." ); 1091 Input.parentNode.removeChild( Input ); 1092 }, 1093 showError: function(field, error) { 1094 hra_suscribe.fn.hideError( field ); 1095 var Temp = document.createElement( "p" ); 1096 Temp.classList.add( "hint", "error" ); 1097 Temp.textContent = error; 1098 1099 field.appendChild( Temp ); 1100 }, 1101 hideError: function(field) { 1102 var Error = field.querySelector(".hint.error"); 1103 if (Error){ 1104 Error.parentNode.removeChild(Error); 1105 } 1106 }, 1107 addSuccess: function(field, msg) { 1108 hra_suscribe.fn.hideError( field ); 1109 var Temp = document.createElement( "p" ); 1110 Temp.classList.add( "hint", "success" ); 1111 Temp.style.color = "#fff"; 1112 Temp.textContent = msg; 1113 1114 field.appendChild( Temp ); 1115 }, 1116 send: function(value, success_callback, error_callback) { 1117 var req = new XMLHttpRequest(); 1118 req.onreadystatechange = function() { 1119 if ( req.readyState == 4 && req.status == 200) { 1120 var reqJson = JSON.parse( req.responseText ); 1121 if( reqJson && reqJson.status == "ok" ){ 1122 if( success_callback ){ 1123 success_callback(); 1124 } 1125 }else{ 1126 /*if( error_callback ){ 1127 error_callback(); 1128 }*/ 1129 1130 hra_suscribe.fn.showError(error_callback, reqJson.message); 1131 } 1132 } 1133 }; 1134 var k__rand = Math.floor(Math.random() * 1000000); 1135 req.open( "GET", "/ajax/suscribe_newsletter.html?email="+value+"&newsletterID=1&m="+k__rand ); 1136 req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); 1137 req.send(); 1138 } 1139} 1140 1141try { 1142 hra_suscribe.fn.start(); 1143} catch (e) { 1144 console.error('HRA-Suscribe-Error '+e); 1145}
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.