1/* 2 "breaking": { 3 "10368348": { 4 "type": 1, 5 "name": "Pilne" 6 } 7 }, 8 9 .page-header-large 10*/ 11 12var genesisRecommends = { 13 www_schema: '', 14 now: false, 15 loaded: false, 16 loading: false, 17 winOffset: 0, 18 fromHost: 1, 19 fromRoute: 0, 20 elements: [], 21 containers: '', 22 contextContainers: '', 23 currentID: 0, 24 currentLang: 1, 25 visitedSource: 'storage', 26 visited: [], 27 used: [], 28 aaUsed: [], 29 lastTL: [], 30 recommends: [], 31 breaking: [], 32 timeline: [], 33 topPromo: {}, 34 slots: { 35 index: 0, 36 max: 1, 37 }, 38 autoloadDisplayIndex: -1, 39 autoloadDeepData: false, 40 autoloadPlaceholder: false, 41 listIdents: { 42 'ad': 'ad', 43 'tl': 'timeline_elements', 44 'pa': 'authors_popular_elements', 45 'la': 'authors_latests_elements', 46 'pa2': 'authors_2_popular_elements', 47 'la2': 'authors_2_latests_elements', 48 'cp': 'category_popular_elements', 49 'cl': 'category_latests_elements', 50 'cp2': 'category_2_popular_elements', 51 'cl2': 'category_2_latests_elements', 52 'pp': 'premium_popular_elements', 53 'lp': 'premium_latests_elements', 54 'ps': 'sub_popular_elements', 55 'ls': 'sub_latests_elements', 56 'ph': 'host_popular_elements', 57 'lh': 'host_latests_elements', 58 'pg': 'global_popular_elements', 59 'lr': 'route_latests_elements', 60 'lsm': 'smaki_latests_elements', 61 'psm': 'smaki_popular_elements', 62 'lnm': 'newsmed_latests_elements', 63 'pnm': 'newsmed_popular_elements', 64 'lit': 'infotuba_latests_elements', 65 'pit': 'infotuba_popular_elements', 66 'lqz': 'quizik_latests_elements', 67 'pqz': 'quizik_popular_elements', 68 'n': 'native_elements', 69 'nspec1': 'native_elements_special_1' 70 }, 71 nextLists: { 72 'premium_popular_elements': ['lp', 'lr', 'lh', 'ph', 'pg'], 73 'premium_latests_elements': ['pp', 'lr', 'lh', 'ph', 'pg'], 74 'authors_popular_elements': ['pa2', 'pp', 'lp', 'lr', 'lh', 'ph', 'pg'], 75 'authors_latests_elements': ['la2', 'lp', 'pp', 'lr', 'lh', 'ph', 'pg'], 76 'authors_2_popular_elements': ['pa', 'pp','lp','lr','lh','ph','pg'], 77 'authors_2_latests_elements': ['la', 'lp','pp','lr','lh','ph','pg'], 78 'category_popular_elements': ['cl', 'cp2','lr','lh','ph','pg'], 79 'category_latests_elements': ['cp', 'cl2','lr','lh','ph','pg'], 80 'category_2_popular_elements': ['cl2', 'cp','lr','lh','ph','pg'], 81 'category_2_latests_elements': ['cp2', 'cl','lr','lh','ph','pg'], 82 'host_popular_elements': ['pg', 'lr', 'lh'], 83 'global_popular_elements': ['ph', 'lr', 'lh'], 84 'sub_popular_elements': ['ls', 'pg', 'ph', 'lr', 'lh'], 85 'sub_latests_elements': ['ps', 'lr', 'lh', 'pg', 'ph'], 86 'route_latests_elements': ['lh', 'ph', 'pg'], 87 'host_latests_elements': ['lr', 'ph', 'pg'], 88 'smaki_popular_elements': ['lsm', 'pg', 'lr', 'lh'], 89 'smaki_latests_elements': ['lr', 'lh', 'pg'], 90 'newsmed_popular_elements': ['lnm', 'pg', 'lr', 'lh'], 91 'newsmed_latests_elements': ['lr', 'lh', 'pg'], 92 'infotuba_popular_elements': ['lit', 'pg', 'lr', 'lh'], 93 'infotuba_latests_elements': ['lr', 'lh', 'pg'], 94 'quizik_popular_elements': ['lqz', 'pg', 'lr', 'lh'], 95 'quizik_latests_elements': ['lr', 'lh', 'pg'], 96 'native_elements': ['lr', 'lh', 'ph', 'pg'], 97 'native_elements_special_1': ['n', 'lr', 'lh', 'ph', 'pg'], 98 }, 99 template: '<a href="%url" title="%hint" data-id="%id">' + 100 '<strong class="t"><span>%title</span></strong>' + 101 '<p class="l"><i>%lead</i></p>' + 102 '<div class="c">%containers</div>' + 103 '<div class="a">' + 104 '<i class="fn">%author_fname</i> <i class="ln">%author_lname</i>' + 105 '</div>'+ 106 '<div class="i" data-image="">' + 107 '<img src="%image" alt="%hint" loading="lazy">' + 108 '</div>' + 109 '</a>', 110 _template: '<div class="news-data" data-href="%url" data-element-id="%id">'+
111 '<div class="news-author">'+ 112 '<span class="item-author">'+ 113 '<span><i class="fn">%author_fname</i> <i class="ln">%author_lname</i></span>'+ 114 '</span>'+ 115 '</div>'+ 116 '<div class="news-containers"><span class="item-containers">%containers</span></div>'+ 117 '<div class="news-titlelead-wrapper">'+ 118 '<a href="%url" class="news-title" title="%hint">'+ 119 '<strong><span>%title</span></strong>'+ 120 '<div class="news-lead"><i>%lead</i></div>'+ 121 '</a>'+ 122 '</div>'+ 123 '</div>'+ 124 '<div class="news-image news-image-lazyload" data-image="">'+ 125 '<a href="%url" data-opin="true">'+ 126 '<img src="%image" alt="%hint" loading="lazy" />'+ 127 '</a>'+ 128 '</div>', 129 // rem news-image-png dla png 130 131 init: function () { 132 let obj = this, 133 date = new Date(), 134 element = document.querySelector('#element'), 135 config = document.querySelector('div[data-genesis="recommend-config"]'); 136 this.visitedLoad(); 137 if (element && (element.dataset.type == 1) && (element.dataset.id > 0)) 138 { 139 this.currentID = element.dataset.id; 140 this.currentLang = element.dataset.lang; 141 this.visitedUpdate(this.currentID); 142 this.used.push(this.currentID); 143 } 144 else 145 { 146 // return false; 147 } 148 if (config) 149 { 150 this.fromHost = config.dataset.fromHost; 151 this.fromRoute = config.dataset.fromRoute; 152 this.contextContainers = config.dataset.containers; 153 this.containers = document.body.dataset.cntr; 154 } 155 this.now = date.toISOString(); 156 157 if (location.host.indexOf('dorzeczy') >= 0) 158 this.www_schema = 'dorzeczy'; 159 else 160 if ((location.host.indexOf('wprostukraine') >= 0) || (location.host.indexOf('ua.wprost') >= 0)) 161 this.www_schema = 'wprost_ukraine'; 162 else 163 if (location.host.indexOf('smaki') >= 0) 164 this.www_schema = 'smaki'; 165 else 166 if (location.host.indexOf('quizik') >= 0) 167 this.www_schema = 'quizik'; 168 else 169 if (location.host.indexOf('infotuba') >= 0) 170 this.www_schema = 'infotuba'; 171 else 172 this.www_schema = 'wprost'; 173 174 this.winOffset = (genesisPage.getHeight() * 0.8); 175 this.autoloadPlaceholder = document.querySelector('#articles-autoload'); 176 177 addCSSModule('module-box-list', '/_css/modules/box-list.css', 'ul.bl'); 178 179 window.onpopstate = function(event) { 180 location = document.location; 181 }; 182 document.addEventListener('scroll', function (event) { 183 obj.scrollPage(event); 184 }); 185 186 if ((!this.loaded) && (!this.loading)) 187 { 188 this.load().then((relationsData) => { 189 // console.log('relationsData', relationsData); 190 if (typeof relationsData == 'object' && relationsData !== null) 191 { 192 if (typeof relationsData.recommends == 'object') 193 { 194 obj.recommends = relationsData.recommends 195 } 196 if (typeof relationsData.breaking == 'object') 197 { 198 obj.breaking = relationsData.breaking; 199 obj.markBreakingNews(); 200 } 201 /* 202 if (typeof relationsData.timeline == 'object') 203 { 204 this.timeline = relationsData.timeline 205 } 206 */ 207 if (typeof relationsData.top_promo == 'object') 208 { 209 obj.topPromo = relationsData.top_promo 210 } 211 obj.loaded = true; 212 obj.loading = false;
213 obj.scrollPage(); 214 } 215 }) 216 } 217 }, 218 219 load: function () { 220 //console.log('genesisRecommends relations load'); 221 let obj = this; 222 this.loading = true; 223 return new Promise ((resolve, reject) => { 224 fetch('/relations', { 225 method: 'post', 226 body: JSON.stringify({ 227 'recommends': 1, 228 //'no_search': 0, 229 'containers': obj.containers, 230 'contextContainers': obj.contextContainers, 231 'user': ((typeof deep_user_profile == 'object' && deep_user_profile !== null) ? deep_user_profile : false) 232 }), 233 headers: { 234 'Content-Type': 'application/json', 235 'Accept': 'application/json' 236 } 237 }) 238 .then(res => res.json()) 239 .then(json => { 240 resolve(json); 241 }) 242 .catch(error => { 243 reject(false); 244 }); 245 }); 246 }, 247 getNextArticle: function (list_ident, id_box, id_item) { 248 let id = this.nextID(list_ident); 249 // inne listy 250 if (id == 0) 251 { 252 if ((typeof this.nextLists[list_ident] == 'object') && (this.nextLists[list_ident].length > 0)) 253 { 254 for (let ni = 0; ni < this.nextLists[list_ident].length; ni++) 255 { 256 id = this.nextID(this.listIdents[this.nextLists[list_ident][ni]]); 257 if (id > 0) 258 break; 259 } 260 } 261 } 262 // usun uzywane 263 if (id == 0) 264 { 265 this.used = []; 266 this.visited = []; // MG 267 id = this.nextID(list_ident); 268 // inne listy 269 if (id == 0) 270 { 271 if ((typeof this.nextLists[list_ident] == 'object') && (this.nextLists[list_ident].length > 0)) 272 { 273 for (let ni = 0; ni < this.nextLists[list_ident].length; ni++) 274 { 275 id = this.nextID(this.listIdents[this.nextLists[list_ident][ni]]); 276 if (id > 0) 277 break; 278 } 279 } 280 } 281 } 282 return id; 283 }, 284 nextID: function (list_ident) { 285 var id = 0, 286 lr = this.recommends[list_ident]; 287 if (typeof lr == 'object') 288 { 289 for (var ai in lr) 290 { 291 let vp = this.visited.indexOf('' + lr[ai]), 292 up = this.used.indexOf('' + lr[ai]); 293 if ((vp < 0) && (up < 0) && (id == 0)) 294 { 295 id = parseInt(lr[ai]); 296 this.used.push('' + id); 297 break; 298 } 299 } 300 } 301 return id; 302 }, 303 scrollPage: function () { 304 var obj = this; 305 306 if (!this.loaded) 307 return false; 308 309 document.querySelectorAll('div[data-rm="genesis"]:not(.assigned)').forEach(function (element) { 310 if (genesisPage.isElementInViewport(element, 'topM100')) 311 obj.renderBox(element); 312 }); 313 314 if (this.autoloadPlaceholder) 315 { 316 if (this.autoloadPlaceholder.dataset.assigned == 1) 317 { 318 let aaSelIndex = -1, 319 firstAreaTitleTop = 0; 320 this.autoloadPlaceholder.style.backgroundColor = getComputedStyle(document.getElementById('content')).backgroundColor; 321 this.autoloadPlaceholder.querySelectorAll('div.element-next-area:not(.assigned)').forEach(function (element) { 322 if (genesisPage.isElementInViewport(element, 'top')) 323 { 324 obj.getAutoloadData(element.dataset.index, element.dataset.id); 325 // if (element.dataset.index == 3) 326 // obj.getAutoloadHomePage(); 327 } 328 }); 329 const firstArea = this.autoloadPlaceholder.querySelector('#element-next-area-0'); 330 if (firstArea) 331 { 332 const firstAreaTitle = firstArea.querySelector('.art-title'); 333 if (firstAreaTitle) 334 { 335 firstAreaTitleTop = firstAreaTitle.getBoundingClientRect().top + window.scrollY - this.winOffset; 336 } 337 for (let i = 0; i <= 6; i++) 338 { 339 const currArea = this.autoloadPlaceholder.querySelector('#element-next-area-' + i); 340 if (currArea) 341 { 342 const currAreaTitle = currArea.querySelector('.art-title'); 343 let currAreaTitleTop = 0; 344 if (currAreaTitle) 345 { 346 currAreaTitleTop = currAreaTitle.getBoundingClientRect().top + window.scrollY - this.winOffset; 347 if (currAreaTitleTop > 0 && firstAreaTitleTop > 0) 348 { 349 if (genesisScroll.direction == 'down') 350 { 351 if (genesisScroll.top > currAreaTitleTop) 352 aaSelIndex = i; 353 } 354 else 355 {
356 if ((i == 0) && (genesisScroll.top < firstAreaTitleTop)) 357 aaSelIndex = -1; 358 else 359 if (genesisScroll.top > currAreaTitleTop) 360 aaSelIndex = i; 361 } 362 } 363 } 364 } 365 } 366 } 367 this.propagateAutoloadArticle(aaSelIndex); 368 } 369 else 370 if (genesisScroll.top > 300) 371 { 372 this.initAutoload(); 373 } 374 } 375 }, 376 checkDirFilter: function (param, value, operator) { 377 switch (operator) 378 { 379 case 'in': 380 case 're': return (param.indexOf(value) >= 0); 381 case 'gt': return (param > value); 382 case 'lt': return (param < value); 383 case 'ge': return (param >= value); 384 case 'le': return (param <= value); 385 case 'ne': return (param != value); 386 default: return (param == value); 387 } 388 }, 389 getDirVariant: function (id_box) { 390 let obj = this, 391 list_name = false, 392 base_list = false, 393 default_list = false, 394 dir_list = false, 395 filters = false, 396 filter_count = 0, 397 filter_results = 0, 398 no_param = '[empty-filter-param]'; 399 400 if ((typeof genesisRecommendsList == 'object') && (typeof genesisRecommendsList[id_box] == 'object')) 401 base_list = genesisRecommendsList[id_box]; 402 else 403 return false; 404 405 //console.log('genesisRecommends genesisRecommendsList', id_box, base_list); 406 for (let r_list_key in base_list) 407 { 408 if (dir_list != false) 409 break; 410 if (r_list_key == 'default') 411 { 412 default_list = base_list[r_list_key]; 413 list_name = r_list_key; 414 } 415 if (typeof base_list[r_list_key]['filter'] == 'object') 416 { 417 filter_results = 0; 418 filter_count = 0; 419 filters = base_list[r_list_key]['filter']; 420//console.log('deep.event', genesisRecommendsList); 421//console.log('deep.event', filters); 422 for (let filter in filters) 423 { 424 let param = filters[filter][0]; 425 switch (param) 426 { 427 case 'p2s': 428 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 429 param = deep_user_profile.p2s; 430 else 431 param = no_param; 432 break; 433 case 'recency_score': 434 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 435 param = deep_user_profile.recency_score; 436 else 437 param = no_param; 438 break; 439 case 'frequency_score': 440 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 441 param = deep_user_profile.frequency_score; 442 else 443 param = no_param; 444 break; 445 case 'volume_score': 446 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 447 param = deep_user_profile.volume_score; 448 else 449 param = no_param; 450 break; 451 case 'rfv_score': 452 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 453 param = deep_user_profile.rfv_score; 454 else 455 param = no_param; 456 break; 457 case 'rfv_segment': 458 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 459 param = deep_user_profile.rfv_segment; 460 else 461 param = no_param; 462 break; 463 case 'purchased': 464 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 465 param = deep_user_profile.purchased 466 else 467 param = no_param; 468 break; 469 case 'purchase_intention': 470 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 471 param = deep_user_profile.purchase_intention; 472 else 473 param = no_param; 474 break; 475 case 'testAB': 476 case 'testgroup': 477 if (typeof deep_user_profile == 'object' && deep_user_profile !== null) 478 param = deep_user_profile.testgroup 479 else 480 param = no_param; 481 break; 482 case 'subscription': 483 param = ((winReadCookie('subscription') == 1) ? 1 : 0) 484 break; 485 default: 486 param = no_param; 487 break; 488 } 489 filter_count++; 490//console.log('deep.event', param, filters[filter][1], filters[filter][2]); 491//console.log('deep.event', param, obj.checkDirFilter(param, filters[filter][1], filters[filter][2]), deep_user_profile); 492 if ((param !== no_param) && (obj.checkDirFilter(param, filters[filter][1], filters[filter][2]))) 493 filter_results++; 494 } 495//console.log('deep.event', filter_count, filter_results) 496 if ((filter_count > 0) && (filter_count == filter_results) && (typeof base_list[r_list_key]['dir'] == 'object')) 497 { 498 dir_list = base_list[r_list_key]['dir']; 499 list_name = r_list_key; 500 } 501 } 502 } 503 if ((dir_list == false) && (typeof default_list == 'object')) 504 dir_list = default_list; 505 if (typeof dir_list == 'object') 506 { 507 if (!dir_list.length) 508 { 509 if ((genesisPage.isMobile) && (typeof dir_list.mobile == 'object') && (dir_list.mobile.length > 0)) 510 dir_list = dir_list.mobile; 511 else 512 if ((!genesisPage.isMobile) && (typeof dir_list.desktop == 'object') && (dir_list.desktop.length > 0)) 513 dir_list = dir_list.desktop; 514 } 515 516 /* 517 try 518 { 519 if (id_box == 'middle-list') 520 { 521 callDeepEvent({ 522 'event.type': 'test-r-pts-b', 523 'testdata': { 524 'p2s': ((typeof deep_user_profile == 'object') ? deep_user_profile.p2s : false), 525 'testgroup': ((typeof deep_user_profile == 'object') ? deep_user_profile.testgroup : false), 526 'user_data_source': deep_user_source, 527 'list_name': list_name 528 } 529 }); 530 } 531 } 532 catch(e) 533 { 534 } 535 */ 536 537 if (dir_list.length > 0) 538 return { 539 'dir': dir_list, 540 'name': list_name 541 }; 542 else 543 return false; 544 } 545 else 546 return false; 547 }, 548 renderBox: function (destObj, invisible, addWrapper) { 549 let obj = this 550 id_box = destObj.id, 551 pl_name = destObj.dataset.placement, 552 ids = '' + (destObj.dataset.ids || '').trim(), 553 hdr = destObj.dataset.header, 554 hdrClass = destObj.dataset.headerClass || '', 555 listClass = destObj.dataset.class || '', 556 itemClass = destObj.dataset.itemClass || '', 557 adsGap = destObj.dataset.adsGap, 558 p_dir = '' + ( genesisPage.isMobile ? (destObj.dataset.mobDir ? destObj.dataset.mobDir : (destObj.dataset.dir || '')) : (destObj.dataset.dir || '')).trim(), 559 a_dir = (p_dir != '') ? p_dir.split(',') : false, 560 id_dir = (ids != '') ? ids.split(',') : false, 561 v_dir = this.getDirVariant(id_box), 562 redraw = (destObj.dataset.mode == 'redraw'), 563 header = '', 564 dir_name = 'default'; 565 566 if ((v_dir !== false) && (typeof v_dir == 'object') && (v_dir.dir.length > 0)) 567 { 568 a_dir = v_dir.dir; 569 dir_name = v_dir.name; 570 } 571 if ((id_dir != false) && (id_dir.length > 0)) 572 { 573 a_dir = id_dir; 574 dir_name = 'DIR_BY_PARAMS_IDS'; 575 } 576 577 const isVisible = !!( 578 destObj.offsetWidth || 579 destObj.offsetHeight || 580 destObj.getClientRects().length 581 ); 582 583 if ((isVisible || invisible) && (typeof a_dir == 'object') && (a_dir.length > 0)) 584 { 585 let l1, l2, ir = 0; 586 587 if (!id_box) 588 { 589 id_box = this.createID(); 590 destObj.id = id_box; 591 } 592 if (!pl_name) 593 pl_name = id_box; 594 595 if (adsGap && (adsGap > 0) && (dir_name == 'DIR_BY_PARAMS_IDS')) 596 { 597 let temp_dir = []; 598 for (let i = 0; i < a_dir.length; i++) 599 { 600 if ((i % adsGap == 0) && (i >
600 0)) 601 temp_dir.push('ad'); 602 temp_dir.push(a_dir[i]); 603 } 604 a_dir = temp_dir; 605 } 606 607 destObj.classList.add('assigned'); 608 destObj.style.height = 'auto'; 609 610 if (!redraw) 611 { 612 if ((typeof hdr == 'string') && (hdr.toLowerCase() != 'false')) 613 header = '<strong' + (((typeof hdrClass == 'string') && (hdrClass.toLowerCase() != 'false')) ? ' class="' + hdrClass + '"' : '') + '>' + hdr + '</strong>'; 614 if (addWrapper) 615 destObj.innerHTML = '<div class="wrapper">' + header + '<ul class="' + listClass + '"></ul></div>'; 616 else 617 destObj.innerHTML = header + '<ul class="' + listClass + '"></ul>'; 618 } 619 620 if (listClass.indexOf('bl') >= 0) 621 l1 = addCSSModule('module-box-list', '/_css/modules/box-list.css', 'ul.bl'); 622 if (listClass.indexOf('box-list') >= 0) 623 l2 = addCSSModule('module-box-list-old', '/_css/modules/_box-list.css', 'ul.box-list'); 624 625 const destList = destObj.querySelector('ul'); 626 if (destList) 627 { 628 for (let i = 0; i < a_dir.length; i++) 629 { 630 let li = obj.listIdents[a_dir[i]], 631 id = 0, 632 li_template = '' + ((listClass.indexOf('box-list') >= 0) ? obj._template : obj.template); 633 /* 634 if (a_dir[i] == 'tl') 635 { 636 id = obj.timeline[ir]; 637 if (id == obj.currentID) 638 { 639 ir++; 640 id = obj.timeline[ir]; 641 } 642 li_template = ''; 643 ir++; 644 } 645 else 646 */ 647 if ((dir_name == 'DIR_BY_PARAMS_IDS') && (a_dir[i] > 0)) 648 { 649 id = a_dir[i]; 650 } 651 else 652 if (a_dir[i] == 'ad') 653 { 654 if ((typeof genesisAds == 'object') && (typeof genesisAdsUnits == 'object') && (typeof genesisAdsUnits.recommended == 'object') && (typeof genesisAdsUnits.recommended[obj.slots.index] == 'object')) 655 { 656 let slotID = 'ad-recommends-' + genesisAds.createSlotID(), 657 floating = false; 658 659 if ((typeof genesisAdsUnits['recommended'][obj.slots.index]['genesis-hb'] == 'object') && (genesisAdsUnits['recommended'][obj.slots.index]['genesis-hb'] != null)) 660 { 661 if (genesisAdsUnits['recommended'][obj.slots.index]['genesis-hb']['id']) 662 slotID = genesisAdsUnits['recommended'][obj.slots.index]['genesis-hb']['id']; 663 if (genesisAdsUnits['recommended'][obj.slots.index]['genesis-hb']['floating']) 664 floating = (genesisAdsUnits['recommended'][obj.slots.index]['genesis-hb']['floating'] === true); 665 destList.insertAdjacentHTML('beforeEnd', 666 '<li id="' + id_box + '-' + i + '" data-list="' + a_dir[i] + '" data-id="' + id + '" data-name="' + dir_name + '"'+ 667 'class="bli bli-ad bli-tp-billboard size-3x1">' + 668 '<aside class="box-aside ad-aside' + (floating ? ' box-aside-floating' : '') + '"><div id="' + slotID + '" data-ad="genesis" data-type="genesis-hb" class="slot-recommends" data-index="' + obj.slots.index + '"></div></aside></li>' 669 ); 670 setTimeout(function() { 671 let placeholder = document.getElementById(slotID); 672 if (placeholder) 673 { 674 googletag.cmd.push(function() { 675 genesisAds.createDynamicSloByIndex('recommended', placeholder.dataset.index, 'genesis-hb', placeholder.id, false, 'load'); 676 }); 677 } 678 }, 50); 679 obj.slots.index++; 680 continue; 681 } 682 else 683 if ((typeof genesisAdsUnits['recommended'][obj.slots.index]['gam'] == 'object') && (genesisAdsUnits['recommended'][obj.slots.index]['gam'] != null)) 684 { 685 if (genesisAdsUnits['recommended'][obj.slots.index]['gam']['id']) 686 slotID = genesisAdsUnits['recommended'][obj.slots.index]['gam']['id']; 687 if (genesisAdsUnits['recommended'][obj.slots.index]['gam']['floating']) 688 floating = (genesisAdsUnits['recommended'][obj.slots.index]['gam']['floating'] === true); 689 destList.insertAdjacentHTML('beforeEnd', 690 '<li id="' + id_box + '-' + i + '" data-list="' + a_dir[i] + '" data-id="' + id + '" data-name="' + dir_name + '"'+ 691 'class="bli bli-ad bli-tp-billboard size-3x1">' + 692 '<aside class="box-aside ad-aside' + (floating ? ' box-aside-floating' : '') + '"><div id="' + slotID + '" data-ad="genesis" data-type="gam" class="slot-recommends" data-index="' + obj.slots.index + '"></div></aside></li>' 693 ); 694 setTimeout(function() { 695 let placeholder = document.getElementById(slotID); 696 if (placeholder) 697 { 698 if (genesisAds.createDynamicSloByIndex('recommended', placeholder.dataset.index, 'gam', placeholder.id, false, 'load')) 699 genesisAds.eventGA('GAM Slot Created', {'placeholder': 'Recommended', 'type': 'GAM', 'index': placeholder.dataset.slots
699Index}); 700 else 701 genesisAds.eventGA('GAM Slot Failed', {'placeholder': 'Recommended', 'type': 'GAM', 'index': placeholder.dataset.slotsIndex}); 702 } 703 }, 250); 704 obj.slots.index++; 705 continue; 706 } 707 else 708 if ((typeof genesisAds == 'object') && (typeof genesisAdsUnits['recommended'][obj.slots.index]['mgid'] == 'object') && (genesisAdsUnits['recommended'][obj.slots.index]['mgid'] != null)) 709 { 710 if (genesisAdsUnits['recommended'][obj.slots.index]['mgid']['id']) 711 slotID = genesisAdsUnits['recommended'][obj.slots.index]['mgid']['id']; 712 destList.insertAdjacentHTML('beforeEnd', 713 '<li id="' + id_box + '-' + i + '" data-list="' + a_dir[i] + '" data-id="' + id + '" data-name="' + dir_name + '"'+ 714 'class="bli bli-ad bli-tp-billboard size-3x1">' + 715 '<aside class="box-aside ad-aside"><div id="' + slotID + '" data-ad="genesis" data-type="mgid" class="slot-recommends" data-index="' + obj.slots.index + '" data-script="' + genesisAdsUnits['recommended'][obj.slots.index]['mgid']['script'] + '"></div></aside></li>' 716 ); 717 setTimeout(function() { 718 let placeholder = document.getElementById(slotID); 719 if (placeholder) 720 { 721 if (genesisAds.createDynamicSloByIndex('recommended', placeholder.dataset.index, 'mgid', placeholder.id, false, 'load')) 722 { 723 genesisAds.modules.mgid.obj.refresh(); 724 genesisAds.eventGA('Mgid Slot Created', {'placeholder': 'Recommended', 'type': 'Mgid', 'index': placeholder.dataset.slotsIndex}); 725 } 726 else 727 genesisAds.eventGA('Mgid Slot Failed', {'placeholder': 'Recommended', 'type': 'Mgid', 'index': placeholder.dataset.slotsIndex}); 728 } 729 }, 250); 730 obj.slots.index++; 731 continue; 732 } 733 } 734 } 735 else 736 { 737 id = this.getNextArticle(li, id_box, i); 738 } 739 740 if (id > 0) 741 { 742 li_template = '' + li_template.replace(/\%id/gi, 0) 743 .replace(/\%url/gi, '#" onclick="#') 744 .replace(/\%hint/gi, '') 745 .replace(/\%title/gi, '▇▇▇▇ ▇▇ ▇▇▇▇▇▇ ▇▇▇ ▇▇▇▇▇▇ ▇▇▇▇▇▇') 746 .replace(/\%image/gi, '/_i/pixel.png') 747 .replace(/\%containers/gi, ' ███ ██████ ███'); 748 destList.insertAdjacentHTML('beforeEnd', 749 '<li id="' + id_box + '-' + i + '" data-list="' + a_dir[i] + '" data-id="' + id + '" data-name="' + dir_name + '" '+ 750 'class="' + itemClass + '"><span class="temp">'+ li_template +'</span></li>' 751 ); 752
753 this.getStaticData(id_box, id_box + '-' + i, id, a_dir[i]); 754 } 755 } 756 } 757 if ((typeof checkDeep == 'function') && checkDeep()) 758 { 759 let p = { 760 'event.type': 'recommendations-visible', 761 'recommendation': {}, 762 'source': deep_init_content 763 }; 764 p.recommendation.placement = pl_name; 765 p.recommendation.list = dir_name; 766 callDeepEvent(p); 767 } 768 769 if ((typeof gtag == 'function') || (typeof GA_TRACKING_ID == 'string')) 770 { 771 gtag('event', 'Recommendations', { 772 action: 'Displayed', 773 placement: pl_name 774 }); 775 } 776 777 window.setTimeout(function() { 778 if (typeof afterRecommendRenderBox == 'function') 779 afterRecommendRenderBox(); 780 }, 100); 781 } 782 else 783 { 784 destObj.classList.add('assigned'); 785 destObj.style.display = 'none'; 786 } 787 }, 788 getStaticData: function (id_box, id_item, id, list) { 789 var obj = this, 790 schema = this.www_schema, 791 static_url = ''; 792 if ((list == 'lqz') || (list == 'pqz')) 793 schema = 'quizik'; 794 else 795 if ((list == 'lsm') || (list == 'psm')) 796 schema = 'smaki'; 797 else 798 if ((list == 'lit') || (list == 'pit')) 799 schema = 'infotuba'; 800 id = '' + id; 801 static_url = '/_f/static_texts/' + schema + '/' + id.substr(-4) + '/' + id + ((this.currentLang > 1) ? ('-' + this.currentLang) : '') + '.txt?dt=' + obj.now.substr(0, 17) + '00'; 802 //console.log('genesisRecommends getStaticData', id_box, id_item, id, list, static_url); 803 try 804 { 805 fetch(static_url, { 806 cache: 'no-cache', 807 }) 808 .then(res => res.json()) 809 .then(res => { 810 obj.renderBoxItem(id_box, id_item, id, list, res); 811 //console.log('genesisRecommends getStaticData', id_box, id_item, id, list, res); 812 }) 813 .catch(error => { 814 //console.error('genesisRecommends getStaticData', id_box, id_item, id, list, static_url, error); 815 static_url = '/' + id + '/file.static?txt=1&dt=' + obj.now.substr(0, 18)+'0'; 816 if ((list == 'lqz') || (list == 'pqz')) 817 static_url = 'https://quizik.pl' + static_url; 818 else 819 if ((list == 'lsm') || (list == 'psm')) 820 static_url = 'https://smaki.pl' + static_url; 821 else 822 if ((list == 'lit') || (list == 'pit')) 823 static_url = 'https://infotuba.pl' + static_url; 824 fetch(static_url, { 825 cache: 'no-cache', 826 }) 827 .then(res => res.json()) 828 .then(res => { 829 obj.renderBoxItem(id_box, id_item, id, list, res); 830 //console.log('genesisRecommends getStaticData', id_box, id_item, id, list, res); 831 }) 832 .catch(error => { 833 //console.error('genesisRecommends getStaticData 2', id_box, id_item, id, list, static_url); 834 }); 835 }); 836 } 837 catch(e) 838 { 839 //console.error('genesisRecommends getStaticData', e); 840 } 841 }, 842 843 renderBoxItem: function (id_box, id_item, id, list, json) { 844 //console.log('genesisRecommends renderBoxItem', id_box, id_item, id, list, json); 845 var obj = this; 846 obj.elements[json.id] = json; 847 848 let containers = '', // '<b style="background-color: #EEE; color: #000; padding: 10px;">
848' + list + '</b> '; 849 listClass = '', 850 listObj = document.querySelector('div#' + id_box), 851 itemObj = false; 852 853 if (!listObj) 854 return false; 855 856 itemObj = listObj.querySelector('li#' + id_item); 857 if (!itemObj) 858 return false; 859 860 listClass = listObj.dataset.class || ''; 861 862 if (typeof json.containers == 'object') 863 { 864 for (let c in json.containers) 865 containers += '<span class="cntr-' + json.containers[c].id + '">' + json.containers[c].name + '</span>'; 866 } 867 if (location.host.indexOf('wprost.ss') >= 0) 868 { 869 json.url = json.url.replace(/https/gi, 'http').replace(/wprost.pl/gi, 'wprost.ss'); 870 json.url = json.url.replace(/https/gi, 'http').replace(/quizik.pl/gi, 'quizik.wprost.ss'); 871 json.url = json.url.replace(/https/gi, 'http').replace(/smaki.pl/gi, 'smaki.wprost.ss'); 872 json.url = json.url.replace(/https/gi, 'http').replace(/newsmed.pl/gi, 'newsmed.wprost.ss'); 873 json.url = json.url.replace(/https/gi, 'http').replace(/infotuba.pl/gi, 'infotuba.wprost.ss'); 874 json.url = json.url.replace(/https/gi, 'http').replace(/www.wprostukraine.eu.pl/gi, 'ua.wprost.ss'); 875 } 876 if (location.host.indexOf('dorzeczy.ss') >= 0) 877 json.url = json.url.replace(/https/gi, 'http').replace(/dorzeczy.pl/gi, 'dorzeczy.ss'); 878 if (json.url.indexOf('@new_id_element@') > 0) 879 json.url = json.url.replace(/@new_id_element@/gi, json.id); 880 881 if (json.thumb.large.indexOf('wprost.pl') > 0) 882 { 883 json.thumb.large = json.thumb.large.replace(/:\/\/(\w*\.)/g, '://img.'); 884 } 885 if (json.thumb.large.indexOf('https://img.pl/') == 0) 886 { 887 json.thumb.large = json.thumb.large.replace('https://img.pl/', '/'); 888 } 889 890 let df_template = '' + ((listClass.indexOf('box-list') >= 0) ? obj._template : obj.template), 891 li_template = df_template.replace(/\%id/gi, json.id) 892 .replace(/\%url/gi, json.url) 893 .replace(/\%hint/gi, json.title.replace(/"/gi, '"')) 894 .replace(/\%lead/gi, ((json.lead_ent) ? json.lead_ent : json.lead).replace(/"/gi, '"')) 895 .replace(/\%title/gi, ((json.title_ent) ? json.title_ent : json.title).replace(/"/gi, '"')) 896 .replace(/\%image/gi, json.thumb.small) 897 .replace(/\%containers/gi, containers); 898 if ((typeof json.author == 'object') && ((json.author.first_name) || (json.author.last_name)) && (json.author.thumb)) 899 { 900 li_template = li_template.replace(/\%author_fname/gi, json.author.first_name) 901 .replace(/\%author_lname/gi, json.author.last_name); 902 } 903 itemObj.innerHTML = li_template; 904 905 let a = itemObj.querySelector('.a'), 906 i = itemObj.querySelector('.i'), 907 link = itemObj.querySelector('a'), 908 oldA = itemObj.querySelector('.news-author'); 909 if (li_template.indexOf('%author') > 0) 910 { 911 if (a) 912 a.remove(); 913 if (oldA) 914 oldA.remove(); 915 } 916 else 917 if ((typeof json.author == 'object') && ((json.author.first_name) || (json.author.last_name)) && (json.author.thumb)) 918 { 919 itemObj.classList.add('h-a', 'rec'); 920 a.insertAdjacentHTML('afterBegin', '<img src="' + json.author.thumb + '" alt="" width="40" height="40" loading="lazy">'); 921 } 922 923 if (i) 924 { 925 i.classList.add('rec'); 926 if (json.thumb.large.indexOf('.png') < 0) 927 i.style.backgroundColor = ((json.color) ? json.color : '#F0F0F0'); 928 else 929 i.classList.add('i-png'); 930 } 931 932 if (link) 933 { 934 link.addEventListener('click', function (event) { 935 const placement = listObj.dataset.placement || id_box, 936 index = Array.from(itemObj.parentNode.children).indexOf(itemObj) + 1; 937 if ((typeof gtag == 'function') || (typeof GA_TRACKING_ID == 'string')) 938 { 939 gtag('event', 'Recommendations', { 940 action: 'Recommendation Click', 941 placement: placement, 942 box: index, 943 from: obj.listIdents[list], 944 }); 945 } 946 if ((typeof deep_customer == 'object') && (typeof checkDeep == 'function') && checkDeep()) 947 { 948 let p = { 949 'event.type': 'recommendations-clicked', 950 'recommendation': { 951 'placement': placement, 952 'box': index, 953 'from': obj.listIdents[list], 954 'list': itemObj.dataset.name || '' 955 }, 956 'source': deep_init_content, 957 'dest': json.object 958 }; 959 callDeepEvent(p); 960 // console.log('deep.event', p.recommendation); 961 // alert('href ' + this.href + ' \n placement: ' + p.recommendation.placement + ' \n box: ' + p.recommendation.box + ' \n from: ' + p.recommendation.from + ' \n list: ' + p.recommendation.list ); 962 } 963 obj.visitedUpdate(this.dataset.id); 964 if (location.hostname == this.hostname) 965 location = this.href; 966 else 967 window.open(this.href); 968 event.stopPropagation(); 969 event.preventDefault(); 970 return false;
971 }); 972 } 973 if (typeof obj.breaking == 'object') 974 { 975 window.setTimeout(function() { 976 obj.markBreakingNews(); 977 }, 10); 978 } 979 }, 980 981 // AutoLoad //////////////////////////////////////////////////////////////// 982 983 initAutoload: function() { 984 const autoloadIdents = [ 985 'lr', 986 'n', 987 'pp', 988 'n', 989 'n', 990 'ph' 991 ]; 992 993 /* 994 if ((typeof gtag == 'function') || (typeof GA_TRACKING_ID == 'string')) 995 { 996 gtag('config', GA_TRACKING_ID, { 997 send_page_view: false 998 }); 999 } 1000 */ 1001 1002 // let autoloadIdents = ['lr', 'pp', 'n', 'ph', 'lp', 'lh']; 1003 1004 this.autoloadPlaceholder.dataset.assigned = 1; 1005 1006 // console.log('initAutoload 1', autoloadIdents); 1007 // console.log('initAutoload 2', autoloadIdents); 1008 1009 this.autoloadPlaceholder.insertAdjacentHTML( 1010 'beforeEnd', 1011 '<div id="articles-autoload-section-1" class="articles-autoload-section"></div>' + 1012 '<div id="articles-autoload-section-2" class="articles-autoload-section"></div>' 1013 ); 1014 const sec1 = this.autoloadPlaceholder.querySelector('#articles-autoload-section-1'), 1015 sec2 = this.autoloadPlaceholder.querySelector('#articles-autoload-section-2'); 1016 1017 for (let autoload_i = 0; autoload_i < 6; autoload_i++) 1018 { 1019 const aa = this.getNextAutoloadArticle(this.listIdents[autoloadIdents[autoload_i]]), 1020 sec = (autoload_i < 2 ? sec1 : sec2); 1021 //console.log('aa AA', aa); 1022 sec.insertAdjacentHTML( 1023 'beforeEnd', 1024 '<div id="element-next-area-' + autoload_i + '" '+ 1025 'data-index="' + autoload_i + '" '+ 1026 'data-ident="' + aa.ident + '" '+ 1027 'data-list="' + aa.list + '" '+ 1028 'data-id="' + aa.id + '" '+ 1029 'class="element-next-area"><div class="element-next-temp' + 1030 ((this.autoloadPlaceholder.dataset.layout == 'center') ? ' element-next-temp-center' : '') + 1031 '"></div></div>' 1032 ); 1033 } 1034 let nodes = document.querySelectorAll('.article'); 1035 if (!nodes[0]) 1036 addCSSModule('module-article', '/_css/modules/article.css'); 1037 addCSSModule('module-articles-autoload', '/_css/modules/articles-autoload.css'); 1038 addCSSModule('module-art-authors', '/_css/modules/art-authors.css'); 1039 addCSSModule('module-sources', '/_css/modules/sources.css'); 1040 addCSSModule('module-layout-columns', '/_css/layout-columns.css'); 1041 this.autoloadPlaceholder.classList.add('shown'); 1042 }, 1043 getNextAutoloadArticle: function (list_ident) { 1044 let id = this.nextAutoloadID(list_ident), 1045 list = this.listIdents[list_ident], 1046 ident = list_ident; 1047 if (id == 0) 1048 { 1049 //console.log('aa0', id, list_ident , this.nextLists[list_ident]); 1050 if ((typeof this.nextLists[list_ident] == 'object') && (this.nextLists[list_ident].length > 0)) 1051 { 1052 for (let ni = 0; ni < this.nextLists[list_ident].length; ni++) 1053 { 1054 //console.log('aa 1 >'+ni, this.listIdents[this.nextLists[list_ident][ni]] ); 1055 id = this.nextAutoloadID(this.listIdents[this.nextLists[list_ident][ni]]); 1056 //console.log('aa 1 >'+ni, id, this.listIdents[this.nextLists[list_ident][ni]] ); 1057 if (id > 0) 1058 { 1059 list = this.listIdents[this.nextLists[list_ident][ni]]; 1060 ident = list_ident; 1061 break; 1062 } 1063 } 1064 } 1065 } 1066 return { 1067 'id': id, 1068 'list': list, 1069 'ident': ident 1070 }; 1071 }, 1072 nextAutoloadID: function (list_ident) { 1073 let lr = this.recommends[list_ident], 1074 id = 0; 1075 if (typeof lr == 'object') 1076 { 1077 for (var ai in lr) 1078 { 1079 let vp = this.visited.indexOf('' + lr[ai]), 1080 ap = this.aaUsed.indexOf('' + lr[ai]), 1081 up = -1; 1082 if (genesisPage.isMobile) 1083 up = this.used.indexOf('' + lr[ai]); 1084 if ((vp < 0) && (up < 0) && (ap < 0)) 1085 { 1086 id = lr[ai]; 1087 this.used.push('' + id); 1088 this.aaUsed.push('' + id); 1089 break; 1090 } 1091 } 1092 } 1093 return id; 1094 }, 1095 getAutoloadData: function(index, id) { 1096 const currArea = this.autoloadPlaceholder.querySelector('#element-next-area-' + index); 1097 id = '' + parseInt(id); 1098 if (currArea) 1099 { 1100 let obj = this, 1101 static_url = '/_f/static_texts/' + this.www_schema + '/' + id.substr(-4) + '/' + id + '.next?dt=' + obj.now.substr(0, 18) + '0', 1102 next_static_url = '/' + id + '/load.next?txt=1&dt=' + obj.now.substr(0, 18) + '0'; 1103 currArea.classList.add('assigned'); 1104 try 1105 { 1106 fetch(static_url, { 1107 cache: 'no-cache', 1108 }) 1109 .then(res => res.json()) 1110 .then(res => { 1111 obj.renderAutoloadItem(index, id, res); 1112 }) 1113 .catch(error => { 1114 let static_url = 1115 fetch(next_static_url, { 1116 cache: 'no-cache', 1117 }) 1118 .then(res => res.json()) 1119 .then(res => { 1120 obj.renderAutoloadItem(index, id, res); 1121 }) 1122 .catch(error => { 1123 console.error('genesisRecommends #2', error); 1124 }); 1125 }); 1126 } 1127 catch(e) 1128 { 1129 console.error('genesisRecommends #1', error); 1130 } 1131 } 1132 }, 1133 autoloadClick: function(sender, elementType) { 1134 const currArea = this.autoloadPlaceholder.querySelector('#element-next-area-' + sender.dataset.index); 1135 if (currArea) 1136 { 1137 const url = sender.href.trim(); 1138 if ((typeof deep_customer == 'object') && (typeof checkDeep == 'function') && checkDeep()) 1139 { 1140 let p = { 1141 'event.type': 'recommendations-autoload-clicked', 1142 recommendation: { 1143 placement: 'articles-autoload', 1144 element: elementType.replace(' (', '-').replace(')', '').toLowerCase().trim(), 1145 box: parseInt(sender.dataset.index) + 1, 1146 from: currArea.dataset.list || '', 1147 list: currArea.dataset.list || '' 1148 }, 1149 source: deep_init_content 1150 }; 1151 callDeepEvent(p); 1152 console.log('callDeepEvent', p, url, sender.hostname); 1153 } 1154 if (typeof gtag == 'function') 1155 { 1156 gtag('event', 'Autoload', { 1157 action: 'Autoload Clicked', 1158 element: elementType, 1159 title: currArea.dataset.title, 1160 url: url, 1161 index: sender.dataset.index 1162 }); 1163 } 1164 if (location.hostname == sender.hostname) 1165 location = url; 1166 else 1167 window.open(url); 1168 } 1169 }, 1170 renderAutoloadItem: function(index, id, json) { 1171 //console.log('genesisRecommends renderAutoloadItem', index, id, json ); 1172 const currArea = this.autoloadPlaceholder.querySelector('#element-next-area-' + index); 1173 this.visitedUpdate(id); 1174 this.autoloadPlaceholder.dataset.inited = 1; 1175 if (currArea) 1176 { 1177 var obj = this; 1178 currArea.dataset.title = json.title; 1179 currArea.dataset.title_seo = json.title_seo; 1180 currArea.dataset.url = json.url_canonical; 1181 currArea.innerHTML = json.html.next; 1182 1183 const element = currArea.querySelector('.element-article'), 1184 columns = currArea.querySelector('.element-article .columns'), 1185 header = currArea.querySelector('.element-next-header'), 1186 button = currArea.querySelector('.art-next-text-button .button'), 1187 buttonGallery = currArea.querySelector('.art-next-gallery-button .button'), 1188 leftColumn = currArea.querySelector('.element-article .left-column'), 1189 rightColumn = currArea.querySelector('.element-article .right-column'), 1190 centerColumn = currArea.querySelector('.element-article .center-column'), 1191 article = currArea.querySelector('.element-article .article'), 1192 artHeader = currArea.querySelector('.element-article .article header'), 1193 artTitle = currArea.querySelector('.element-article .article .art-title'), 1194 artTitleA = currArea.querySelector('.element-article .article .art-title a'), 1195 artTitle2hh = currArea.querySelector('.element-article .article .art-title.art-title-2hh'), 1196 artAuthors = currArea.querySelector('.element-article .article .art-authors'), 1197 artImage = currArea.querySelector('.element-article .article .art-image'), 1198 artImageA = currArea.querySelector('.element-article .article .art-image a'), 1199 artCommercial = currArea.querySelector('.element-article .article .art-commercial'), 1200 adBillboard = currArea.querySelector('.page-billboard-element-next'), 1201 adRectangle = currArea.querySelector('.page-rectangle-element-next'), 1202 adBillboardSlot = currArea.querySelector('.page-billboard-element-next .slot'), 1203 adRectangleSlot = currArea.querySelector('.page-rectangle-element-next .slot'); 1204 1205 if (element) 1206 { 1207 if (genesisPage.isMobile) 1208 { 1209 if (rightColumn) 1210 rightColumn.remove(); 1211 } 1212 else 1213 { 1214 if (centerColumn) 1215 { 1216 if (columns) 1217 columns.className = ''; 1218 if (leftColumn) 1219 leftColumn.className = 'center-column'; 1220 if (rightColumn) 1221 rightColumn.remove(); 1222 if (header) 1223 header.classList.add('element-header-center'); 1224 } 1225 else 1226 if (rightColumn) 1227 { 1228 let pnt = 0; 1229 if (element && article && artHeader) 1230 { 1231 pnt = pnt + parseInt(getComputedStyle(article).paddingTop, 10); 1232 if (artTitle2hh) 1233 { 1234 const style = getComputedStyle(artTitle2hh); 1235 pnt = pnt + artTitle2hh.offsetHeight; 1236 pnt = pnt + parseInt(style.marginTop); 1237 pnt = pnt + parseInt(style.marginBottom); 1238 } 1239 else 1240 { 1241 if (artAuthors) 1242 { 1243 const style = getComputedStyle(artAuthors); 1244 pnt = pnt + artAuthors.offsetHeight; 1245 pnt = pnt + parseInt(style.marginTop); 1246 pnt = pnt + parseInt(style.paddingTop); 1247 pnt = pnt + parseInt(style.marginBottom); 1248 pnt = pnt + parseInt(style.paddingBottom); 1249 } 1250 if (artImage) 1251 { 1252 const style = getComputedStyle(artImage); 1253 pnt = pnt + parseInt(style.marginTop); 1254 pnt = pnt + parseInt(style.paddingTop); 1255 } 1256 if (artCommercial) 1257 { 1258 const style = getComputedStyle(artCommercial); 1259 pnt = pnt + artCommercial.offsetHeight; 1260 pnt = pnt + parseInt(style.marginTop); 1261 pnt = pnt + parseInt(style.paddingTop); 1262 pnt = pnt + parseInt(style.marginBottom); 1263 pnt = pnt + parseInt(style.paddingBottom); 1264 } 1265 pnt = pnt + parseInt(artHeader.offsetHeight); 1266 } 1267 rightColumn.style.marginTop = pnt + 'px'; 1268 } 1269 } 1270 } 1271 if (!artImage) 1272 element.classList.add('element-article-no-image'); 1273 if (header) 1274 { 1275 const wrapper = header.querySelector('.wrapper'); 1276 if (wrapper) 1277 wrapper.insertAdjacentHTML('beforeEnd', '<span class="progress"></span>'); 1278 header.dataset.index = index; 1279 header.classList.add('element-next-header-' + index); 1280 if (genesisPage.elements && genesisPage.elements.elementHeader) 1281 genesisPage.elements.elementHeader.appendChild(header.cloneNode(true)); 1282 header.remove(); 1283 } 1284 if (button) 1285 button.dataset.index = index; 1286 1287 if (index == 0) 1288 this.initColumnAds(); 1289 1290 // Events ////////////////////////////////////////////////// 1291 1292 if (artTitleA) 1293 { 1294 if (typeof gtag == 'function') 1295 { 1296 gtag('event', 'Autoload', { 1297 action: 'Create', 1298 title: artTitleA.innerText.trim(), 1299 url: artTitleA.href.trim(), 1300 index: index 1301 }); 1302 } 1303 artTitleA.dataset.index = index; 1304 artTitleA.addEventListener('click', function (event) { 1305 obj.autoloadClick(this, 'Title'); 1306 event.preventDefault(); 1307 event.stopPropagation(); 1308 return false; 1309 }); 1310 } 1311 if (artImageA) 1312 { 1313 artImageA.dataset.index = index; 1314 artImageA.addEventListen
1314er('click', function (event) { 1315 obj.autoloadClick(this, 'Image'); 1316 event.preventDefault(); 1317 event.stopPropagation(); 1318 return false; 1319 }); 1320 } 1321 if (button) 1322 { 1323 button.dataset.index = index; 1324 button.addEventListener('click', function (event) { 1325 obj.autoloadClick(this, 'Button'); 1326 event.preventDefault(); 1327 event.stopPropagation(); 1328 return false; 1329 }); 1330 } 1331 if (buttonGallery) 1332 { 1333 buttonGallery.dataset.index = index; 1334 buttonGallery.addEventListener('click', function (event) { 1335 obj.autoloadClick(this, 'Button (Gallery)'); 1336 event.preventDefault(); 1337 event.stopPropagation(); 1338 return false; 1339 }); 1340 } 1341 1342 // Ads ///////////////////////////////////////////////////// 1343 1344 if (typeof googletag == 'object' && (typeof genesisAds == 'object') && (typeof genesisAdsUnits == 'object') && (typeof genesisAdsUnits.autoload == 'object') && (typeof genesisAdsUnits.autoload[obj.slots.index] == 'object')) 1345 { 1346 currArea.dataset.slotRefresh = 0; 1347 if (adBillboard && adBillboardSlot) 1348 { 1349 adBillboardSlot.id = 'element-next-billboard-' + index; 1350 setTimeout(function() { 1351 googletag.cmd.push(function() { 1352 genesisAds.createDynamicSloByIndex('autoload', index, 'billboard', adBillboardSlot.id, false, 'load'); 1353 }); 1354 }, 10); 1355 } 1356 if (!genesisPage.isMobile && adRectangle && adRectangleSlot) 1357 { 1358 adRectangleSlot.id = 'element-next-rectangle-' + index; 1359 setTimeout(function() { 1360 googletag.cmd.push(function() { 1361 genesisAds.createDynamicSloByIndex('autoload', index, 'rectangle', adRectangleSlot.id, false, 'load'); 1362 }); 1363 }, 20); 1364 } 1365 } 1366 else 1367 { 1368 if (adBillboard) 1369 adBillboard.remove(); 1370 if (adRectangle) 1371 adRectangle.remove(); 1372 } 1373 1374 // deepTracker 1375 1376 if ((typeof json.deep_bi_data == 'object') && (typeof checkDeep == 'function') && checkDeep()) 1377 this.autoloadDeepData = json.deep_bi_data; 1378 else 1379 this.autoloadDeepData = false; 1380 1381 this.markBreakingNews(); 1382 } 1383 } 1384 }, 1385 propagateAutoloadArticle: function (index) { 1386 const currArea = this.autoloadPlaceholder.querySelector('#element-next-area-' + index); 1387 let _title, 1388 _id, 1389 _url, 1390 _search; 1391 if (index != this.autoloadDisplayIndex) 1392 { 1393 this.autoloadDisplayIndex = index; 1394 if (index < 0) 1395 { 1396 if (genesisPage.elements && genesisPage.elements.elementHeader) 1397 { 1398 genesisPage.elements.elementHeader.querySelectorAll('.element-next-header').forEach(function (nextHeader) { 1399 nextHeader.classList.remove('visible'); 1400 }); 1401 } 1402 _url = genesisPage.url; 1403 _title = genesisPage.title; 1404 } 1405 else 1406 if (currArea) 1407 { 1408 if (genesisPage.elements && genesisPage.elements.elementHeader) 1409 { 1410 genesisPage.elements.elementHeader.querySelectorAll('.element-next-header').forEach(function (nextHeader) { 1411 if (nextHeader.classList.contains('element-next-header-' + index)) 1412 nextHeader.classList.add('visible'); 1413 else 1414 nextHeader.classList.remove('visible'); 1415 }); 1416 } 1417 _id = currArea.dataset.id; 1418 _url = currArea.dataset.url; 1419 _title = currArea.dataset.title_seo; 1420 if ((!currArea.dataset.scrollTop) || (genesisScroll.direction == 'down')) 1421 currArea.dataset.scrollTop = genesisScroll.top; 1422 } 1423 1424 document.title = _title; 1425 1426 if (_url.indexOf('?') > 0) 1427 _url = _url.substr(0, _url.indexOf('?')); 1428 if (_url.substr(0, 4) == 'http') 1429 { 1430 if (typeof window.history.pushState === 'function') 1431 { 1432 const url_parser = document.createElement('a'); 1433 url_parser.href = _url; 1434 if (location.hostname != url_parser.hostname) 1435 { 1436 _url = location.protocol + '//' + location.hostname + '/' + _id + url_parser.search; 1437 } 1438 1439 const stateObj = { 1440 url: _url, 1441 title: _title, 1442 index: index 1443 }; 1444 window.history.pushState(stateObj, _title, _url); 1445 1446 if (currArea && index >= 0) 1447 { 1448 // GA 1449 1450 if (typeof gtag == 'function') 1451 { 1452 if (index >= 0) 1453 { 1454 gtag('event', 'Autoload Displayed', { 1455 category: 'Autoload', 1456 title: currArea.dataset.title_seo, 1457 url: currArea.dataset.url, 1458 index: index 1459 }); 1460 } 1461 } 1462 1463 // deepTracker 1464 1465 if ((typeof this.autoloadDeepData == 'object') && (typeof checkDeep == 'function') && checkDeep()) 1466 { 1467 callNewPageDeep(this.autoloadDeepData); 1468 let p = { 1469 'event.type': 'autoload-pageview', 1470 'recommendation': {}, 1471 'source': deep_init_content, 1472 'dest': this.autoloadDeepData 1473 }; 1474 p.recommendation.placement = 'articles-autoload'; 1475 p.recommendation.box = parseInt(currArea.dataset.index) + 1; 1476 p.recommendation.from = currArea.dataset.ident; 1477 callDeepEvent(p); 1478 } 1479 1480 // hitsEvents ////////////////////////////////////////////// 1481 1482 genesisHits.sendAndRefresh({ 1483 hits_events: { 1484 director: location.href, 1485 display_set: { 1486 'id': _id, 1487 'type': 1, 1488 'event': 'display', 1489 'action': 'set', 1490 'director': location.href, 1491 'referer': (genesisPage.referrer ? atob(genesisPage.referrer) : document.referer), 1492 'referrer': (genesisPage.referrer ? atob(genesisPage.referrer) : document.referrer) 1493 } 1494 } 1495 }); 1496 1497 // Gemius 1498 1499 if (typeof pp_gemius_identifier == 'string') 1500 { 1501 if (typeof gemius_pending == 'function') 1502 { 1503 gemius_pending('gemius_hit'); 1504 gemius_pending('gemius_event'); 1505 gemius_pending('pp_gemius_hit'); 1506 gemius_pending('pp_gemius_event'); 1507 } 1508 if (typeof gemius_hit == 'function') 1509 { 1510 if (pp_gemius_identifier.toLowerCase().substr(0, 5) == 'used_') 1511 gemius_hit(pp_gemius_identifier.substr(5)); 1512 else 1513 gemius_hit(pp_gemius_identifier); 1514 } 1515 } 1516 } 1517 else 1518 { 1519 // deepTracker 1520 if ((typeof deep_init_content == 'object') && (typeof checkDeep == 'function') && checkDeep()) 1521 { 1522 callNewPageDeep(deep_init_content); 1523 } 1524 } 1525 } 1526 } 1527 } 1528 1529 if (currArea) 1530 { 1531 let aaT = currArea.dataset.scrollTop, 1532 aaH = currArea.offsetHeight; 1533 1534 if ((genesisScroll.top >= aaT) && (genesisScroll.top < (aaT + aaH))) 1535 { 1536 var aaPR = parseFloat(((genesisScroll.top - aaT) * 100) / aaH); 1537 if (aaPR > 100) 1538 aaPR = 100; 1539 1540 if (genesisPage.elements && genesisPage.elements.elementHeader) 1541 { 1542 genesisPage.elements.elementHeader.querySelectorAll('.progress').forEach(function (progress) { 1543 const header = progress.closest('.element-next-header'); 1544 if (header) 1545 { 1546 //console.log('progress', index, aaT, aaH, aaPR + '%', header, header.classList.contains('element-next-header-' + index)); 1547 if (header.classList.contains('element-next-header-' + index)) 1548 { 1549 progress.style.opacity = 1; 1550 progress.style.width = aaPR + '%'; 1551 } 1552 else 1553 progress.style.opacity = 0; 1554 } 1555 else 1556 progress.style.opacity = 0; 1557 }); 1558 genesisPage.elements.elementHeader.querySelectorAll('.right-column').forEach(function (rightColumn) { 1559 rightColumn.style.opacity = 0; 1560 }); 1561 } 1562 } 1563 } 1564 else 1565 { 1566 if (genesisPage.elements && genesisPage.elements.elementHeader) 1567 { 1568 genesisPage.elements.elementHeader.querySelectorAll('.progress').forEach(function (progress) { 1569 progress.style.opacity = 1; 1570 }); 1571 genesisPage.elements.elementHeader.querySelectorAll('.right-column').forEach(function (rightColumn) { 1572 rightColumn.style.opacity = 1; 1573 }); 1574 } 1575 } 1576 }, 1577 getAutoloadHomePage: function () { 1578 return false; 1579 try 1580 { 1581 /* 1582 var obj = this; 1583 if ($('#homepage-autoload').length != 1) 1584 $.ajax({ 1585 type: 'GET', 1586 url: 'https://www.wprost.pl/?autoload=1&dt=' + obj.now.substr(0, 16) + '00', 1587 success: function(home_html) { 1588 $('#homepage-autoload').html(home_html); 1589 }, 1590 error: function() { 1591 console.log('home html error'); 1592 } 1593 }); 1594 */ 1595 } 1596 catch(e) 1597 { 1598 } 1599 }, 1600
1601 initColumnAds: function () { 1602 const contentWidth = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--content-width')), 1603 section1 = this.autoloadPlaceholder.querySelector('#articles-autoload-section-1'), 1604 section2 = this.autoloadPlaceholder.querySelector('#articles-autoload-section-2'); 1605 if ((genesisPage.getWidth() - contentWidth > 340) && (typeof googletag == 'object') && (typeof genesisAds == 'object') && (typeof genesisAdsUnits == 'object') && (typeof genesisAdsUnits.autoload == 'object') && genesisAdsUnits.autoload !== null) 1606 { 1607 let indexAd = false, 1608 leftAd = false, 1609 rightAd = false, 1610 leftAd2 = false, 1611 rightAd2 = false; 1612 callDeepEvent({ 1613 'event.type': 'autoload-ads' 1614 }); 1615 genesisAdsUnits.autoload.forEach((adSet, i) => { 1616 if (typeof adSet == 'object' && adSet !== null) 1617 { 1618 for (let adKey in adSet) 1619 { 1620 if (adKey == 'left' && !leftAd) 1621 { 1622 leftAd = adSet[adKey]; 1623 if (indexAd === false) 1624 indexAd = i; 1625 } 1626 if (adKey == 'right' && !rightAd) 1627 { 1628 rightAd = adSet[adKey]; 1629 if (indexAd === false) 1630 indexAd = i; 1631 } 1632 if (adKey == 'left2' && !leftAd2) 1633 { 1634 leftAd2 = adSet[adKey]; 1635 if (indexAd === false) 1636 indexAd = i; 1637 } 1638 if (adKey == 'right2' && !rightAd2) 1639 { 1640 rightAd2 = adSet[adKey]; 1641 if (indexAd === false) 1642 indexAd = i; 1643 } 1644 } 1645 } 1646 }); 1647 if (indexAd) 1648 { 1649 if (section1) 1650 { 1651 section1.insertAdjacentHTML( 1652 'afterBegin', 1653 '<div class="articles-autoload-column articles-autoload-column-left">' + 1654 '<div class="i"><div id="autoload-ad-left"></div></div>' + 1655 '</div>' + 1656 '<div class="articles-autoload-column articles-autoload-column-right">' + 1657 '<div class="i"><div id="autoload-ad-right"></div></div>' + 1658 '</div>' 1659 ); 1660 } 1661 if (section2) 1662 { 1663 section2.insertAdjacentHTML( 1664 'afterBegin', 1665 '<div class="articles-autoload-column articles-autoload-column-left">' + 1666 '<div class="i"><div id="autoload-ad-left-2"></div></div>' + 1667 '</div>' + 1668 '<div class="articles-autoload-column articles-autoload-column-right">' + 1669 '<div class="i"><div id="autoload-ad-right-2"></div></div>' + 1670 '</div>' 1671 ); 1672 } 1673 if (leftAd && rightAd && section1) 1674 { 1675 setTimeout(function() { 1676 genesisAds.createDynamicSloByIndex('autoload', indexAd, 'left', 'autoload-ad-left', false, 'load'); 1677 genesisAds.createDynamicSloByIndex('autoload', indexAd, 'right', 'autoload-ad-right', false, 'load'); 1678 }, 120); 1679 } 1680 if (leftAd2 && rightAd2 && section2) 1681 { 1682 setTimeout(function() { 1683 genesisAds.createDynamicSloByIndex('autoload', indexAd, 'left2', 'autoload-ad-left-2', false, 'viewport'); 1684 genesisAds.createDynamicSloByIndex('autoload', indexAd, 'right2', 'autoload-ad-right-2', false, 'viewport'); 1685 }, 320); 1686 } 1687 } 1688 } 1689 }, 1690 1691 // breaking news 1692 1693 markBreakingNews: function () { 1694 if (typeof this.breaking == 'object') 1695 { 1696 for (let id in this.breaking) 1697 { 1698 const label = '<b class="bnl bnl-' + this.breaking[id].type + '">' + this.breaking[id].name + '</b> '; 1699 this.breaking[id].count = 0; 1700 document.querySelectorAll('.bl li a[data-id="' + id + '"]:not([data-breaking-news="true"])').forEach((breakingItem) => { 1701 if (breakingItem && (breakingItem.dataset.breakingNews != 'true')) 1702 { 1703 const title = breakingItem.querySelector('strong.t span'); 1704 if (title) 1705 title.insertAdjacentHTML('afterBegin', label); 1706 breakingItem.dataset.breakingNews = true;
1707 breakingItem.dataset.from = 'recommends'; 1708 this.breaking[id].assigned = true; 1709 this.breaking[id].count++; 1710 } 1711 }); 1712 } 1713 return this.breaking; 1714 } 1715 else 1716 return false; 1717 }, 1718 1719 // visited 1720 1721 visitedLoad: function() { 1722 this.visited = localStorage.getItem('articles'); 1723 if (document.querySelector('div[data-rm="genesis"][data-visited="cookie"]')) 1724 { 1725 this.visitedSource = 'cookie'; 1726 this.visited = winReadCookie('readed'); 1727 } 1728 if (!this.visited) 1729 this.visited = []; 1730 else 1731 this.visited = arrayExplode(':', '' + this.visited); 1732 }, 1733 visitedSave: function() { 1734 if (this.visited.length > 120) 1735 this.visited.splice(120, this.visited.length-120); 1736 localStorage.setItem('articles', arrayImplode(':', this.visited)); 1737 winCreateCookie('readed', arrayImplode(':', this.visited), (30 * 10)); 1738 }, 1739 visitedUpdate: function(id) { 1740 id = parseInt(id); 1741 if (id > 0) 1742 { 1743 if (!this.visited) 1744 this.visited = ['' + id]; 1745 else 1746 { 1747 if (typeof this.visited == 'object') 1748 { 1749 let p = this.visited.indexOf('' + id); 1750 if (p >= 0) 1751 this.visited.splice(p, 1); 1752 this.visited.splice(0, 0, '' + id); 1753 } 1754 } 1755 this.visitedSave(); 1756 } 1757 }, 1758 1759 createID: function () { 1760 let d = new Date(), 1761 ts = d.getTime(); 1762 return 'gen-recommends-' + ts + '-' + Math.floor(Math.random() * 1000) + '-' + Math.floor(Math.random() * 1000); 1763 } 1764}; 1765(function(a){a.init();}(genesisRecommends));
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.