1 2 3var realtime_length = undefined; 4 5var update_realtime_items = true; 6 7 8 9var realTimeFunctions = { 10 11 url : 'https://media.eldinamo.cl', 12 13 path : 'real_time', 14 15 $element : jQuery('.js-rtb-real-time'), 16 17 attrs : ['key'], 18 19 handlebars_id : false, 20 21 onLoadFunction : null, //FUNCION A EJECUTAR AL CARGAR EL HTML 22 23 is_mobile : function(){ 24 25 var check = false; 26 27 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); 28 29 return check; 30 31 32 33 // if(typeof window.orientation!='undefined') 34 35 // return true; 36 37 // else 38 39 // return false; 40 41 }, 42 43 create : function(){ 44 45 var $element = this.$element; 46 47 if(typeof $element=='undefined' || $element=='' ){ 48 49 console.log('Elemento no definido'); 50 51 return false; 52 53 } 54 55 56 57 58 59 if($element.length>0){ 60 61 $element.each(function(i, item){ 62 63 var $item = jQuery(item); 64 65 var attrs = $item.data(); 66 67 var file = realTimeFunctions.getFileUrl(attrs.key); 68 69 if(file!=false){ 70 71 realTimeFunctions.getJson($item, file); 72 73 } 74 75 }); 76 77 } 78 79 80 81 }, 82 83 getAttr : function(data){ 84 85 if(typeof data!='object' ){ 86 87 return []; 88 89 } 90 91 var attrs = this.attrs; 92 93 var data_attr = {}; 94 95 $.each(data, function(i,item){ 96 97 data_attr[i] = ''; 98 99 if( attrs.indexOf(i)>=0 ){ 100 101 data_attr[i] = item; 102 103 } 104 105 }); 106 107 return data_attr; 108 109 }, 110 111 getFileUrl : function(key){ 112 113 if(typeof key!='string' || key==''){ 114 115 return false; 116 117 } 118 119 var random = Math.floor((Math.random() * 10000) + 1); 120 121 if(this.path!='') 122 123 return this.url+'/'+this.path+'/'+key+'.json?r='+random; 124 125 else 126 127 return this.url+'/'+key+'.json?r='+random; 128 129 }, 130 131 getJson : async function($element, url){ 132 133 jQuery.ajax({ 134 135 url: url, 136 137 dataType: 'json', 138 139 cache: false, 140 141 success: async function(data) { 142 143 if (typeof data !== 'object' || typeof data.key === 'undefined') { 144 145 return false; 146 147 } 148 149 150 151 update_realtime_items = false; 152 153 154 155 if(typeof realtime_length == "undefined"){ 156 157 update_realtime_items = true; 158 159 } 160 161 else if(realtime_length !== data.total){ 162 163 update_realtime_items = true; 164 165 } 166 167 168 169 realtime_length = data.total; 170 171 172 173 if(!update_realtime_items){ 174 175 console.log("No actualizamos realtime"); 176 177 return; 178 179 } 180 181 182 183 var html = await realTimeFunctions.html(data); 184 185 186 187 $element.html(html); 188 189 190 191 // FUNCION AL CARGAR EL HTML 192 193 if (typeof realTimeFunctions.onLoadFunction === 'function') { 194 195 realTimeFunctions.onLoadFunction(); 196 197 } 198 199 200 201 202 203 if ( typeof window.instgrm !== 'undefined' ) { 204 205 window.instgrm.Embeds.process(); 206 207 } 208 209 210 211 }, 212 213 error: function(error) { 214 215 console.log("error al cargar"); 216 console.log(error); 217 218 } 219 220 }); 221 222 }, 223 224 html : async function(json_data){ 225 226 var html = ''; 227 228 229 230 231 232 if(this.handlebars_id!=false && typeof this.handlebars_id=='string' && jQuery(this.handlebars_id)[
2320] ){ 233 234 235 236 var source = jQuery(this.handlebars_id).html(); 237 238 var template = Handlebars.compile(source); 239 240 html = template({data:json_data}); 241 242 } 243 244 else{ 245 246 247 248 var html_item = ''; 249 250 if(json_data.items.length>0){ 251 252 if(global_section == 'home'){ 253 width_mm = '100%'; 254 }else{ 255 width_mm = '90%'; 256 } 257 258 titulo_mm = `<a href="${json_data.enlace}">` 259 +`<h4 class="the-bag | all:my-end-20" data-color="yellow">${json_data.title}</h4>` 260 +`</a>` 261 262 for (var i = 0; i < json_data.items.length; i++) { 263 264 var item = json_data.items[i]; 265 266 var title = item.title; 267 268 var imagen = ''; 269 270 var block_img = ''; 271 272 var style_article = 'style="--grid-cols: 1fr; padding: 0.5rem;"'; 273 274 275 if(item.url!=''){ 276 277 title = '<a href="'+item.url+'" class="the-card__permalink" target="_blank">'+item.title+'</a>'; 278 279 imagen = await realTimeFunctions.obtenerImagenMeta(item.url); 280 281 block_img = '<div class="the-card__media">' 282 283 +'<img loading="lazy" src="'+imagen+'" alt="'+item.title+'" width="222" height="131" class="the-card__image | u-aspect-ratio" style="--aspect: 222/131;" />' 284 285 +'</div>'; 286 287 style_article = 'style="--grid-cols: 1fr 8rem; background-color: #ddd; padding: 0.5rem;"'; 288 289 } 290 291 292 293 html_item += '<article class="the-card" data-layout="default" '+style_article+'>' 294 295 +'<div class="the-card__caption">' 296 297 +'<time datetime="" class="the-card__hour | all:my-end-4">'+item.hour+'</time>' 298 299 +'<h5 class="the-card__title | all:my-end-8">' 300 +title 301 +'</h5>' 302 303 +'<p class="the-card__text">'+item.content.replace(/<\/?p>/g, '')+'</p>' 304 305 +'</div>' 306 307 if(imagen){ 308 html_item += block_img; 309 } 310 311 312 html_item += '</article>'; 313 314 if(i < json_data.items.length -1){ 315 html_item += '<hr class="u-separator | all:my-12">'; 316 } 317 318 } 319 320 } 321 322 html = '<div class="highlight-section__item | timeline-section " style="width:'+width_mm+';"><h3 class="the-title | all:my-end-16">Minuto a minuto</h3>' 323 + titulo_mm 324 +'<div class="timeline-container">'+ html_item+'</div' 325 +'</div>'; 326 327 } 328 329 return html; 330 331 }, 332 333 obtenerImagenMeta: async function(url) { 334 try { 335 new_url = url.replace('https://eldinamo.test','https://www.eldinamo.cl'); 336 // Obtener el contenido HTML de la URL 337 const response = await fetch(new_url); 338 const html = await response.text(); 339 340 // Cargar el HTML en un DOMParser 341 const parser = new DOMParser(); 342 const doc = parser.parseFromString(html, 'text/html'); 343 344 // Buscar las meta tags 345 const metas = doc.querySelectorAll('meta'); 346 347 // Recorrer las meta tags en busca de og:image 348 for (let meta of metas) { 349 if (meta.getAttribute('property') === 'og:image') { 350 return meta.getAttribute('content'); // Retorna la URL de la imagen 351 } 352 } 353 } catch (error) { 354 console.error('Error al obtener la imagen meta:', error); 355 } 356 357 return null; 358 } 359 360 361 362}; 363 364 365 366// RESPONSIVE VIDEOS 367 368var setResponsiveVideo = function() { 369 370 var toResponsive = Array.prototype.join.call(arguments); 371 372 var $toResponsive = jQuery(toResponsive); 373 374 375 376 jQuery.each($toResponsive, function(i, el) { 377 378 var $element = jQuery(el); 379 380 var $parent = $element.parent(); 381 382 383 384 if (!$parent.hasClass('u-responsive-video')) 385 386 $element.wrap('<div class="u-responsive-video"></div>'); 387 388 }); 389 390}; 391 392 393 394// ****************************************************** 395 396// FUNCION A EJECUTAR AL CARGAR EL REAL TIME 397 398var onLoadRealtime = function(){ 399 400 // ****************************************************** 401 402 // RESPONSIVE VIDEO 403 404 setResponsiveVideo('iframe[src*="rudo"]', 'iframe[src*="youtube"]', 'iframe[src*="vimeo"]', 'video', 'audio', 'iframe[src*=docdroid]'); 405 406 // ****************************************************** 407 408} 409 410// ****************************************************** 411 412 413 414jQuery(document).ready(function(){ 415 416 realTimeFunctions.create(); 417 418 realTimeFunctions.onLoadFunction = onLoadRealtime; 419 420 setInterval(function(){ 421 422 realTimeFunctions.create(); 423 424 },50 * 1000); 425 426 setTimeout(function(){ 427 428 const timelineContainer = document.querySelector('.timeline-container'); 429 430 if(typeof timelineContainer == 'undefined' || timelineContainer == null) 431 return 432 433 // Manejo del arrastre vertical 434 let isDown = false;
435 let startY; 436 let scrollTop; 437 438 timelineContainer.addEventListener('mousedown', (e) => { 439 isDown = true; 440 timelineContainer.classList.add('active'); 441 startY = e.pageY - timelineContainer.offsetTop; 442 scrollTop = timelineContainer.scrollTop; 443 timelineContainer.style.cursor = "grabbing"; 444 }); 445 446 timelineContainer.addEventListener('mouseleave', () => { 447 isDown = false; 448 timelineContainer.classList.remove('active'); 449 timelineContainer.style.cursor = "grab"; 450 }); 451 452 timelineContainer.addEventListener('mouseup', () => { 453 isDown = false; 454 timelineContainer.classList.remove('active'); 455 timelineContainer.style.cursor = "grab"; 456 }); 457 458 timelineContainer.addEventListener('mousemove', (e) => { 459 if (!isDown) return; // Detiene la función si el mouse no está presionado 460 e.preventDefault(); 461 const y = e.pageY - timelineContainer.offsetTop; 462 const walk = (y - startY) * 2; // Multiplica el desplazamiento 463 timelineContainer.scrollTop = scrollTop - walk; // Resta el desplazamiento 464 }); 465 466 timelineContainer.addEventListener('touchstart', (e) => { 467 isDown = true; 468 startY = e.touches[0].pageY - timelineContainer.offsetTop; 469 scrollTop = timelineContainer.scrollTop; 470 timelineContainer.style.cursor = "grabbing"; 471 }); 472 473 timelineContainer.addEventListener('touchend', () => { 474 isDown = false; 475 timelineContainer.style.cursor = "grab"; 476 }); 477 478 timelineContainer.addEventListener('touchmove', (e) => { 479 if (!isDown) return; 480 e.preventDefault(); 481 const y = e.touches[0].pageY - timelineContainer.offsetTop; 482 const walk = (y - startY) * 2; // Multiplica el desplazamiento 483 timelineContainer.scrollTop = scrollTop - walk; 484 }); 485 486 timelineContainer.addEventListener('wheel', (e) => { 487 e.preventDefault(); // evita scroll de la página 488 489 // Puedes ajustar la velocidad multiplicando deltaY 490 const speed = 1; 491 timelineContainer.scrollTop += e.deltaY * speed; 492 }, { passive: false }); 493 494 // Evita la selección de texto al arrastrar 495 timelineContainer.addEventListener('mousedown', function (e) { 496 e.preventDefault(); 497 }); 498 499 },5 * 1000); 500 501 502});
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.