1 2var ads_counts_ids = {}; 3 4var dconsole = { 5 _messages: [], 6 7 push: function(msg) { 8 this._messages.push(msg); 9 }, 10 11 log: function() { 12 console.log(...this._messages); 13 } 14}; 15 16Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { 17 18 switch (operator) { 19 case '==': 20 return (v1 == v2) ? options.fn(this) : options.inverse(this); 21 case '===': 22 return (v1 === v2) ? options.fn(this) : options.inverse(this); 23 case '!=': 24 return (v1 != v2) ? options.fn(this) : options.inverse(this); 25 case '!==': 26 return (v1 !== v2) ? options.fn(this) : options.inverse(this); 27 case '<': 28 return (v1 < v2) ? options.fn(this) : options.inverse(this); 29 case '<=': 30 return (v1 <= v2) ? options.fn(this) : options.inverse(this); 31 case '>': 32 return (v1 > v2) ? options.fn(this) : options.inverse(this); 33 case '>=': 34 return (v1 >= v2) ? options.fn(this) : options.inverse(this); 35 case '&&': 36 return (v1 && v2) ? options.fn(this) : options.inverse(this); 37 case '||': 38 return (v1 || v2) ? options.fn(this) : options.inverse(this); 39 default: 40 return options.inverse(this); 41 } 42}); 43 44var openWindow = function(url, winHeight, winWidth) { 45 var winTop = (screen.height / 2) - (winHeight / 2); 46 var winLeft = (screen.width / 2) - (winWidth / 2); 47 window.open(url, 'sharer', 'height=' + winHeight + ', width=' + winWidth + ', top=' + winTop + ', left=' + winLeft + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0'); 48} 49 50function add_param_to_all_href(name, value) { 51 let hostname = window.location.hostname; 52 let protocol = window.location.protocol; 53 let patt = new RegExp(".*" + hostname, "g"); 54 55 document.querySelectorAll('a').forEach(function (element) { 56 let href = element.getAttribute('href'); 57 58 if (href) { 59 if (href !== '#') { 60 let absolute_url_patt = new RegExp('^(?:[a-z]+:)?//', 'i'); 61 let is_absolute_url = absolute_url_patt.test(href); 62 63 if (!is_absolute_url) { 64 href = protocol + '//' + hostname + href; 65 } 66 67 try { 68 var url = new URL(href); 69 if (url.hostname.match(patt)) { 70 url.searchParams.set(name, value); 71 let new_url = url.href; 72 element.setAttribute('href', new_url); 73 } 74 } catch (error) { 75 // console.log(href); 76 // console.log(error); 77 } 78 } 79 } 80 }); 81} 82 83var show_post_tags = function(){ 84 85 var tags_data_divs = document.querySelectorAll('.js_single_post_tags'); 86 87 var source = document.getElementById("single_post_tags_template"); 88 89 tags_data_divs.forEach(function(tag_div) { 90 91 var template = Handlebars.compile(source.innerHTML); 92 93 var post_tags = tag_div.dataset.tags; 94 95 if(!post_tags.length){ 96 return; 97 } 98 99 var html = template({ 100 post_tags : JSON.parse(post_tags) 101 }); 102 103 tag_div.outerHTML = html; 104 105 }); 106} 107 108var show_related_posts = function(){ 109 110 var related_content_divs = document.querySelectorAll('.js_single_related_posts'); 111 112 var source = document.getElementById("single_related_posts_template"); 113 114 related_content_divs.forEach(function(related_div) { 115 116 var template = Handlebars.compile(source.innerHTML); 117 118 var related_posts = related_div.dataset.posts; 119 120 related_posts = JSON.parse(related_posts) 121 122 while(related_posts.length>4){ 123 related_posts.pop(); 124 } 125 126 var html = template({ 127 posts : related_posts 128 }); 129 130 related_div.outerHTML = html; 131 132 }); 133} 134 135var activate_rrss_share_buttons = function(){ 136 137 document.addEventListener('click', function(e) { 138 if (e.target.matches('[data-share-network]')) { 139 e.preventDefault(); 140 openWindow(e.target.getAttribute('href'), 500, 500); 141 } 142 }); 143 144} 145 146var loadEmbedRudoV2 = function(autostart) { 147 var source = document.getElementById("embed-rudo-template").innerHTML; 148 var template = Handlebars.compile(source); 149 //var url_autostart = '?autostart=false'; 150 var url_autostart = '?volume=0'; 151 152 if (typeof global_rudo_url == 'undefined' || !document.querySelector('.js_rudo_video') || document.querySelectorAll('.js_rudo_video').length <= 0) { 153 return false;
154 } 155 var jsRudoVideos = document.querySelectorAll('.js_rudo_video:not(.loaded)'); 156 if (jsRudoVideos.length <= 0) return false; 157 158 if (autostart == true) { 159 url_autostart = '?autostart=true'; 160 } 161 162 jsRudoVideos.forEach(function(item_rudo) { 163 164 165 if (item_rudo.innerHTML) { 166 item_rudo.classList.add('loaded'); 167 var content = item_rudo; 168 var dps_rudo = JSON.parse(content.innerHTML); 169 var ikey = content.dataset.ikey; 170 var ancho = parseInt(content.closest('.js-main-single-body').offsetWidth); 171 var alto = parseInt(ancho / 16) * 9; 172 var tag_imagen = content.closest('.js-main-single-body').querySelector('.js-content-img'); 173 var type_video; 174 175 content.innerHTML = ''; 176 177 if (dps_rudo.multiple == false) { 178 179 if(typeof dps_rudo.videos !=='undefined' && dps_rudo.videos.length>0){ 180 dps_rudo.video = dps_rudo.videos[0]; 181 } 182 183 if (typeof dps_rudo.video == 'undefined' || typeof dps_rudo.video.key == 'undefined') { 184 content.dataset.rudo = ''; 185 content.setAttribute('data-rudo', ''); 186 return false; 187 } 188 189 type_video = 'vod'; 190 if (dps_rudo.video.type == 'podcast') { 191 alto = '300'; 192 type_video = 'podcast'; 193 } 194 195 var url = global_rudo_url + '/' + type_video + '/' + dps_rudo.video.key + '/skin/simple/i/' + ikey + url_autostart; 196 197 var embed = template({ 198 url: url, 199 width: ancho, 200 height: alto 201 }); 202 203 tag_imagen.innerHTML = embed; 204 } else { 205 if (typeof dps_rudo.videos == 'undefined' || dps_rudo.videos.length <= 0) { 206 content.dataset.rudo = ''; 207 content.setAttribute('data-rudo', ''); 208 return false; 209 } 210 tag_imagen.innerHTML = ''; 211 for (var i = 0; i < dps_rudo.videos.length; i++) { 212 var rudo = dps_rudo.videos[i]; 213 alto = parseInt(ancho / 16) * 9; 214 type_video = 'vod'; 215 if (rudo.type == 'podcast') { 216 alto = '300'; 217 type_video = 'podcast'; 218 } 219 220 var url = global_rudo_url + '/' + type_video + '/' + rudo.key + '/skin/simple/i/' + ikey + url_autostart; 221 222 var embed = template({ 223 url: url, 224 width: ancho, 225 height: alto 226 }); 227 228 tag_imagen.innerHTML += embed; 229 }; 230 } 231 content.dataset.rudo = ''; 232 content.dataset.ikey = ''; 233 content.setAttribute('data-rudo', ''); 234 content.setAttribute('data-ikey', ''); 235 } 236 }); 237 238} 239 240var mejores_momentos_programas = function() { 241 242 var selectElement = document.querySelector('#mejores_momentos-programas'); 243 244 var value = selectElement.options[selectElement.selectedIndex].value; 245 246 if(value!="default"){ 247 248 var $link = document.getElementById('hidden_program_select_anchor_'+value); 249 $link.click(); 250 251 } 252 253} 254 255function js_fixed_iframe_rudo(event) { 256 return; 257 event.preventDefault(); 258 let element = event.currentTarget; 259 var iframe = document.getElementById("fixed-live-iframe"); 260 let src = element.getAttribute("data-iframe-rudo-src"); 261 iframe.setAttribute("src", src); 262 263 var iframeContainer = document.getElementById("fixed-live-box"); 264 iframeContainer.classList.remove('u-hidden'); 265 266 var button = iframeContainer.querySelector('button'); 267 268 button.addEventListener('click', function(e) { 269 e.preventDefault(); 270 iframe.setAttribute('src', 'about:blank'); 271 iframeContainer.classList.add('u-hidden'); 272 }); 273} 274 275var loadSearchForm = function(){ 276 277 // BUSCADOR 278 document.querySelector(".main-header-form.main-header__form").addEventListener("submit", function(event) { 279 event.preventDefault(); 280 var search = this.querySelector('.main-header-form__input').value; 281 search = search.replace(/á/g,'a'); 282 search = search.replace(/é/g,'e'); 283 search = search.replace(/ÃÂ/g,'i'); 284 search = search.replace(/ó/g,'o'); 285 search = search.replace(/ú/g,'u'); 286 search = search.replace(/ÃÂ/g,'A'); 287 search = search.replace(/Ãâ°/g,'E'); 288 search = search.replace(/ÃÂ/g,'I'); 289 search = search.replace(/Ãâ/g,'O'); 290 search = search.replace(/ÃÅ¡/g,'U'); 291 search = search.replace(/ñ/g,'n'); 292 search = search.replace(/Ãâ/g,'N'); 293 location.href = global_domain+'/search/'+encodeURI(search)+'/'; 294 }); 295 296} 297 298var isValidURL = function (string) { 299 var res = string.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g); 300 return (res !== null) 301} 302
303var request = function(endpoint='', method = 'GET', data={}){ 304 305 const options = { 306 method : method, 307 cache : 'no-cache', 308 }; 309 if(method.toLowerCase()!=='get' && method.toLowerCase()!=='head' ) 310 options.body = data; 311 312 const promise = fetch(endpoint,options); 313 return promise 314 .then( response => response.json() ); 315} 316 317var initSubmit = function(form){ 318 319 form.addEventListener('submit', (e)=>{ 320 321 e.preventDefault(); 322 323 let formData = new FormData(e.target); 324 325 request(e.target.getAttribute('action'), 'post', formData) 326 .then(response => { 327 328 alert(response.msg); 329 330 if(response.status==='error') 331 return; 332 333 e.target.reset(); 334 }) 335 .catch( e =>{ 336 console.error('[form contacto] Error en el servidor.'); 337 }); 338 339 }); 340 341} 342 343var init_post_forms = function () { 344 345 const forms = document.querySelectorAll('.js-form-content, form.wpcf7-form'); 346 347 if(forms.length===0) return; 348 349 forms.forEach( item => { 350 351 if(item.dataset.hasEventSubmit) 352 return; 353 354 item.dataset.hasEventSubmit = 1; 355 356 if( item.classList.contains('wpcf7-form') ){ 357 358 let input = document.createElement("input"); 359 input.setAttribute("type", "hidden"); 360 input.setAttribute("name", "action"); 361 input.setAttribute("value", "contacto_carolina"); 362 item.appendChild(input); 363 364 item.setAttribute('action', ''); 365 if(typeof global_url_ajax==='string' && global_url_ajax!=='') 366 item.setAttribute('action', global_url_ajax); 367 } 368 369 initSubmit(item); 370 }); 371 372} 373 374var onLoadPost = function(){ 375 loadEmbedRudoV2(false); 376 activate_rrss_share_buttons(); 377 show_post_tags(); 378 show_related_posts(); 379 init_post_forms(); 380} 381 382var setDfpData = function () { 383 384 let dfp_account_id = "143911651"; 385 let prefix_path = "/"+dfp_account_id+"/carolina.cl"; 386 let relative_url = window.location.pathname; 387 388 switch(true){ 389 case relative_url=="/participa/": 390 dfp_data.dataPath = prefix_path+"/interiores/"; 391 break; 392 case relative_url=="/carolinade/": 393 dfp_data.dataPath = prefix_path+"/interiores/"; 394 break; 395 case relative_url=="/senal-en-vivo/": 396 dfp_data.dataPath = prefix_path+"/interiores/"; 397 break; 398 case relative_url=="/tv/": 399 dfp_data.dataPath = prefix_path+"/interiores/"; 400 break; 401 case relative_url=="/carolina2/": 402 dfp_data.dataPath = prefix_path+"/interiores/"; 403 break; 404 case /^\/noticias\//.test(relative_url): 405 dfp_data.dataPath = prefix_path+"/interiores/"; 406 break 407 case /^\/mejores-momentos\//.test(relative_url): 408 dfp_data.dataPath = prefix_path+"/interiores/"; 409 break 410 case /^\/podcast\//.test(relative_url): 411 dfp_data.dataPath = prefix_path+"/interiores/"; 412 break 413 case /^\/mood\//.test(relative_url): 414 dfp_data.dataPath = prefix_path+"/interiores/"; 415 break 416 case /^\/programas\//.test(relative_url): 417 dfp_data.dataPath = prefix_path+"/interiores/"; 418 break 419 case /^\/search\//.test(relative_url): 420 dfp_data.dataPath = prefix_path+"/interiores/"; 421 break 422 case /\.html$/.test(relative_url): 423 dfp_data.dataPath = prefix_path+"/interiores/"; 424 break 425 default: 426 dfp_data.dataPath = prefix_path+"/home/"; 427 break; 428 } 429 430 dfp_data.custom_vars = {}; 431 432 dfp_data.custom_vars.dfp = dfp_data.dataPath.split(dfp_account_id)[1]; 433 434 dfp_data.custom_vars.url = window.location.href; 435 dfp_data.custom_vars.desc_url = window.location.href; 436 437 Object.defineProperty(dfp_data.custom_vars, "correlator", { 438 get: function() { 439 return Array.from({length: 24}, () => Math.floor(Math.random() * 10)).join(''); 440 }, 441 configurable: false, 442 enumerable: true, 443 }); 444 445 446 dfp_data.custom_vars.vpa = "auto"; 447 dfp_data.custom_vars.plcmt = 1; 448 dfp_data.custom_vars.dth = global_device == "desktop" ? 3 : 2; 449 450 451} 452 453var generate_ad_id = function(ad_id_base) { 454 // Verificar si la propiedad "ad_id_base" existe en ads_counts_ids 455 if (ads_counts_ids.hasOwnProperty(ad_id_base)) { 456 ads_counts_ids[ad_id_base].count++; 457 } else { 458 if (ads_counts_ids[ad_id_base] === undefined) { 459 ads_counts_ids[ad_id_base] = {}; 460 ads_counts_ids[ad_id_base].count = 1; 461 } 462 } 463 464 return ad_id_base + ads_counts_ids[ad_id_base].count; 465} 466 467function generateSizeMapping(slotSizes){ 468 469 var sizeMappingBuilder = googletag.sizeMapping(); 470 471 let largeScreenSizes = [[960,250],[960,180],[160,600],[970,90],[970,250],[960,90],[300,250],[336,280],[300,600],[120,600],[728,90],[1,1]]; 472 let mediumScreenSizes = [[160,600],[300,250],[336,280],[120,600],[728,90],[1,1]]; 473 let smallScreenSizes = [[300,250],[336,280],[320,100],[300,100],[320,50],[300,50],[1,1]]; 474 let zeroCrossZeroSizes = [[300,250],[336,280],[320,100],[300,100],[320,50],[300,50],[1,1]]; 475 476 let findedLargeScreenSizes = slotSizes.filter(elem1 => { 477 return largeScreenSizes.some(elem2 => elem2[0] === elem1[0] && elem2[1] === elem1[1]); 478 }); 479 480 if (findedLargeScreenSizes.length > 0) { 481 sizeMappingBuilder.addSize([992, 0], findedLargeScreenSizes); 482 } 483 484 let findedMediumScreenSizes = slotSizes.filter(elem1 => { 485 return mediumScreenSizes.some(elem2 => elem2[0] === elem1[0] && elem2[1] === elem1[1]); 486 }); 487 488 if (findedMediumScreenSizes.length > 0) { 489 sizeMappingBuilder.addSize([768, 0], findedMediumScreenSizes); 490 } 491 492 let findedSmallScreenSizes = slotSizes.filter(elem1 => { 493 return smallScreenSizes.some(elem2 => elem2[0] === elem1[0] && elem2[1] === elem1[1]); 494 }); 495 496 if (findedSmallScreenSizes.length > 0) { 497 sizeMappingBuilder.addSize([320, 0], findedSmallScreenSizes); 498 } 499 500 let findedZeroCrossZeroSizes = slotSizes.filter(elem1 => { 501 return zeroCrossZeroSizes.some(elem2 => elem2[0] === elem1[0] && elem2[1] === elem1[1]); 502 }); 503 504 if (findedZeroCrossZeroSizes.length > 0) { 505 sizeMappingBuilder.addSize([0, 0], findedZeroCrossZeroSizes); 506 } 507 508 return sizeMappingBuilder.build(); 509 510} 511 512 513googletag.cmd.push(function() { 514 515 const original = googletag.defineSlot; 516 517 googletag.defineSlot = function(adUnitPath, size, divId) { 518 519 // Solo muestra el log si divId existe y NO contiene la palabra "holos_" 520 if (divId && !divId.includes('holos_')) { 521 console.group('GPT defineSlot'); 522 console.log('Ad Unit:', adUnitPath); 523 console.log('Size:', size); 524 console.log('Div ID:', divId); 525 526 const err = new Error(); 527 const stack = err.stack 528 .replace(/^Error(:.*)?\n?/, '') // Elimina la palabra "Error" 529 .split('\n') 530 .filter(line => !line.includes('defineSlot')) // Quita tu wrapper 531 .filter(line => line.trim() !== '') // Elimina lÃneas vacÃas 532 .join('\n'); 533 534 console.log(stack); 535 536 console.groupEnd(); 537 } 538 539 // Se ejecuta SIEMPRE para que GPT funcione con normalidad en todos los divs 540 return original.call(this, adUnitPath, size, divId); 541 }; 542 543}); 544 545var loadAds = function () { 546 547 if (!document.querySelector(".rtb_slot")) return false;
548 549 var window_width = window.innerWidth; 550 551 // Si googletag no está definido, retorna false 552 if (typeof googletag === 'undefined' || typeof googletag.cmd == 'undefined') return false; 553 554 googletag.cmd.push(function() { 555 556 var rtb_slots_divs = document.querySelectorAll(".rtb_slot:not(.loaded):not(.only-focus)"); 557 558 rtb_slots_divs.forEach(function(rtb_div) { 559 560 rtb_div.classList.add("loaded"); 561 562 var slot = rtb_div.dataset.slot; 563 564 if(typeof dfp_data !="undefined" && typeof dfp_data.dataPath!="undefined"){ 565 slot = dfp_data.dataPath+slot; 566 } 567 568 if(typeof ocultar_publicidad_tmp == "undefined"){ 569 ocultar_publicidad_tmp = false; 570 } 571 572 if (ocultar_publicidad_tmp == true) { 573 574 var parent = rtb_div.closest('.the-banner'); 575 576 if (parent) { 577 parent.style.display = 'none'; 578 } 579 else{ 580 rtb_div.style.display = 'none'; 581 } 582 583 return; 584 } 585 586 var base_id = rtb_div.dataset.adunit; 587 588 var id = generate_ad_id(base_id); 589 590 var min_width = null; 591 592 var valid = true; 593 594 if (rtb_div.getAttribute('data-min-width') !== null && rtb_div.getAttribute('data-min-width') !== '') { 595 min_width = parseInt(rtb_divgetAttribute('data-min-width')); 596 } 597 598 if (min_width != null && window_width <= min_width) { 599 valid = false; 600 } 601 602 if (valid == true) { 603 604 var dimensions = rtb_div.dataset.dimensions; 605 606 if(!dimensions){ 607 dimensions="[]"; 608 } 609 610 dimensions = JSON.parse(dimensions); 611 612 const fechaLimite = new Date("2025-09-18"); 613 const fechaActual = new Date(); 614 615 if(base_id=="top" && fechaActual <= fechaLimite){ 616 617 let new_dimension = [970,250]; 618 619 if(!dimensions.some(size => size[0] === new_dimension[0] && size[1] === new_dimension[1])){ 620 dimensions.unshift(new_dimension); 621 } 622 623 } 624 625 // dimensions.sort(function(a, b) { 626 627 // if (a[0] !== b[0]) { 628 // if(global_device=="desktop"){ 629 // return b[0] - a[0]; 630 // } 631 // else{ 632 // return a[0] - b[0]; 633 // } 634 // } 635 636 // }); 637 638 // if(dimensions[0][0]==320){ 639 // dimensions.sort(function(a, b) { 640 // return b[1] - a[1]; 641 // }); 642 // } 643 644 var slotDiv = document.createElement('div'); 645 slotDiv.id = id; 646 647 rtb_div.appendChild(slotDiv); 648 649 var oop = rtb_div.dataset.oop; 650 651 if(typeof oop !== 'undefined' && oop=="true"){ 652 slot_ad = googletag.defineOutOfPageSlot(slot,id); 653 654 var format = rtb_div.dataset.format; 655 if(typeof format !== 'undefined' && (newFormat = Function("return " + format)()) !== undefined){ 656 try { 657 slot_ad = googletag.defineOutOfPageSlot(slot,newFormat); 658 } 659 catch { 660 return; 661 } 662 663 } 664 665 } 666 else{ 667 668 if(base_id=="skycraper_left"){ 669 return; 670 } 671 672 slot_ad = googletag.defineSlot(slot, dimensions, id); 673 674 let site_mapping = generateSizeMapping(dimensions,slot); 675 676 slot_ad.defineSizeMapping(site_mapping); 677 678 679 } 680 681 if(slot_ad==null){ 682 return; 683 } 684 685 686 if(typeof kv !== 'undefined' && kv !=''){ 687 688 // Object.entries(kv).forEach(function([key, value]) { 689 // if (value !== "") { 690 // googletag.pubads().setTargeting(key, value); 691 // } 692 // }); 693 694 const targetingUpdates = {}; 695 696 Object.entries(kv).forEach(([key, value]) => { 697 if (value !== "") { 698 // Si hay valor, lo preparamos para añadir o actualizar 699 targetingUpdates[key] = value; 700 } else { 701 // En la nueva API, asignar 'null' le dice a Google que BORRE solo este key, 702 // sin afectar el resto de tus targetings de la página. 703 targetingUpdates[key] = null; 704 } 705 }); 706 707 // Aplicamos toda la configuración en una sola llamada 708 googletag.setConfig({ 709 targeting: targetingUpdates 710 }); 711 712 } 713 714 slot_ad.addService(googletag.pubads()); 715 // googletag.pubads().enableSingleRequest(); 716 // googletag.pubads().collapseEmptyDivs(true, true); 717 718 // googletag.enableServices(); 719 720 googletag.display(id); 721 722 var refresh = rtb_div.dataset.reload; 723 724 var limit_refresh = rtb_div.dataset.limit_refresh; 725 726 if(limit_refresh){ 727 limit_refresh = Number(limit_refresh); 728 } 729 730 if(refresh){ 731 732 let count_intervals = 0; 733 734 var intervalID = setInterval(function() { 735 736 var allSlots = googletag.pubads().getSlots(); 737 738 // Busca el slot con el ID 'top' usando el m
738étodo find 739 var specificSlot = allSlots.find(function(slot_tmp) { 740 var slotIdMatches = slot_tmp.getSlotElementId() === id; 741 return slotIdMatches; 742 }); 743 744 if(!specificSlot){ 745 746 specificSlot = allSlots.find(function(slot_tmp) { 747 var slotAdUnitMatches = slot_tmp.getAdUnitPath() === slot; 748 return slotAdUnitMatches; 749 }); 750 } 751 752 if(specificSlot){ 753 console.log("dps refresh ad "+id); 754 googletag.pubads().refresh([specificSlot]); 755 756 count_intervals++; 757 758 if (limit_refresh && count_intervals >= limit_refresh) { 759 console.log("dps delete refresh for ad "+id+" after "+limit_refresh+" times"); 760 clearInterval(intervalID); 761 } 762 763 } 764 else{ 765 console.log("dps not found ad "+id); 766 window.clearInterval(intervalID); 767 } 768 769 }, refresh*1000); 770 } 771 772 } 773 774 775 }); 776 777 }); 778 779 780 googletag.cmd.push(function() { 781 googletag.pubads().addEventListener('slotRenderEnded', function(event) { 782 // Obtén el ID del slot 783 var slotId = event.slot.getSlotElementId(); 784 785 if(!event.isEmpty && slotId=="itt1"){ 786 itt_script(slotId); 787 } 788 }); 789 }); 790 791} 792 793var itt_script = function(slot_id){ 794 795 let totalSeconds = 14; 796 const $modal = document.querySelector('.itt-modal'); 797 798 var slot_dom = document.getElementById(slot_id); 799 800 801 // if (slot_dom.style.display === 'none') { 802 // $modal.remove(); 803 // } 804 805 $modal.classList.remove("u-hidden"); 806 const $modalText = document.querySelector('.modal__text'); 807 const $modalButton = document.querySelector('.modal__button'); 808 809 // Inicialmente, oculta el botón de cerrar 810 $modalButton.classList.add("u-hidden"); 811 812 const updateModalText = setInterval(() => { 813 let seconds = totalSeconds--; 814 815 if (seconds === 0) { 816 hideModal(); 817 } else { 818 $modalText.innerHTML = "Este aviso se cerrará en " + seconds + " segundos "; 819 } 820 }, 1000); 821 822 const hideModal = () => { 823 clearInterval(updateModalText); 824 $modalText.innerHTML = "Este aviso se cerrará "; 825 $modal.remove(); 826 } 827 828 setTimeout(() => { 829 $modalButton.classList.remove("u-hidden"); 830 }, 2000); 831 832 $modalButton.addEventListener('click', hideModal); 833 834} 835 836var load_img_placeholders_ads = function(){ 837 838 if (!document.querySelector(".rtb_slot")) return false; 839 840 let placeholders_domains = "https://placehold.co/"; 841 let bg_color = "yellow"; 842 let txt_color = "black"; 843 844 let rtb_slots_divs = document.querySelectorAll(".rtb_slot:not(.loaded):not(.only-focus)"); 845 846 rtb_slots_divs.forEach(function(rtb_div) { 847 848 rtb_div.classList.add("loaded"); 849 850 let demoSize = rtb_div.dataset.demosize; 851 852 if(!demoSize){ 853 return; 854 } 855 856 demoSize = JSON.parse(demoSize); 857 858 let width = demoSize[0]; 859 let height = demoSize[1]; 860 861 let src = placeholders_domains+width+"x"+height+"/"+bg_color+"/"+txt_color; 862 863 let ad_img = document.createElement('img'); 864 865 ad_img.src = src; 866 867 rtb_div.append(ad_img); 868 869 }); 870 871 872} 873 874var player_audio = function(){ 875 876 var audioButton = document.querySelector('.js_action_audio_player'); 877 878 if(!audioButton){ 879 return; 880 } 881 882 883 var audio = document.getElementById('audio_player'); 884 885 const starVol = 0.7; 886 887 audio.volume = starVol; 888 889 // Agrega el event listener para el evento 'click' 890 audioButton.addEventListener('click', function(event) { 891 event.preventDefault(); 892 // Verifica si el elemento tiene la clase 'play' 893 if (audioButton.classList.contains('fa-play')) { 894 // Si tiene la clase 'play', la remueve y agrega la clase 'pause' 895 audioButton.classList.remove('fa-play'); 896 audioButton.classList.add('fa-pause'); 897 audio.play(); 898 } else if (audioButton.classList.contains('fa-pause')) { 899 // Si tiene la clase 'pause', la remueve y agrega la clase 'play' 900 audioButton.classList.remove('fa-pause'); 901 audioButton.classList.add('fa-play'); 902 audio.pause(); 903 } 904 }); 905 906 907 const slider = document.getElementById('slider'); 908 909 noUiSlider.create(slider, { 910 start: starVol*100, 911 connect: [true, false], 912 range: { 913 'min': 0, 914 'max': 100 915 } 916 }); 917 918 slider.noUiSlider.on('update', (values) => { 919 const value = values[0]/100; 920 audio.volume = value; 921 }); 922 923} 924 925var setDfpCustomToIframes = function(){ 926 927 const class_loaded = "dfp_loaded"; 928 929 const filter = [ 930 // 'rudo.video', 931 'mdstrm.com' 932 ]; 933 934 const iframes = Array.from(document.querySelectorAll('iframe[data-src]')) 935 .filter(iframe => 936 !iframe.classList.contains(class_loaded) && 937 filter.some(domain => iframe.getAttribute('data-src').includes(domain)) 938 ); 939
940 iframes.forEach(iframe => { 941 let url = null; 942 943 iframe.classList.add(class_loaded); 944 945 url = iframe.getAttribute('data-src'); 946 947 const matchedDomain = filter.find(domain => url.includes(domain)); 948 949 if (url) { 950 let new_url = add_to_iframe_for_vast_params(url,matchedDomain); 951 iframe.setAttribute('data-src', new_url); 952 if (iframe.classList.contains('js_keep_type_src')) { 953 iframe.setAttribute('data-src', new_url); 954 } 955 else{ 956 iframe.removeAttribute('data-src'); 957 iframe.setAttribute('src', new_url); 958 } 959 960 } 961 }); 962 963} 964 965var add_to_iframe_for_vast_params = function(url,matchedDomain) { 966 if (!/^https?:\/\//i.test(url)) { 967 url = "https://" + url; 968 } 969 970 let new_url = url; 971 if(matchedDomain=="mdstrm.com"){ 972 const urlObj = new URL(url); 973 const params = urlObj.searchParams; 974 975 for (const [key, value] of Object.entries(dfp_data.custom_vars)) { 976 console.log(key); 977 if (!params.has("custom."+key)) { 978 params.set("custom."+key, value); 979 } 980 } 981 982 if (typeof kv === "object") { 983 //Construir string estilo query 984 //delete kv.keywords; 985 const kvString = Object.entries(kv) 986 .map(([k,v]) => `${k}=${v}`) 987 .join("&"); 988 989 //Encodear TODO como un unico valor 990 params.set("custom.kv", encodeURIComponent(kvString)); 991 992 // Opcional: agregar url y desc_url 993 params.set("custom.url", encodeURIComponent(window.location.href)); 994 params.set("custom.desc_url", encodeURIComponent(window.location.href)); 995 } 996 997 new_url = urlObj.toString(); 998 999 } 1000 return new_url; 1001} 1002 1003var load_main_player_home = function () { 1004 1005 if ( 1006 typeof window !== 'undefined' && 1007 window.MAIN_PLAYER_BOX && 1008 typeof window.MAIN_PLAYER_BOX.updateMainPlayerBox === 'function' 1009 ) { 1010 window.MAIN_PLAYER_BOX.updateMainPlayerBox(); 1011 } 1012 1013} 1014 1015document.addEventListener("DOMContentLoaded", function(event) { 1016 setDfpData(); 1017 1018 setDfpCustomToIframes(); 1019 1020 load_main_player_home(); 1021 1022 onLoadPost(); 1023 1024 player_audio(); 1025 1026 const url = new URL(window.location.href); 1027 const params = new URLSearchParams(url.search); 1028 1029 if (params.get('img_demo_ads') === '1') { 1030 load_img_placeholders_ads(); 1031 } 1032 else{ 1033 1034 let relative_url = window.location.pathname; 1035 1036 1037 if(relative_url=="/senal-en-vivo/"){ 1038 setTimeout(() => { 1039 loadAds(); 1040 }, "3000"); 1041 } 1042 else{ 1043 loadAds(); 1044 } 1045 1046 1047 1048 } 1049 1050 1051 1052 loadSearchForm(); 1053 1054 //ESTO DEBE IR AL ULTIMO EN MODO DEV 1055 //add_param_to_all_href("new_carolina",1); 1056});
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.