1var scrollSectionsToAddCount=3 2 3function populateTwitterEmbeds() { 4 5 6 7 document.querySelectorAll('div:not(#scroll-section-0) blockquote[class="twitter-tweet"]').forEach(function(item) { 8 9 const regex = /https:\/\/twitter.com\/[^\/]*\/status\/(\d+)/mi; 10 11 const match = item.outerHTML.match(regex); 12 13 // log.debug('twitter match'); 14 15 if (match!==null) { 16 log.debug(match[1]); 17 let id=match[1]; 18 19 20 let f = '<div class="twitter-tweet twitter-tweet-rendered" style="display: flex; max-width: 550px; width: 100%; margin-top: 10px; margin-bottom: 10px;"><iframe id="twitter-widget-0" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen="true" class="" title="X Post" src="https://platform.twitter.com/embed/Tweet.html?dnt=false&embedId=twitter-widget-0&features=eyJ0ZndfdGltZWxpbmVfbGlzdCI6eyJidWNrZXQiOltdLCJ2ZXJzaW9uIjpudWxsfSwidGZ3X2ZvbGxvd2VyX2NvdW50X3N1bnNldCI6eyJidWNrZXQiOnRydWUsInZlcnNpb24iOm51bGx9LCJ0ZndfdHdlZXRfZWRpdF9iYWNrZW5kIjp7ImJ1Y2tldCI6Im9uIiwidmVyc2lvbiI6bnVsbH0sInRmd19yZWZzcmNfc2Vzc2lvbiI6eyJidWNrZXQiOiJvbiIsInZlcnNpb24iOm51bGx9LCJ0ZndfZm9zbnJfc29mdF9pbnRlcnZlbnRpb25zX2VuYWJsZWQiOnsiYnVja2V0Ijoib24iLCJ2ZXJzaW9uIjpudWxsfSwidGZ3X21peGVkX21lZGlhXzE1ODk3Ijp7ImJ1Y2tldCI6InRyZWF0bWVudCIsInZlcnNpb24iOm51bGx9LCJ0ZndfZXhwZXJpbWVudHNfY29va2llX2V4cGlyYXRpb24iOnsiYnVja2V0IjoxMjA5NjAwLCJ2ZXJzaW9uIjpudWxsfSwidGZ3X3Nob3dfYmlyZHdhdGNoX3Bpdm90c19lbmFibGVkIjp7ImJ1Y2tldCI6Im9uIiwidmVyc2lvbiI6bnVsbH0sInRmd19kdXBsaWNhdGVfc2NyaWJlc190b19zZXR0aW5ncyI6eyJidWNrZXQiOiJvbiIsInZlcnNpb24iOm51bGx9LCJ0ZndfdXNlX3Byb2ZpbGVfaW1hZ2Vfc2hhcGVfZW5hYmxlZCI6eyJidWNrZXQiOiJvbiIsInZlcnNpb24iOm51bGx9LCJ0ZndfdmlkZW9faGxzX2R5bmFtaWNfbWFuaWZlc3RzXzE1MDgyIjp7ImJ1Y2tldCI6InRydWVfYml0cmF0ZSIsInZlcnNpb24iOm51bGx9LCJ0ZndfbGVnYWN5X3RpbWVsaW5lX3N1bnNldCI6eyJidWNrZXQiOnRydWUsInZlcnNpb24iOm51bGx9LCJ0ZndfdHdlZXRfZWRpdF9mcm9udGVuZCI6eyJidWNrZXQiOiJvbiIsInZlcnNpb24iOm51bGx9fQ%3D%3D&frame=false&hideCard=false&hideThread=false&id=' + id + '&lang=en&origin=https%3A%2F%2Fwww.jezebel.com%2Fhilary-duffs-husband-has-entered-the-ashley-tisdale-toxic-mom-group-chat&sessionId=4649a6df74887613c845b43c8c53618983bccc72&siteScreenName=jezebel&theme=light&widgetsVersion=2615f7e52b7e0%3A1702314776716&width=550px" style="position: static; visibility: visible; width: 550px; height: 830px; display: block; flex-grow: 1;" data-tweet-id="' + id + '"></iframe></div>'; 21 22 item.outerHTML = f; 23 } 24 }); 25 26 27 28} 29 30function populateBlueskyEmbeds() { 31 32 33 let EMBED_URL = 'https://embed.bsky.app'; 34 35 window.addEventListener('message', function (event) { 36 if (event.origin !== EMBED_URL) { 37 return; 38 } 39 40 var id = event.data.id; 41 if (!id) { 42 return; 43 } 44 var embed = document.querySelector("[data-bluesky-id=\"".concat(id, "\"]")); 45 if (!embed) { 46 return; 47 } 48 49 var height = event.data.height; 50 if (height) { 51 embed.style.height = "".concat(height, "px"); 52 // log.debug('adjust bluesky height'); 53 } 54}); 55 56 document.querySelectorAll('blockquote[class="bluesky-embed"]').forEach(function(item) { 57 58 const regex = /data-bluesky-uri="(.*?")/mi; 59 60 const match = item.outerHTML.match(regex); 61 if (match!==null) { 62 63 64 65 66 let u = match[1].replace('at://','').replace('"',''); 67 68 let fid=Math.floor(Math.random() * (99999999999 - 100000 + 1)) + 100000 69 let f = '<div class="bluesky-embed" style="max-width: 600px; width: 100%; margin-top: 10px; margin-bottom: 10px; display: flex;"><iframe data-bluesky-id="' + fid + '" src="https://embed.bsky.app/embed/' + u +'?id=' + fid + '&ref_url=&colorMode=system" width="100%" frameborder="0" scrolling="no" style="border: none; display: block; flex-grow: 1;"></iframe></div>'; 70 71 item.outerHTML = f; 72 } 73 }); 74 75 76 77 78} 79 80 81 82 83 84let scrollTracker = {lastAdRefresh: new Date(), 85 lastPageViewRecorded: new Date(), 86 isOkToRefreshAd() { 87 // let date = new Date(); 88 // let fakeDate = new Date(); 89 // fakeDate.setMinutes(date.getSeconds() - 30); 90 //lastAdRefresh=fakeDate; 91 92 //let td = (date - lastAdRefresh) / (1000 * 60); 93 94 95 // log.info(td); 96 if (this.lastAdRefresh===null) { 97 log.info('lastAdRefresh: true'); 98 return true; 99 100 } else if ( this.getElapsedSeconds(this.lastAdRefresh) >10) { 101 log.info('lastAdRefresh: true'); 102 return true; 103 104 } else { 105 log.info('lastAdRefresh: false'); 106 return false 107 } 108 }, 109 isOkToSendPageView() {let date = new Date(); 110 111 112 // log.info(td); 113 if (this.lastPageViewRecorded===null) { 114 log.info('lastPageViewRecorded: true'); 115 return true; 116 117 } else if ( this.getElapsedSeconds(this.lastPageViewRecorded) >10) { 118 log.info('lastPageViewRecorded: true'); 119 return true; 120 121 } else {
122 log.info('lastPageViewRecorded: false'); 123 return false 124 } 125 126 }, 127 refreshAds() { 128 //this.lastAdRefresh=new Date(); 129 if (this.isOkToRefreshAd()) { 130 this.forceRefreshAds(); 131 return true; 132 } else { 133 return false; 134 } 135 }, 136 recordPageView(scrollElement) { 137 // this.lastPageViewRecorded=new Date(); 138 if (this.lastPageViewRecorded()) { 139 this.forceRecordPageView(); 140 return true; 141 } else { 142 return false; 143 } 144 }, 145 getElapsedSeconds(oldDate) { 146 let date = new Date(); 147 let et = (date - oldDate) / (10 * 60) 148 log.info(et); 149 return et; 150 }, 151 forceRecordPageView(scrollElement) { 152 153 154 155 let thisUrl = scrollElement.getAttribute('url') 156 157 158 159 let title = scrollElement.getAttribute("seo_title"); 160 161 thisUrl=AddTrailingSlash(thisUrl); 162 const url = new URL(thisUrl); 163 log.debug(title); 164 log.debug(thisUrl); 165 log.debug(url.pathname); 166 gtag('event', 'page_view', { 167 page_title: title, 168 page_location: thisUrl, 169 page_path: url.pathname 170 }); 171 this.lastPageViewRecorded=new Date(); 172 log.info('page_view recorded'); 173 }, 174 forceRefreshAds() { 175 if ( typeof htlbid !== 'undefined' && htlbid !== null ) { 176 if (document.querySelector("#bottom_leaderboard")!==null) { 177 htlbid.reloadSlot('bottom_leaderboard'); 178 } 179 if ((document.querySelector("#above_logo")!==null) && document.querySelector("#above_logo").checkVisibility()) { 180 htlbid.reloadSlot('above_logo'); 181 } else { 182 if (document.querySelector("#top_leaderboard")!==null) { 183 htlbid.reloadSlot('top_leaderboard'); 184 } 185 } 186 this.lastAdRefresh= new Date(); 187 } 188 } 189}; 190 191 192 193document.addEventListener("DOMContentLoaded", () => { 194 195 log.setDefaultLevel(log.levels.TRACE, true); 196 197 log.setLevel('silent', true); 198 199 showEmailPopup(); 200 201 202}); 203 204 var origUrl = null; 205var bottomOfPreviousSection=0; 206var isInitialpositionRightRailAds=true; 207//var resizeObserver; 208let prevEntry=null; 209var lastIntersection=null; 210var lastIntersectionScrollY=0; 211var currentIntersectionEntry=null; 212var lastObserverTriggered=null; 213 214/*resizeObserver = new ResizeObserver(entries => { 215 for (let entry of entries) { 216 log.debug('Div size changed:', entry.contentRect.width, entry.contentRect.height); 217 positionRightRailAds(30); 218 } 219 }); */ 220 221 222var observer; 223 224var doScroll=true; 225//if (true || window.location.href=='https://www.jezebel.com/jim-caviezel') { 226 // doScroll = true; 227//} 228// if (getUrlParam('s')=='scroll') { 229 230// doScroll = true; 231// } 232//log.debug('let us do it: ' + doScroll); 233 234 235 236 237 238function scrollToAudioPlayer($clickedEl) { 239 event.preventDefault(); 240 log.debug($clickedEl); 241 let post_id=$clickedEl.getAttribute("post_id"); 242 log.debug(post_id); 243 244 // log.debug('scrollToAudioPlayer'); 245 // $clickedEl=jQuery($clickedEl); 246 // log.debug($clickedEl); 247 // $at = $clickedEl.attr("href"); 248 let at="#audio-title[post_id='" + post_id + "']"; 249 // let at="#audio-title-" + post_id ; 250 // log.debug($at); 251 // log.debug(jQuery($at).offset().top); 252 log.debug(at); 253 jQuery('html, body').animate({ 254 scrollTop: jQuery(at).offset().top - 200 255 },0); 256 document.querySelector("#tts-player[post_id='" + post_id + "']").play(); 257 return false; 258} 259function getUrlParam(name) { 260 let r = ''; 261 const queryString = window.location.search;
262 const urlParams = new URLSearchParams(queryString); 263 264 if (queryString !== "") { 265 r = urlParams.get(name); 266 } 267 268 return r; 269} 270function getCommentCount(obj,url,postId) { 271 // var u = new URL(window.location); 272 // u.hash = ''; 273 // u.search = ''; 274 // log.debug(url); 275 //log.debug(obj.id); 276 277 // type: 'get',url: 'https://disqus.com/api/3.0/threads/details.json?api_key=rI9PSTKxFdaoFerkDzYfy3OlzHelmyvBy4PDZaCKGl9K2alhBFqDigdnVcqpxMYx&callback=foo&forum=paste-magazine&thread=link:' + loc , 278 url = url.replace('?s=scroll',''); 279 280 /* jQuery.ajax({ 281 type: 'get',url: 'https://disqus.com/api/3.0/threads/details.json?api_key=mZyGvuGCJddMuwBLSBOrVIYboExFoMNur40ypGj1ZCMFOSKsXDbi17RhenUYeBDV&callback=foo&forum=jezebel-1&thread=link:' + loc , 282 */ 283 jQuery.ajax({ 284 type: 'get',url: 'https://disqus.com/api/3.0/threads/details.json?api_key=mZyGvuGCJddMuwBLSBOrVIYboExFoMNur40ypGj1ZCMFOSKsXDbi17RhenUYeBDV&callback=foo&forum=jezebel-1&thread=link:' + encodeURIComponent(url), 285 success: function (data) { 286 287 let r = data.match(/\"posts\":(\d+)/); 288 //log.debug('getCommentCount'); 289 // log.debug('count: ' + r[1]); 290 // log.debug(url); 291 292 let x = document.getElementById( 'comment-count-' + postId); 293 294 if (x!==null) { 295 x.innerText=r[1]; // + 'x'; 296 297 298 } 299 x = obj.querySelector('#show-comment-block'); 300 301 if (x!==null) { 302 if (r[1] === '0' || r[1] === '' ) { 303 x.innerText=('Start the discussion...'); 304 } else if (r[1] == '1' ) { 305 x.innerText=('Continue the discussion...'); 306 } else { 307 x.innerText=('Show all ' + r[1] + ' comments...'); 308 } 309 } 310 311 312 }, 313 error: function (request, status, error) { 314 console.error(error); 315 } 316 317}); 318 319 320} 321function showCommentsTopArticle(obj,postId) { 322
323 let commentParent=obj.parentNode.parentNode; 324 325 let hideMe = commentParent.querySelector('#disqus-comment-count-wrapper') 326 327 hideMe.classList.add("hide"); 328 let showMe = commentParent.querySelector('#disqus_thread'); 329 showMe.classList.remove("hide"); 330} 331function parent (element, n = 1, matchId='') { 332 let r = false; 333 let {parentNode} = element; 334 for (let i = 1; parentNode && i < n; i++) { 335 ({parentNode} = parentNode); 336 // log.debug ('parent'); 337 // log.debug (parentNode); 338 if (parentNode === null || parentNode.lenght===0) { 339 break; 340 } else if (parentNode.id==matchId) { 341 r=true; 342 break; 343 } 344 //log.debug('parent id: ' + parentNode.id); 345 // log.debug ('parent after'); 346 } 347 348 return r; 349} 350function showCommentsForScroll(obj,postId) { 351 log.debug('showCommentsForScroll let us do it: ' + doScroll); 352 if (doScroll) { 353 //log.debug('showCommentsForScroll'); 354 // log.debug(obj); 355 // log.debug(postId); 356 let isFirstComentBlock = parent(obj,10,'scroll-section-0'); 357 358 //scroll-section-0 359 if (false && isFirstComentBlock) { 360 showCommentsTopArticle(obj,postId); 361 } else { 362 363 //log.debug(obj); 364 let commentParent=obj.parentNode.parentNode; 365 // log.debug('commentParent'); 366 //log.debug(commentParent); 367 368 369 370 // 371 372 document.querySelectorAll('li[id^="block-"]').forEach(function(item) { 373 log.debug(item.id); 374 item.style.display='block'; 375 }); 376 377 document.querySelectorAll('#disqus-comment-count-wrapper').forEach(function(item) { 378 379 item.style.display='block'; 380 }); 381 let hideMe = commentParent.querySelector('#disqus-comment-count-wrapper') 382 383 hideMe.classList.add("hide"); 384 385 let btn = commentParent.querySelector('#show-comments-button') 386 let wrapper = commentParent.querySelector('#disqus-comment-count-wrapper') 387 //wp-block-comments hide 388 let block = commentParent.querySelector('#comments.wp-block-comments') 389 log.debug('remove hide'); 390 log.debug(block); 391 if (block) { 392 block.classList.remove("hide"); 393 } 394 395 396 let art = document.querySelector("article[post_id='" + postId + "']") 397 398 let url = document.querySelector("div[post_id='" + postId + "'].scroll-article-container").getAttribute("url") 399 let title = document.querySelector("div[post_id='" + postId + "'].scroll-article-container").querySelector("h1.title").innerText 400 401 let auri=getAbsolutePath(url).replace("/", ""); 402 403 loadDisqusComments(postId, postId + " " + auri , title,url); 404 405 406 /* 407 const timeoutId = setTimeout(() => { 408 positionRightRailAds(); 409 410 }, 5000); */ 411 } 412 } 413} 414 415const getAbsolutePath = (urlString) => { 416 try { 417 const url = new URL(urlString); 418 return url.pathname; 419 } catch (error) { 420 // Handle invalid URLs if necessary 421 console.error("Invalid URL:", error); 422 return null; 423 } 424}; 425 426function loadDisqusComments (postId,newIdentifier, newTitle, newUrl) { 427 // If DISQUS is not yet loaded, load the embed script first 428// log.debug('loadDisqusComments'); 429 // log.debug(newIdentifier); 430 // log.debug(newTitle); 431 // log.debug(newUrl); 432 newUrl = newUrl.replace('?s=scroll',''); 433 log.debug(newUrl); 434 document.querySelectorAll("div[id^='disqus_thread']").forEach(function(item) { 435 log.debug('empty disqus_thread div'); 436 item.innerHTML=''; 437 }); 438 let container_id = 'disqus_thread_'+postId; 439 window.disqus_container_id = container_id; 440 if (typeof DISQUS === 'undefined') { 441 window.disqus_shortname = 'avclub'; // Replace with your shortname 442 window.disqus_identifier = newIdentifier; 443 window.disqus_title = newTitle; 444 window.disqus_url = newUrl; 445 446 // Append the disqus_thread div if it doesn't exist 447 if (!document.getElementById('disqus_thread')) { 448 const disqusThreadDiv = document.createElement('div'); 449 disqusThreadDiv.id = container_id; //'disqus_thread_'+postId; 450 document.body.appendChild(disqusThreadDiv);
450 // Or append to a specific container 451 } 452 453 // Load the Disqus embed script 454 const script = document.createElement('script'); 455 script.type = 'text/javascript'; 456 script.src = `//${window.disqus_shortname}.disqus.com/embed.js`; 457 script.setAttribute('data-timestamp', +new Date()); 458 (document.head || document.body).appendChild(script); 459 } else { 460 // Disqus is already loaded, reset it for the new thread 461 DISQUS.reset({ 462 reload: true, 463 config: function() { 464 this.page.identifier = newIdentifier; 465 this.page.title = newTitle; 466 this.page.url = newUrl; 467 } 468 }); 469 } 470 471 // log.debug('unobserve', observer); 472 observer.disconnect(); 473 474 475 476 477 let newSections = document.querySelectorAll('div[id^="scroll-section-"]'); 478 479 480 481 newSections.forEach(section => { 482 483 484 observer.observe(section); 485 }); 486 487 488 489 490 //const timeoutId = setTimeout(() => { 491 // positionRightRailAds(26); 492 // 493 // }, 5000); 494 495} 496 497 498 499function setStickyAside() { 500 /* 501 const ismbr= isMemberOrEditor(); 502 console.log('setStickyAside()'); 503 504 //if (!ismbr){ 505 let elx = document.querySelector('.widget-container.widget_block'); 506 507 let isLandingPage = false; 508 if( document.querySelector('.landing-top') !== null){ 509 isLandingPage=true; 510 } 511 512 513 let isTall = window.innerHeight>1024; 514 515 elx.classList.add("fixed"); 516 517 if (isTall) { 518 elx.classList.add("tall"); 519 520 } 521 522 */ 523} 524 525 526 527 528window.onscroll = function() {scrollFunction()}; 529 530function scrollFunction() { 531 const ismbr= isMemberOrEditor(); 532 533 534 535 536 const el = document.getElementsByClassName("bottom-link-row"); 537 if( el !== null && el.length>0) { 538 // log.debug('add fixed listener'); 539 // document.addEventListener("DOMContentLoaded", () => { 540 const topLeader=document.getElementById('top_leaderboard'); 541 const aboveLogo=document.getElementById('above_logo') 542 543 544 if (topLeader === null) { 545 log.debug('top_leaderboard: null'); 546 } else { 547 log.debug('top_leaderboard: ' + topLeader.clientHeight); 548 } 549 550 551 if (aboveLogo === null) { 552 553 log.debug('above_logo: null'); 554 } else { 555 556 log.debug('above_logo: ' + aboveLogo.clientHeight); 557 } 558 let ss = ''; 559 560 if (window.innerWidth<480) { 561 ss = 'm'; 562 } else { 563 ss = 'd'; 564 } 565 566 log.debug('ss: ' + ss); 567 if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) { 568 el[0].classList.add('fixed'); 569 570 if(ismbr) { 571 el[0].classList.add('no-ads'); 572 // log.debug('ads hidden'); 573 } else if ( ss=='m' && (topLeader===null || topLeader.clientHeight===0) ) { 574 el[0].classList.add('no-ads'); 575 // log.debug('ads hidden'); 576 } else if ( ss=='d' && (aboveLogo===null || aboveLogo.clientHeight===0) ) { 577 el[0].classList.add('no-ads'); 578 // log.debug('ads hidden'); 579 } else { 580 // log.debug('ads not hidden'); 581 } 582 } else { 583 el[0].classList.remove('fixed'); 584 el[0].classList.remove('no-ads'); 585 } 586 // }); 587 } 588} 589 590 591 592 593 594 595/*jQuery(document).ready(function ($) { 596 log.debug('JQuery Ready.'); 597}); */ 598 599function getCookie(name) { 600 var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); 601 if (match) return match[2]; 602} 603 604 605// 606function getIsLoggedViaCookie() { 607 let name = 'wordpress_test_cookie'; 608 var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)')); 609 if (match) return match[2]; 610} 611 612 613function positionRightRailAds(additionalFudge=0){ 614 /* 615 log.debug('positionRightRailAds() ' + additionalFudge); 616 617 if (isInitialpositionRightRailAds) { 618 additionalFudge=0; 619 620 isInitialpositionRightRailAds=false; 621 } 622 if (document.getElementById('scroll-section-0').getBoundingClientRect().height<2000) { 623 document.getElementById('sidebar-recommended').style.display='none'; 624 } 625 for (let step = 1; step <= 7; step++) {
626 setAdPositionRightRail(step,-28 + additionalFudge) 627 } 628 */ 629} 630 631 632function setAdPositionRightRail(adNumber, fudge) { 633 let tp = document.querySelector('#top_rectangle_side_' + adNumber); 634 let mp = document.querySelector('#middle_rectangle_side_' + adNumber) 635 if (tp) { 636 let topParent = tp.parentElement; 637 let middleParent = mp.parentElement; 638 if (window.innerWidth>=640) { 639 640 let scrollSection = document.querySelector('#scroll-section-' + (adNumber)); 641 topParent.style.display = "block"; 642 topParent.style.position = "absolute"; 643 topParent.style.top = scrollSection.getBoundingClientRect().top + (window.scrollY + fudge ) +"px" ; 644 // log.debug('topParent: ' + topParent.style.top); 645 646 647 middleParent.style.display = "block"; 648 middleParent.style.position = "absolute"; 649 middleParent.style.top = scrollSection.getBoundingClientRect().top + ( window.scrollY + 650 + fudge) +"px" ; 650 log.debug('middleParent: ' + scrollSection.getBoundingClientRect().top); 651 } else { 652 653 if (topParent!==null) { 654 topParent.remove(); 655 } 656 if (middleParent!==null) { 657 middleParent.remove(); 658 } 659 } 660 } 661} 662 663function isLoggedInViaClass() { 664 665 666 667 668 isLoggedIn = document.body.classList.contains('logged-in'); 669 if (isLoggedIn) { 670 return true; 671 } else { 672 return false; 673 } 674 675 676} 677function getJMemberLevel() { 678 return getCookie('jmemberlevel') ; 679} 680 681function getIsAccessToRestrictedContentAllowed() { 682 let c = getCookie('jmemberlevel'); 683 684 return ( c == '2' || c == '3' ) ; 685} 686 687function getIsRestrictedContent() { 688 var el = document.getElementById('is-restricted-content') 689 if (el) { 690 if (el.value == '1' ) { 691 // log.debug('Content is restriced'); 692 return true; 693 } else { 694 // log.debug('Content is public'); 695 return false; 696 } 697 698 699 700 } 701 702 703} 704 705 706function getIsLoggedInMember() { 707 if (getCookie('jmemberlevel') && getIsLoggedViaCookie()) { 708 return true; 709 } else { 710 711 return false; 712 } 713 714} 715 716 717/* 718function initCommentSetupForCachedPage() { 719 log.debug('initCommentSetupForCachedPage'); 720 let pmb = document.querySelector('comments-login-request'); 721 //.wpd-login-to-comment 722 if (pmb) { 723 log.debug('initCommentSetupForCachedPage2'); 724 // log.debug( pmb.innerHTML); 725 // log.debug(pmb); 726 pmb.outerHTML = '<a href="/login" class="wpd-login-to-comment-link">' + pmb.outerHTML + '</a>'; 727 pmb.style.display = ""; 728 } 729 // 730 731 pmb = document.querySelector('.wpd-login > a'); 732 if (pmb) { 733 // log.debug('initCommentSetupForCachedPage3'); 734 // log.debug(pmb); 735 pmb.setAttribute('href', "/membership-account"); 736 } 737 738 pmb = document.querySelectorAll('.wpd-login > a'); 739 if (pmb) { 740 //log.debug('initCommentSetupForCachedPage4'); 741 // log.debug(pmb[1]); 742 if (pmb[1]) { 743 pmb[1].setAttribute('href', "/logout"); 744 } 745 } 746 // 747 pmb = document.querySelector('.wpd-load-more-submit-wrap > button.wpd-load-comments.wpd-prim-button'); 748 if (pmb) { 749 let ccnt = ''; 750 //log.debug('initCommentSetupForCachedPage5'); 751 //<div class="wpd-thread-info " data-comments-count="29"> 752 let pmc = document.querySelector('.wpd-thread-info'); 753 //log.debug('initCommentSetupForCachedPage5a'); 754 if (pmc) { 755 // log.debug('initCommentSetupForCachedPage5b'); 756 ccnt = pmc.getAttribute('data-comments-count'); 757 // log.debug('commnencnt: ' + ccnt) 758 } 759 // log.debug('initCommentSetupForCachedPage6'); 760 // log.debug(pmb); 761 if (ccnt!=='') { 762 pmb.innerHTML = pmb.innerHTML + '(' + ccnt +')'; 763 } 764 //pmb[1].setAttribute('href', "/logout"); 765 } 766 767} 768*/ 769function initMembershipSetup() { 770 //log.debug('initMembershipSetup'); 771 let loc =window.location.pathname ; 772 //log.debug( loc); 773 if ( loc.startsWith('/login') ) { 774 //log.debug('try pmpro_actions_nav'); 775 cnw = document.querySelector('.pmpro_actions_nav:not(.lost-password)'); 776 if (cnw) { 777 log.debug('in pmpro_actions_nav'); 778 cnw.style.display = "none"; 779 // log.debug(cnw); 780 } 781 782 } 783 if ( loc.startsWith('/membership-account/membership-confirmation') ) { 784 log.debug('LOOK FOR H2'); 785 cnw = document.querySelectorAll('.pmpro_confirmation_wrap > p')[2] 786 if (cnw) { 787 log.debug(cnw); 788 let d = document.createElement( 'p' ); 789 d.id = "username"; 790 791 d.innerHTML = 'Your default display name is your first and last name. You can change your display name at any time via <a href="/membership-account/your-profile">Edit Profile</a>.' ; 792 // log.debug(d); 793 // cnw.appendChild(d); 794 cnw.parentNode.insertBefore(d, cnw.nextSibling); 795 } 796 797 } 798 if ( loc.startsWith('/membership') ) { 799 // 800 801 let sa = document.querySelector('#shipping_address'); 802 if (sa) { 803 804 sa.setAttribute('placeholder','Name\nStreet\nCity State Zip'); 805 } 806 let sub = document.querySelector('#subscribe'); 807 if (sub) { 808 // log.debug('initMembershipSetup3'); 809 sub.checked = true; 810 811 } 812 813 //log.debug('initMembershipSetup2'); 814
815 const urlParams = new URLSearchParams(window.location.search); 816 const myParam = urlParams.get('level'); 817 let msg=''; 818 if (myParam=='2') { 819 msg = "Your subscription will be auto-renewed monthly. You may cancel at any time."; 820 821 } else if (myParam=='3') { 822 823 msg = "Your subscription will be auto-renewed annually. You may cancel at any time."; 824 } 825 826 let pmb = document.querySelector('#pmpro_message_bottom'); 827 if (pmb) { 828 // log.debug('initMembershipSetup3'); 829 pmb.innerHTML=msg; 830 pmb.style.display = ""; 831 } 832 833 834 let cnw = document.querySelector('.pmpro_checkout-field-username > label'); 835 if (cnw) { 836 //log.debug('pmpro_checkout-field-username'); 837 let d = document.createElement( 'span' ); 838 d.id = "display-name-warning"; 839 d.cssClass = "old-comment-warning"; 840 d.innerHTML = ' (displayed publicly with comments posted)' ; 841 cnw.appendChild(d); 842 843 } 844 845 // log.debug('pmpro_account-membership > h2'); 846 cnw = document.querySelector('#pmpro_account-membership > h2'); 847 if (cnw) { 848 //log.debug('pmpro_checkout-field-username'); 849 log.debug('IN pmpro_account-membership > h2'); 850 cnw.style.display = "none"; 851 } 852 853 854 // 855 // 856 cnw = document.querySelector('.pmpro_table th:nth-of-type(3)'); 857 if (cnw) { 858 859 //log.debug('IN .pmpro_table th:nth-of-type(3)'); 860 cnw.style.visibility="hidden"; 861 } 862 cnw = document.querySelector('.pmpro_table td:nth-of-type(3)'); 863 if (cnw) { 864 865 // log.debug('IN .pmpro_table td:nth-of-type(3)'); 866 cnw.style.visibility="hidden"; 867 } 868 cnw = document.querySelector('.pmpro_table td:nth-of-type(2)'); 869 if (cnw) { 870 871 // log.debug('IN .pmpro_table td:nth-of-type(2)'); 872 // log.debug( cnw.innerHTML) 873 let tmp = cnw.innerHTML.replace( 'per Month','').replace( 'per Year','').replace('>.','>'); 874 // log.debug( tmp); 875 cnw.innerHTML = tmp; 876 } 877 // 878 cnw = document.querySelector('#pmpro_actionlink-levels'); 879 if (cnw) { 880 881 cnw.style.display = "none"; 882 } 883 884 885 cnw = document.querySelector('#pmpro_actionlink-change'); 886 if (cnw) { 887 888 cnw.innerHTML = 'Change Membership'; 889 } 890 let lol = document.querySelector('#pmpro_actionlink-logout'); 891 if (lol) { 892 lol.setAttribute('href','/logout?redirect_to=' + encodeURI( '/')); 893 } 894 // 895 } 896} 897 898/*function isMemberOrEditor() 899{ 900 901 var memberCookie = getCookie('jmemberlevel'); 902 903 return (memberCookie=='2' || memberCookie=='3' || memberCookie=='administrator' || memberCookie=='editor' || memberCookie=='contributor') ; 904} 905*/ 906function initArticleCommentsSetup() { 907 let $loc =window.location.pathname ; 908 909 910 911 912 if (!$loc.startsWith('/login') && !$loc.startsWith('/register') && !$loc.startsWith('/user') && !$loc.startsWith('/password') && !$loc.startsWith('/membership')) { 913 // 914 // log.debug('initArticleCommentsSetup A'); 915 const urlParams = new URLSearchParams(window.location.search); 916 const myParam = urlParams.get('cli'); 917 const jmemberlevel = getCookie('jmemberlevel'); 918 let isCommenterLoggedIn = (myParam=='true' || jmemberlevel=='2' || jmemberlevel=='3'); 919 //wpd-sbs-toggle 920 let lit = document.querySelector('.wpd-sbs-toggle'); 921 if (lit) { 922 // log.debug('initArticleCommentsSetup B'); 923 lit.style.display = "none"; //none 924 925 } 926 927 let li = document.querySelector('.wpd-form-wrap'); 928 if (li) { 929 // log.debug('initArticleCommentsSetup C'); 930 if (isCommenterLoggedIn) { 931 li.style.display = ""; 932 } else { 933 li.style.display = "none"; //none 934 } 935 } 936 let lid = document.querySelector('#comments-login-request'); 937 if (lid) { 938 if (isCommenterLoggedIn) { 939 lid.style.display = "none" 940 } else { 941 lid.style.display = "block"; 942 } 943 } 944 945 document.cookie = "um_previous_page=" + encodeURI( $loc); 946 947 let l = document.querySelector('.wpd-login a'); 948 if (l) { 949 l.setAttribute('href',l.getAttribute('href') + '?redirect_to=' + encodeURI( $loc)); 950 } 951 let c = document.querySelector('.wpd-login-to-comment'); 952 if (c) { 953 954 if (c.innerText.includes('login')) { 955 c.innerHTML = 'Please <a href="/login?redirect_to=' + encodeURI( $loc) + '">LOG IN</a> to comment'; 956 957 } 958 959 960 } 961 962 let lo = document.querySelectorAll('.wpd-login > a'); 963 if (lo) { 964 965 if(lo[0]) { 966 967 if (lo[0].getAttribute('href','author')) { 968 969 970 lo[0].setAttribute('href','/membership-account/?redirect_to=' + encodeURI( $loc) ) 971 972 } 973 } 974 975 if(lo[1]) { 976 977 if (lo[1].innerHTML.includes('out')) { 978 // log.debug('changeit'); 979 980 lo[1].setAttribute('href','/logout?redirect_to=' + encodeURI( $loc) ) 981 lo[1].innerHTML = 'Log Out'; 982 983 } 984 } 985 } 986 987 } 988 989 if ($loc.startsWith('/membership-')) { 990 991 l = document.querySelector('#pmpro_actionlink-logout'); 992 if (l) { 993 l.setAttribute('href','/logout'); 994 } 995 } 996} 997function AddTrailingSlash(v) { 998 if (v!=null) { 999 if (!v.endsWith('/')) { 1000 v += '/'; 1001 } 1002 } 1003 return v; 1004} 1005function isTopInView(el) { 1006 const rect = el.getBoundingClientRect(); 1007 const windowHeight = window.innerHeight || document.documentElement.clientHeight; 1008
1009 // Check if the top of the element is within the vertical viewport bounds 1010 return rect.top >= 0 && rect.top <= windowHeight; 1011} 1012 1013function setScrollDetails(obj, usePreviousEntry) { 1014 let tmpId=""; 1015 let correctObject= null; 1016 1017 1018 1019 1020 if (obj.constructor.name == 'IntersectionObserverEntry') { 1021 correctObject=obj.target; 1022 tmpId = correctObject.getAttribute("id"); 1023 } else { 1024 correctObject=obj; 1025 tmpId = correctObject.getAttribute("id"); 1026 } 1027 1028 lastSectionObserved = correctObject; 1029 1030 1031 //console.log(correctObject); 1032 1033 // console.log("tmpId: " + tmpId); 1034 log.info('Scrolling ALL setScrollDetails: ' + usePreviousEntry); 1035 // log.info('Scrolling not instersecting: ' + tmpId); 1036 if (usePreviousEntry) { 1037 tmpId= tmpId.replace("-1","-0").replace("-2","-1").replace("-3","-2").replace("-4","-3").replace("-5","-4").replace("-6","-5").replace("-7",-"6"); 1038 } 1039 // log.info('Scrolling not instersecting above: ' + tmpId); 1040 1041 let actHere = document.querySelector('#' + tmpId); 1042 1043 let thisUrl = actHere.getAttribute('url') 1044 history.replaceState(null, null, thisUrl); 1045 1046 1047 let title = correctObject.querySelector('article').getAttribute("seo_title"); 1048 1049 title=stripHtml (title) ; 1050 1051 1052 1053 1054 // log.info('Scrolling trigger page_view: ' + title); 1055 thisUrlWithSlash=AddTrailingSlash(thisUrl); 1056 const url = new URL(thisUrl); 1057 if (window.scrollY > 0) { 1058 if ( typeof htlbid !== 'undefined' && htlbid !== null ) { 1059 if (document.querySelector("#bottom_leaderboard")!==null) { 1060 htlbid.reloadSlot('bottom_leaderboard'); 1061 } 1062 if ((document.querySelector("#above_logo")!==null) && document.querySelector("#above_logo").checkVisibility()) { 1063 htlbid.reloadSlot('above_logo'); 1064 } else { 1065 if (document.querySelector("#top_leaderboard")!==null) { 1066 htlbid.reloadSlot('top_leaderboard'); 1067 } 1068 } 1069 1070 // console.log("htlbid.reloadSlot('middle_rectangle_a');") 1071 htlbid.reloadSlot('middle_rectangle_a'); 1072 htlbid.reloadSlot('middle_rectangle_b'); 1073 // console.log("htlbid.reloadSlot('middle_rectangle_b');") 1074 } 1075 1076 gtag('event', 'page_view', { 1077 page_title: title, 1078 page_location: thisUrlWithSlash, 1079 // page_path: url.pathname 1080 }); 1081 } 1082 if ( typeof pSUPERFLY !== 'undefined' && pSUPERFLY !== null ) { 1083 1084 if (window.scrollY> 0) { 1085 let a = document.querySelector("#" + correctObject.getAttribute("id") + " .bylinepublished a").innerText ; 1086 if ( typeof a === 'undefined' && a === null ) { 1087 a=""; 1088 } 1089 let s = document.querySelector("#" + correctObject.getAttribute("id") + " .header .type a").innerText; 1090 if ( typeof s === 'undefined' && s === null ) { 1091 s=""; 1092 } 1093 1094 1095 // console.log("author: " + a); 1096 // console.log("section: " + s); 1097 // console.log("path: " + url.pathname); 1098 // console.log("title: " + title); 1099 pSUPERFLY.virtualPage({ 1100 sections: s, 1101 authors: a, 1102 path: url.pathname, 1103 title: title 1104 }); 1105 } 1106 } 1107 // currentIntersectionEntry=entryToActOn; 1108} 1109 1110var lastSectionObserved = null; 1111 1112if (doScroll) { 1113document.addEventListener("DOMContentLoaded", () => { 1114 //scrollTracker 1115 //lastAdRefresh: null,lastPaveViewRecorded: null 1116 log.setDefaultLevel(log.levels.TRACE, true); 1117 //log.debug('log.getLevel(): ' + log.getLevel()); 1118 log.setLevel('silent', true) 1119 // log.debug('log.getLevel(): ' + log.getLevel()); 1120 1121 if (true || (document.getElementsByClassName('postid-1825910190') !== null && document.getElementsByClassName('postid-1825910190').length>0)) 1122 { 1123 let div0 = document.querySelector('div[id="scroll-section-0"]'); 1124 if (div0!==null) { 1125 origUrl = div0.getAttribute("url"); 1126 } 1127 1128 let sectionsScroll = document.querySelectorAll('div[id^="scroll-section-"]'); 1129 1130 1131 sectionsScroll.forEach(p => { 1132 1133 p.classList.remove('hide'); 1134 1135 }); 1136 1137 1138 1139 log.info('section0'); 1140 let section0 = document.querySelector('div[id^="scroll-section-0"]'); 1141 if (section0!=null) { 1142 let postId=section0.getAttribute("post_id"); 1143 let url=section0.getAttribute("url"); 1144 1145 1146 log.info(postId); 1147 log.info(url); 1148 getCommentCount(section0,url,postId); 1149 } 1150 // log.debug('postid-1825910190 HERE WE GO'); 1151 1152 const observerOptions = { 1153 root: null, // observe intersections with the viewport 1154 rootMargin: '0px', 1155 threshold: 0.1 //0.5 // trigger when 50% of the section is visible 1156 }; 1157 1158 observer = new IntersectionObserver((entries, observer) => { 1159 1160 prevEntry=null; 1161 bottomOfPreviousSection=0 1162 let stopLoop=false; 1163 1164 let isIntersectionFound=false;
1165 entries.forEach(entry => { 1166 lastObserverTriggered=entry; 1167 // console.log('IO: ' + entry.target.getAttribute("id")); 1168 // console.log('IO: ' + entry.isIntersecting); 1169 // console.log( entry.target); 1170 //if(currentIntersectionEntry!=null) { 1171 // log.info('Scrolling all current: ' + currentIntersectionEntry.target.getAttribute("id")); 1172 // } else { 1173 // log.info('Scrolling all current: ' + 'null'); 1174 // } 1175 1176 if (prevEntry == null) { 1177 prevEntry = entry; 1178 } 1179 let entryToActOn=entry; 1180 1181 1182 if (entryToActOn.isIntersecting) { 1183 isIntersectionFound=true; 1184 currentIntersectionEntry=entryToActOn; 1185 log.info('Scrolling all isIntersecting: ' + entry.target.getAttribute("id")); 1186 1187 1188 let lastIntersectionsId=0; 1189 if (lastIntersection == null ) { 1190 lastIntersectionsId=document.querySelector("#scroll-section-0").getAttribute('id'); 1191 } else { 1192 1193 lastIntersectionsId= lastIntersection.target.getAttribute('id'); 1194 } 1195 1196 1197 1198 log.info('Scrolling lastIntersectionsId: ' + lastIntersectionsId); 1199 1200 1201 let isCurrentSectionInView = isTopInView(entryToActOn.target); 1202 1203 1204 const iId = entryToActOn.target.getAttribute('id'); 1205 1206 let thisPostId = entryToActOn.target.getAttribute('post_id'); 1207 1208 1209 1210 let sectionsToChange = document.querySelectorAll('div[id^="scroll-section-"]'); 1211 1212 1213 sectionsToChange.forEach(p => { 1214 1215 let postId=p.getAttribute("post_id"); 1216 1217 let mp = p.querySelector('#disqus-comment-count-wrapper') 1218 if(mp!=null) { 1219 mp.classList.remove("hide"); 1220 1221 } 1222 1223 1224 }); 1225 1226 1227 1228 setScrollDetails(entryToActOn, false); 1229 1230 isFirstObserverTriggered=true; 1231 1232 1233 lastIntersection=entry; 1234 stopLoop=true; 1235 1236 // log.info("Scrolling: i want to break"); 1237 } else { 1238 // not intesecting 1239 1240 1241 1242 // log.info('Scrolling all maybe skip: ' + entry.target.getAttribute("id")); 1243 // log.info('Scrolling all maybe skip:' + currentIntersectionEntry.target.getAttribute("id")); 1244 1245 // if(entry.target.getAttribute("id") == "scroll-section-0" && currentIntersectionEntry.target.getAttribute("id") == "scroll-section-1") { 1246 // log.info('Scrolling all skip: ' + 'adjustment'); 1247 // } else { 1248 //setScrollDetails(entryToActOn, true); 1249 //} 1250 1251 } 1252 prevEntry=entry; 1253 1254 1255 }); 1256 if (!isIntersectionFound) { 1257 let isSectionFound = false; 1258 1259 // console.log("IO: No Interection" ); 1260 1261 1262 document.querySelectorAll('div[id^="scroll-section-"]').forEach(element => { 1263 if (!isSectionFound) { 1264 if (isElementPartiallyInViewport(element)) { 1265 // console.log("set url"); 1266 setScrollDetails(element, false); 1267 1268 isSectionFound=true; 1269 1270 } 1271 } 1272 }); 1273 1274 1275 1276 1277 } 1278 1279 }, observerOptions); 1280 1281 setStickyAside(); 1282 1283 let sections = document.querySelectorAll('div[id^="scroll-section-"]'); 1284 1285 var loadCnt=0; 1286 1287 sections.forEach(p => { 1288 1289 1290 1291 1292 if ( p.getAttribute('id') == 'scroll-section-0') { 1293 1294 p.querySelectorAll("blockquote[class='instagram-media']").forEach((item, index) => { 1295 log.debug ('insta: blockquotex' ); 1296 log.debug(item); 1297 log.debug (item ); 1298 let iUrl= item.getAttribute('data-instgrm-permalink'); 1299 log.debug ('insta iUrl: ' + iUrl); 1300 const r = /(reel|p)\/([^\/]*)/; 1301 const match = iUrl.match(r); 1302 // preg_match('/\/p\/([^\/]*)\//si', iUrl, $output_array); 1303 if ( match!=null && match.length==3) { 1304 log.debug ('insta: ' + match[2]); 1305 const rnd = Math.floor(Math.random() * 9999999); 1306 const rframe='<iframe class="instagram-media instagram-media-rendered" id="instagram-embed-' + rnd + '" src="https://www.instagram.com/p/' + match[2] + '/embed/" allowtransparency="true" allowfullscreen="true" frameborder="0" height="674" data-instgrm-payload-id="instagram-media-payload-0" scrolling="no" style="background: white; max-width: 540px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); box-shadow: none; display: block; margin: 0px 0px 12px; min-width: 326px; padding: 0px;position:relavtive"></iframe>'; 1307 1308 item.outerHTML=rframe; 1309 } 1310 }); 1311 1312 } 1313 1314 1315 1316 if ( p.getAttribute('id') != 'scroll-section-0') { 1317 1318 let url = p.getAttribute('url') ; //'https://www.avclub.com/john-waters-christmas-interview-2025'; 1319 let postId = p.getAttribute('post_id') ; 1320 1321 let xhr = new XMLHttpRequest(); 1322 1323 1324 // let postId=p.getAttribute("post_id"); 1325 // log.debug('get : ' + url); 1326 // log.debug(p); 1327 xhr.open('GET', url, true); // true for asynchronous operation 1328 1329 xhr.onreadystatechange = function () { 1330 1331 if (xhr.readyState === 4 && xhr.status === 200) { 1332 1333 let data = xhr.responseText; 1334 //log.debug(data); 1335 const parser = new DOMParser(); 1336 log.setLevel('trace'); 1337 1338 const doc = parser.parseFromString(data, "text/html"); 1339 // log.debug(doc.body.querySelector("h1").textContent) 1340 //log.debug(doc.body.querySelector("article")) 1341 p.innerHTML=doc.body.querySelector("article").outerHTML; 1342 1343 let dts = p.querySelector("[id^='disqus_thread']"); 1344 // log.debug('dts'); 1345 // log.debug(dts); 1346 dts.setAttribute('id','disqus_thread_' + p.getAttribute("post_id")); 1347 1348 let numbers = p.id.replace(/\D/g, ''); 1349 1350 p.querySelectorAll('div[id^="mid_leaderboard_rectangle_"]').forEach(d => { 1351 //log.debug("Add x_"+numbers); 1352 // log.debug(d); 1353 p.removeAttribute("data-ad-processed"); 1354 //if(!d.id.startsWith("x_")) { 1355 //d.id=("id","x_" + numbers + "_" + d.getAttribute("id")); 1356 // d.id=d.id.replace('_rectangle_','_rectangle_' + postId +'_') 1357 d.id=d.id + '_' + postId 1358 // log.debug(d);log.debug("Add x_ done"); 1359 // d.setAttribute("class", d.getAttribute("class").replace('_rectangle_','_rectangle_' + postId +'_')); 1360 // } 1361 }); 1362 1363 let aurl= p.getAttribute('url'); 1364 log.debug ('insta aurl: ' +aurl ); 1365 log.debug(p) 1366 log.debug ('get insta embeds' ); 1367 p.querySelectorAll("blockquote[class='instagram-media']").forEach((item, index) => { 1368 log.debug ('insta: blockquotex' ); 1369 log.debug(item); 1370 log.debug (item ); 1371 let iUrl= item.getAttribute('data-instgrm-permalink'); 1372 log.debug ('insta iUrl: ' + iUrl); 1373 const r = /(reel|p)\/([^\/]*)/; 1374 const match = iUrl.match(r); 1375 // preg_match('/\/p\/([^\/]*)\//si', iUrl, $output_array); 1376 if ( match!=null && match.length==3) { 1377 log.debug ('insta: ' + match[2]); 1378 const rnd = Math.floor(Math.random() * 9999999); 1379 const rframe='<iframe class="instagram-media instagram-media-rendered" id="instagram-embed-' + rnd + '" src="https://www.instagram.com/p/' + match[2] + '/embed/" allowtransparency="true" allowfullscreen="true" frameborder="0" height="674" data-instgrm-payload-id="instagram-media-payload-0" scrolling="no" style="background: white; max-width: 540px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); box-shadow: none; display: block; margin: 0px 0px 12px; min-width: 326px; padding: 0px;position:relavtive"></iframe>'; 1380 1381 item.outerHTML=rframe; 1382 } 1383 }); 1384 1385 loadCnt++; 1386 1387 if(loadCnt===scrollSectionsToAddCount) { 1388 1389 1390 1391 1392 let newSections = document.querySelectorAll('div[id^="scroll-section-"]'); 1393 1394 1395 1396 1397 newSections.forEach(section => { 1398 1399 postId=section.getAttribute("post_id"); 1400 url=section.getAttribute("url"); 1401 1402 //observer.observe(section); 1403 1404 1405 1406 1407 getCommentCount(section,url,postId); 1408 let dt = section.querySelector('div[id^="disqus_thread"]') 1409 if (dt!=null) { 1410 dt.setAttribute("id","disqus_thread_" + section.getAttribute("post_id")); 1411 dt.innerHTML=''; 1412 } 1413 1414 let asm = document.querySelector('#article-share-button[post_id="' + postId + '"]'); 1415 asm.addEventListener('click', function(event) { 1416 log.debug('Element clicked!'); 1417 let pid = event.target.getAttribute("post_id"); 1418 log.debug('post_id' + pid); 1419 let smp = document.querySelector('#article-share-button[post_id="' + pid + '"]').parentElement; 1420 let sm = smp.querySelector('#article-share-menu'); 1421 1422 // let sm = $('#article-share-menu'); 1423 if (sm!==null) { 1424 if (sm.classList.contains("is-open")) { 1425 1426 1427 1428 sm.classList.remove("is-open") 1429 sm.setAttribute("aria-hidden", true); 1430 // sm.addClass("hide"); 1431 sm.classList.add("hide") 1432 } else { 1433 1434 sm.classList.add("is-open") 1435 sm.setAttribute("aria-hidden", false); 1436 // sm.addClass("hide"); 1437 sm.classList.remove("hide") 1438 } 1439 } else { 1440 // sm.removeClass("is-open"); 1441 // sm.attr("aria-hidden", true); 1442 // sm.addClass("hide"); 1443 } 1444 1445 });
1446 // resizeObserver.observe(dt); 1447 1448 1449 }); 1450 1451 positionRightRailAds(0); 1452 1453 1454 let lastMore = document.querySelector("#scroll-section-" + scrollSectionsToAddCount + " .scroll-more") 1455 if (lastMore!=null) { 1456 lastMore.innerHTML=''; 1457 } 1458 let newObSections = document.querySelectorAll('div[id^="scroll-section-"]'); 1459 1460 newObSections.forEach(section => { 1461 log.debug('initial observe', section); 1462 1463 observer.observe(section); 1464 }); 1465 1466 populateBlueskyEmbeds(); 1467 populateTwitterEmbeds(); 1468 /* tmr = setTimeout(function () { 1469 1470 let dts = document.querySelectorAll('div[id^="disqus_thread"]').forEach((item, index) => { 1471 1472 log.debug("add resizeObserver"); 1473 1474 resizeObserver.observe(item); 1475 }); 1476 }, 5000); 1477 */ 1478 1479 1480 1481 /* 1482 document.querySelectorAll('div[id^="disqus_thread"]').forEach(d => { 1483 //log.debug("Add x_"+numbers); 1484 log.debug('set disqusid: ' + "disqus_thread_" + d.parentNode.getAttribute("post_id")); 1485 log.debug(d); 1486 d.setAttribute("id","disqus_thread_" + d.parentNode.getAttribute("post_id")); 1487 d.innerHTML=''; 1488 1489 }); 1490 */ 1491 1492 /************************************/ 1493 let $goToCommentsButton = jQuery('.comment-count-go-to'); 1494 1495 // log.debug('add comment click handlers');o 1496 1497 if ($goToCommentsButton.length>0) { 1498 1499 $goToCommentsButton.each(function(index, element) { 1500 1501 // log.debug('add comment click handler'); 1502 // log.debug( $goToCommentsButton[index]); 1503 jQuery(element).on('click', function(event) { 1504 event.preventDefault(); 1505 $clickedObj = jQuery(this); 1506 // log.debug('parent'); 1507 $clickedPostId= $clickedObj.attr("post_id") 1508 log.debug('$clickedPostId: ' + $clickedPostId); 1509 let myQ='.scroll-article-container[post_id="' + $clickedPostId + '"] #disqus-comment-count-wrapper'; 1510 1511 let $xclick = document.querySelector(myQ); 1512 1513 1514 showCommentsForScroll( $xclick,$clickedPostId); 1515 1516 1517 $ss= $clickedObj.parentsUntil('div.scroll-article-container') 1518 // log.debug('parent ss'); 1519 // log.debug($ss.parent('div')); 1520 1521 $sectionScrollElement = $ss.parent('div'); 1522 $sid = $sectionScrollElement.attr('id'); 1523 // log.debug( $sid); 1524 1525 jQuery( $sid +" .sbn-read-more-unlock-btn.rc-read-more-unlock-btn").trigger("click"); 1526 // log.debug('$goToCommentsButtonClick'); 1527 1528 let $showCommentsButtonWrapper = jQuery('#' + $sid + ' #disqus-comment-count-wrapper'); 1529 1530 jQuery('#' + $sid +" .sbn-read-more-unlock-btn.rc-read-more-unlock-btn").trigger("click"); 1531 var container = jQuery('#' + $sid + ' #comment-marker'); 1532 1533 jQuery('html, body').animate({ 1534 scrollTop: container.offset().top - 200 1535 },0); 1536 1537 1538 $showCommentsButtonWrapper.css({ display: "none" }); 1539 jQuery('.wp-block-comments').removeClass("hide"); 1540 1541 } ); //end animate 1542 1543 }); //end click 1544 } //end for loop 1545 /************************************/ 1546 1547 } 1548 } else if (xhr.readyState === 4) { 1549 1550 console.error('An error occurred:', xhr.statusText); 1551 } 1552 }; 1553 1554 xhr.send(); 1555 } 1556 }); 1557 1558 1559 1560 1561 1562 1563 1564 1565 // Optional: Handle the case when the user scrolls back to the very top (remove the hash) 1566 /* window.addEventListener('scroll', () => { 1567 if (window.scrollY === 0) { 1568 history.replaceState(null, null,origUrl); // window.location.pathname 1569 } 1570 });
1571 */ 1572} 1573 1574 /* 1575 if (window.innerWidth<1024 && doScroll) { 1576 document.querySelector('.htlad-middle_rectangle').style.display = "none"; 1577 document.querySelector('.htlad-top_rectangle').style.display = "none"; 1578 1579 } 1580 */ 1581 1582 1583 log.debug('attempt findhighlight'); 1584let tmpx = jQuery('b.type a') 1585if (tmpx.length>0) { 1586 let tmph = tmpx[0].text; 1587 if (tmph.length>0) { 1588 let tmpo = jQuery('.bottom-link-row.horizontal a:contains(' + tmph + ')'); 1589 if (tmpo.length>0) { 1590 tmpo.addClass('active') 1591 log.debug('findhighlight'); 1592 log.debug(tmpo); 1593 } 1594 } 1595} 1596 log.trace("before remove ads"); 1597 1598if (isMemberOrEditor()) { 1599 1600 1601 1602 1603 1604 log.trace("remove ads"); 1605 1606 jQuery('#top_leaderboard').remove(); 1607 jQuery('head img').remove(); 1608 jQuery("[class^=htlad]").remove(); //css("display", "none"); 1609 jQuery(".dfp").remove(); //.css("display", "none"); 1610 jQuery("#master-header").css("margin-top", "0"); 1611 jQuery("#block-19 p").remove(); //.css("display", "none !important"); 1612 jQuery("#block-8 p").remove(); //.css("display", "none !important"); 1613 // let taboola = jQuery("#taboola-below-article-feed"); 1614 // if(taboola) { 1615 //log.debug('taboola-below-article-feed'); 1616 // taboola.html(""); 1617 // taboola.remove(); //.css("display", "none !important"); 1618 } 1619 // taboola = jQuery("#taboola-below-home-page-feed"); 1620 // if(taboola) { 1621 //log.debug('taboola-below-home-page-feed'); 1622 // taboola.html(""); 1623 // taboola.remove(); //.css("display", "none !important"); 1624 // } 1625 1626 // taboola = jQuery("#taboola-below-section-front-feed"); 1627 // if(taboola) { 1628 // log.debug('taboola-below-section-front-feed'); 1629 // taboola.html(""); 1630 //taboola.remove(); //.css("display", "none !important"); 1631 // } 1632 //log.debug ('SUPPRESS ADS DONE'); 1633 1634 1635 1636 log.debug('getIsRestrictedContent'); 1637 //initArticleCommentsSetup(); 1638 if( getIsRestrictedContent() && ! getIsAccessToRestrictedContentAllowed()) { 1639 let el = jQuery( '.copy.entry' ); 1640 // log.debug(el); 1641 // log.debug(el.children('p').first().prop('outerHTML')); 1642 let el2 = el.children('p').eq(1); 1643 let p2 = ''; 1644 if(el2) { 1645 el2.attr("class","blur"); 1646 //let ih = el2.prop('innerHTML') 1647 1648 //el2.prop('outerHTML') 1649 p2= el2.prop('outerHTML') 1650 } 1651 // log.debug(el.firstChild.innerHTML); 1652 if (el) { 1653 let loc =window.location.pathname 1654 //log.debug("remove content") 1655 1656 1657 el.html(el.children('p').first().prop('outerHTML') + p2 + '<div class="login-content"><div class="restricted-warning"><p class="heading">This content is available to subscribers only<p><p>Welcome to Jezebel! Help support our cause and get access to our subscriber-only content. You\'ll also get invited to our private Discord channel, access to our our monthly Jezebel book club, and a chance to win limited-edition Jezebel merch from artists we love.</p><div class="wide-group"><div class="group"><p class="subhead group">Monthly</p><p class="group bullet">FREE Jezebel T-shirt</p><p class="group bullet">Exclusive Content</p><p class="group bullet">Comment on Articles</p> <p class="group bullet"><span style=" text-decoration: line-through;">$8</span> $5/month</p></div><div class="group bullet"><p class="subhead group">Annual</p><p class="group bullet">Get a T-Shirt & Tote Bag</p><p class="group bullet">Exclusive Content</p><p class="group bullet">Comment on Articles</p><p class="group bullet"><span style=" text-decoration: line-through;">$80</span> $50/year</p><p class="group"> </p> </div></div><div class="wide-group buttons"><div class="group"><div class="spacer"><div class="button"><a href="/membership-account/membership-checkout?level=2">Subscribe</a></div></div> </div></div><div class="group"><div class="spacer"><div class="button"><a href="/membership-account/membership-checkout?level=3">Subscribe</a></div></div></div><hr><div class="wide-group buttons"><div class="group"><div class="spacer"><div class="button"><a href="/login?redirect_to=' + encodeURIComponent(loc) + '">Log In</a></div></div> </div></div>'); 1658 1659 } 1660 el = jQuery( '#comments' ); 1661 // log.debug(el); 1662 if (el) { 1663 log.debug("remove comments") 1664 el.html(''); 1665 1666 1667 } 1668 1669 //''
1670 el = jQuery( '.grid-x.article-shares-links.four' ); 1671 // log.debug(el); 1672 if (el) { 1673 // log.debug("remove shares") 1674 el.html(''); 1675 1676 1677 } 1678 } 1679 initMembershipSetup(); 1680 1681$bntrm= jQuery(".sbn-read-more-unlock-btn.rc-read-more-unlock-btn"); 1682 if($bntrm.length>0) { 1683 1684 $bntrm.attr('style','background:#a90026;font-family:Tahoma, sans-serif !important;width:100%;font-size:18px;'); 1685 } 1686 1687}); 1688} else { 1689 1690 1691 1692} 1693 1694 1695//document.addEventListener("DOMContentLoaded", () => { 1696 1697 1698//log.debug('Suppress Ads???'); 1699 1700 // 1701 1702//}); 1703 1704 1705/////////////////} 1706 1707 1708 1709 1710 1711 1712jQuery(function ($) { 1713 /** 1714 * MOBILE NAV 1715 */ 1716 // log.debug('MOBILE NAV'); 1717 1718 /* $(document).on('click', function(event) { 1719 1720 if($(event.target).attr('id') != '32rdph-dd-anchor' && !$(event.target).hasClass('icon-menu')) { 1721 log.debug('click NOT 32rdph-dd-anchor'); 1722 $('.top-bar-right > .menu').removeClass("hover"); 1723 $('.top-bar-right > .menu').attr("aria-expanded", false); 1724 $("#small-navigation-menu") 1725 .removeClass("is-open") 1726 .attr("aria-hidden", true); 1727 } else { 1728 log.debug('click IS 32rdph-dd-anchor'); 1729 1730 } 1731 1732 }); */ 1733 1734 $(document).on('click', function(event) { 1735 log.debug('document.click'); 1736 log.debug(event.target.id); 1737 //article-share-button 1738 if (isOkToCloseMenu(event)) { 1739 log.debug('close it'); 1740 if($(event.target).attr('id') != '32rdph-dd-anchor' && !$(event.target).hasClass('icon-menu')) { 1741 $('.top-bar-right > .menu').removeClass("hover"); 1742 $('.top-bar-right > .menu').attr("aria-expanded", false); 1743 $("#small-navigation-menu") 1744 .removeClass("is-open") 1745 .attr("aria-hidden", true); 1746 } 1747 } 1748 1749 let sm = $('#article-share-menu'); 1750 if (sm) { 1751 if (sm.hasClass("is-open")) { 1752 if(event.target.id != 'article-share-button') { 1753 sm.removeClass("is-open"); 1754 sm.attr("aria-hidden", true); 1755 sm.addClass("hide"); 1756 } 1757 } else { 1758 1759 } 1760 } 1761 }); 1762 $(document).on("click", ".top-bar-right > .menu", function () { 1763 log.debug('click mm'); 1764 if (!$(this).hasClass("hover")) { 1765 $(this).addClass("hover"); 1766 $(this).attr("aria-expanded", true); 1767 $("#small-navigation-menu") 1768 .addClass("is-open") 1769 .attr("aria-hidden", false); 1770 } else { 1771 if (isOkToCloseMenu(event)) { 1772 $(this).removeClass("hover"); 1773 $(this).attr("aria-expanded", false); 1774 $("#small-navigation-menu") 1775 .removeClass("is-open") 1776 .attr("aria-hidden", true); 1777 } 1778 } 1779 }); 1780 1781 1782 1783 1784 1785 1786 1787 //}); 1788 1789 1790 1791 1792 1793 1794 $(document).on("click", "#share-link-copy", function (event) { 1795 event.preventDefault(); 1796 1797 1798 1799 1800 // console.log(event.target.getAttribute('href')); 1801 navigator.clipboard.writeText(event.target.getAttribute('href')); 1802 // c.click(); 1803 event.target.parentNode.parentNode.classList.add('hide'); 1804 // c.classList.add('hide'); 1805 // $('.close-button').trigger('click'); 1806}); 1807 1808 1809 1810 $(document).on("click", "#article-share-button", function () { 1811 // log.debug('share click'); 1812 event.preventDefault(); 1813 let sm = $('#article-share-menu'); 1814 if (sm.hasClass("hide")) { 1815 // $(this).addClass("hover"); 1816 // $(this).attr("aria-expanded", true); 1817 1818 sm.addClass("is-open"); 1819 sm.attr("aria-hidden", false); 1820 sm .removeClass("hide"); 1821 } else { 1822 // if (isOkToCloseMenu(event)) { 1823 // $(this).removeClass("hover"); 1824 // $(this).attr("aria-expanded", false); 1825 // $("#article-share-menu") 1826 // .removeClass("is-open") 1827 // .addClass("hide") 1828 // .attr("aria-hidden", true); 1829 // } 1830 } 1831 }); 1832 1833 1834 1835 /* 1836 $(document).on("click", ".top-bar-right > .menu", function () { 1837 if (!$(this).hasClass("hover")) { 1838 $(this).addClass("hover"); 1839 $(this).attr("aria-expanded", true); 1840 $("#small-navigation-menu") 1841 .addClass("is-open") 1842 .attr("aria-hidden", false); 1843 } else { 1844 if (isOkToCloseMenu(event)) { 1845 $(this).removeClass("hover"); 1846 $(this).attr("aria-expanded", false); 1847 $("#small-navigation-menu") 1848 .removeClass("is-open") 1849 .attr("aria-hidden", true); 1850 } 1851 } 1852 }); 1853 1854 */ 1855
1856 let u = new URL(window.location); 1857 u.hash = ''; 1858 u.search = ''; 1859 1860 1861 let loc = encodeURIComponent(u.toString()); 1862 1863 1864 1865 jQuery.ajax({ 1866 type: 'get',url: 'https://disqus.com/api/3.0/threads/details.json?api_key=mZyGvuGCJddMuwBLSBOrVIYboExFoMNur40ypGj1ZCMFOSKsXDbi17RhenUYeBDV&callback=foo&forum=jezebel-1&thread=link:' + loc , 1867 success: function (data) { 1868 //jdata=JSON.parse(data); 1869 1870 let r = data.match(/\"posts\":(\d+)/); 1871 1872 1873 let t1 = $('.disqus-comment-count span.text'); 1874 if (t1) { 1875 t1.html(r[1]); 1876 } 1877 let t = $('#show-comment-block') 1878 if (t) { 1879 if (r[1] === '0' || r[1] === '' ) { 1880 t.html('Start the discussion...'); 1881 } else if (r[1] == '1' ) { 1882 t.html('Continue the discussion...'); 1883 } else { 1884 t.html('Show all ' + r[1] + ' comments...'); 1885 } 1886 } 1887 1888 1889 1890 }, 1891 error: function (request, status, error) { 1892 log.debug(error); 1893 } 1894 1895}); 1896 1897 1898 let $showCommentsButton = $('#show-comments-button'); 1899 1900 let $showCommentsButtonWrapper = $('#disqus-comment-count-wrapper'); 1901 if ($showCommentsButtonWrapper) { 1902 1903 1904 1905 $($showCommentsButtonWrapper).on('click', function(event) { 1906 //event.preventDefault(); 1907 1908 1909 $showCommentsButtonWrapper.css({ display: "none" }); 1910 1911 $('.wp-block-comments').removeClass("hide"); 1912 } ); 1913 1914 } 1915 1916 1917 let $goToCommentsButton = $('.comment-count-go-to'); 1918 if ($goToCommentsButton) { 1919 1920 1921 1922 $($goToCommentsButton).on('click', function(event) { 1923 event.preventDefault(); 1924 $(".sbn-read-more-unlock-btn.rc-read-more-unlock-btn").trigger("click"); 1925 // log.debug('$goToCommentsButtonClick'); 1926 1927 let $showCommentsButtonWrapper = $('#disqus-comment-count-wrapper'); 1928 1929 1930 var container = $('#comment-marker'); 1931 1932 $('html, body').animate({ 1933 scrollTop: container.offset().top 1934 },0); 1935 1936 1937 $showCommentsButtonWrapper.css({ display: "none" }); 1938 $('.wp-block-comments').removeClass("hide"); 1939 1940 } ); 1941 1942 } 1943 1944 1945 /** 1946 * STICKY AD 1947 */ 1948 /* 1949 $(window).on("scroll resize",function(e){ 1950 1951 1952 $t = $('#taboola-below-article-feed'); 1953 if ($t.length === 0) { 1954 1955 1956 $t = $('#taboola-below-section-front-feed'); 1957 //taboola-below-section-front-feed 1958 if ($t.length === 0) { 1959 1960 1961 $t = $('#taboola-below-home-page-feed'); 1962 } 1963 } 1964 1965 1966 1967 if($t.length !== 0) { 1968 let elementTop = $t.offset().top; 1969 let elementBottom = elementTop + $t.outerHeight(); 1970 let viewportTop = $(window).scrollTop(); 1971 let viewportBottom = viewportTop + $(window).height(); 1972 if ( elementBottom > viewportTop && elementTop < + viewportBottom) { 1973 $('#bottom-fixed-unit').hide(); 1974 1975 } else { 1976 $('#bottom-fixed-unit').show(); 1977 1978 } 1979 } 1980 1981}); */ 1982 1983 1984 /* 1985 $(window).on("resize scroll",function(e){ 1986 // log.debug($(this).width()) 1987 if( $(this).width() >= 1024) { 1988 var $el = $('.pm-sticky'); 1989 var isPositionFixed = ($el.css('position') == 'fixed'); 1990 if ($(this).scrollTop() > 3860 && !isPositionFixed){ 1991 $el.css({'position': 'fixed', 'top': '138px'}); 1992 } 1993 if ($(this).scrollTop() < 3860 && isPositionFixed){ 1994 $el.css({'position': 'static', 'top': '0px'}); 1995 } 1996 } 1997}); 1998*/ 1999 /** 2000 * AJAX SEARCH 2001 */ 2002 2003 if ($("#master-search").length) { 2004 function prodFrontendSearch(inputSelector, listSelector) { 2005 var q = inputSelector.val(); 2006 2007 if (q.length > 2 /* || q !== "undefined" */) { 2008 $("#search_in_progress").addClass("active"); 2009 2010 $.ajax({
2011 url: ajaxurl, 2012 method: "POST", 2013 data: { 2014 action: "pm_article_search", 2015 q: q, 2016 }, 2017 error: function (jqXHR, textStatus, errorThrown) { 2018 console.error("SEARCH AJAX ERROR: " + errorThrown); 2019 }, 2020 }).done(function (response) { 2021 if (response.success === true) { 2022 2023 listSelector 2024 .html(response.data.search_results) 2025 .css("width", $("#article-search").outerWidth()); 2026 2027 2028 $("#search_in_progress").removeClass("active"); 2029 2030 } else { 2031 2032 } 2033 }); 2034 } else { 2035 $("#search_results_list").html(""); 2036 2037 listSelector.removeAttr("style"); 2038 } 2039 } 2040 2041 //prodFrontendSearch($("#master-search"), $("#search_results_list")); 2042 2043 $(document).on("click", "#search_results_list li", function () { 2044 window.location = $(this).data("href"); 2045 }); 2046 2047 /** Search input field listener **/ 2048 2049 var TimerS; 2050 2051 $("#master-search").on("keypress keyup focus", function (e) { 2052 if (e.which == 13) { 2053 let q = $("#master-search").val(); 2054 e.preventDefault(); 2055 2056 if (q.length > 0) { 2057 window.location.href = "/search?q=" + q; 2058 } else { 2059 window.location.href = "/search"; 2060 } 2061 } 2062 2063 clearTimeout(TimerS); 2064 TimerS = setTimeout(function () { 2065 //prodFrontendSearch($("#master-search"), $("#search_results_list")); 2066 }, 500); 2067 }); 2068 2069 const queryString = window.location.search; 2070 const urlParams = new URLSearchParams(queryString); 2071 2072 if (queryString !== "") { 2073 $("#master-search").val($.trim(urlParams.get("q"))); 2074 } 2075 //}); 2076 2077 $(document).click(function (event) { 2078 if ( 2079 $(event.target) !== $("#search_results_list") && 2080 $(event.target).closest("#search_results_list").length <= 0 2081 ) { 2082 2083 $("#search_results_list").html("").removeAttr("style"); 2084 2085 } 2086 2087 2088 }); 2089 } 2090 2091 /** 2092 * MUSIC PLAYER 2093 * */ 2094 2095 $.fn.extend({ 2096 uniqueId: (function () { 2097 var e = 0; 2098 return function () { 2099 return this.each(function () { 2100 this.id || (this.id = "ui-id-" + ++e); 2101 }); 2102 }; 2103 })(), 2104 removeUniqueId: function () { 2105 return this.each(function () { 2106 /^ui-id-\d+$/.test(this.id) && e(this).removeAttr("id"); 2107 }); 2108 }, 2109 }); 2110 2111 function unicodeToString(unicodeString) { 2112 return unicodeString; 2113 2114 let decoded = decodeURIComponent(JSON.parse('["' + unicodeString + '"]')); 2115 2116 return decoded; 2117 } 2118 2119 2120 2121 2122 2123 /** 2124 * SOCIAL SHARE 2125 */ 2126/* 2127if ($("#article-share-menu")) { 2128 const t = $("#article-share-menu"); 2129 t.find(".icon-facebook").on("click", function (e) { 2130 e.preventDefault(), 2131 window.open( 2132 "https://www.facebook.com/sharer/sharer.php?u=" + 2133 encodeURIComponent(this.href), 2134 "fb-share", 2135 "status=0,toolbar=0,location=1,width=700,height=400" 2136 ); 2137 }), 2138 t.find(".icon-twitter").on("click", function (e) { 2139 e.preventDefault(); 2140 const t = $(this), 2141 n = $("<div>" + t.data("title") + "</div>").text(); 2142 window.open( 2143 "https://twitter.com/intent/tweet?via=jezebel&related=jezebel&url=" + 2144 encodeURIComponent(this.href) + 2145 "&text=" + 2146 encodeURI(n).replace("&", "%26"), 2147 "tw-share", 2148 "status=0,toolbar=0,location=1,width=700,height=250" 2149 ); 2150 }),
2151 t.find(".icon-reddit-alien").on("click", function (e) { 2152 e.preventDefault(); 2153 const t = $(this), 2154 n = $("<div>" + t.data("title") + "</div>").text(); 2155 window.open( 2156 "https://www.reddit.com/submit?title=" + 2157 n + 2158 "&url=" + 2159 encodeURIComponent(this.href), 2160 "reddit-share","status=0,toolbar=0,location=1,width=700,height=400" 2161 ); 2162 }), 2163 t.find(".icon-pinterest").on("click", function (e) { 2164 e.preventDefault(); 2165 const t = $(this), 2166 n = t.data("image"), 2167 i = $("<div>" + t.data("title") + "</div>").text(); 2168 window.open( 2169 "https://pinterest.com/pin/create/button/?url=" + 2170 encodeURIComponent(this.href) + 2171 "&media=" + 2172 n + 2173 "&description=" + 2174 encodeURI(i).replace("&", "%26"), 2175 "pi-share", 2176 "status=0,toolbar=0,location=1,width=700,height=250" 2177 ); 2178 }), 2179 t.find(".google-plus").on("click", function (e) { 2180 e.preventDefault(); 2181 $(this); 2182 window.open( 2183 "https://plus.google.com/share?url=" + 2184 encodeURIComponent(this.href), 2185 "google-share", 2186 "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600" 2187 ); 2188 }), 2189 t.find(".linked-in").on("click", function (e) { 2190 e.preventDefault(); 2191 const t = $(this), 2192 n = $("<div>" + t.data("title") + "</div>").text(); 2193 window.open( 2194 "https://www.linkedin.com/shareArticle?mini=true&url=" + 2195 encodeURIComponent(this.href) + 2196 "&title=" + 2197 encodeURI(n).replace("&", "%26"), 2198 "linkedin-share", 2199 "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=570,width=520" 2200 ); 2201 }), 2202 t.find(".tumblr").on("click", function (e) { 2203 e.preventDefault(); 2204 const t = $(this), 2205 n = $("<div>" + t.data("title") + "</div>").text(), 2206 i = $( 2207 "<div>" + 2208 $("meta[name='description']").attr("content") + 2209 "</div>" 2210 ).text(); 2211 window.open( 2212 "http://tumblr.com/widgets/share/tool?canonicalUrl=" + 2213 encodeURIComponent(this.href) + 2214 "&posttype=link&content=" + 2215 encodeURIComponent(t.data("href")) + 2216 "&title=" + 2217 encodeURI(n).replace("&", "%26") + 2218 "&caption=" + 2219 encodeURI(i).replace("&", "%26"), 2220 "tumblr-share", 2221 "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=540" 2222 ); 2223 }), 2224 t.find(".icon-email").on("click", function (e) { 2225 e.preventDefault(), 2226 log.debug( t.find(".icon-email a").attr('href')); 2227 window.location.href = t.find(".icon-email a").attr('href'); 2228 2229 2230 }), 2231 t.find(".stumble-upon").on("click", function (e) { 2232 e.preventDefault(), 2233 window.open( 2234 "http://www.stumbleupon.com/submit?url=" + 2235 encodeURIComponent(this.href), 2236 "stumble-share", 2237 "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=800" 2238 ); 2239 }), 2240 t.find(".icon-comment").on("click", function (e) { 2241 e.preventDefault(); 2242 const t = $(this), 2243 n = t.data("title"), 2244 i = this.href, 2245 o = (function () { 2246 const e = navigator.userAgent.toLowerCase(); 2247 var t = []; 2248 if (/iP(hone|od|ad)/.test(navigator.platform)) { 2249 const e = navigator.appVersion.match( 2250 /OS (\d+)_(\d+)_?(\d+)?/ 2251 ); 2252 t = [ 2253 parseInt(e[1], 10), 2254 parseInt(e[2], 10), 2255 parseInt(e[3] || 0, 10), 2256 ]; 2257 } 2258 var n = "sms:"; 2259 return ( 2260 (n += 2261 t.length > 0 && t[0] > 7 2262 ? "&" 2263 : e.indexOf("iphone") > -1 || e.indexOf("ipad") > -1 2264 ? ";" 2265 : "?"), 2266 (n += "body=") 2267 ); 2268 })(), 2269 r = function (e) { 2270 return { 2271 "“": '"', 2272 "”": '"', 2273 " ": " ", 2274 "’": "'", 2275 "—": "-", 2276 "…": "...", 2277 "'": "'", 2278 "‘": "'", 2279 "…": "...", 2280 "é": "E", 2281 "–": "-", 2282 "ö": "O", 2283 "*": "*", 2284 }[e]; 2285 }, 2286 s = 2287 o + 2288 encodeURIComponent(n.replace(/\&#[0-9]+;/g, r)) + 2289 "%0A%0D" + 2290 encodeURIComponent(i); 2291 window.open(s, "_self"); 2292 }); 2293 } 2294 */ 2295}); 2296 2297 2298 2299//}); 2300 2301 2302 2303 var $xjQuery = jQuery.noConflict(); 2304/* 2305jQuery(document).ready(function ($) { 2306 // Your code here 2307 retryEmptyAdSlots(7000,1); 2308 retryEmptyAdSlots(7000+5000,2); 2309 retryEmptyAdSlots(7000+5000+5000,3); 2310 });
2311 */ 2312 2313function retryEmptyAdSlots(msDelay, tryNumber) { 2314 // log.debug('Queue retryEmptyAdSlots(): ' + tryNumber); 2315 /* const myTimeout = setTimeout(function() { 2316 2317 $xjQuery('div[class^=htlad-]').each(function( index ) { 2318 if ( $xjQuery( this ).is(":visible") ) { 2319 //log.debug( index + ": " + $xjQuery( this ).text() ); 2320 let myid = $xjQuery(this).attr('id'); 2321 2322 2323 if ($xjQuery( this ).contents().find("iframe").attr('id') ) { 2324 } else { 2325 2326 htlbid.refreshSlot(myid); 2327 // htlbid.refreshSlot(myid); 2328 } 2329 } 2330 }); 2331 } 2332 , msDelay); 2333 */ 2334} 2335 2336function isOkToCloseMenu(event) { 2337 let $closeIt = true; 2338 let $b =document.getElementById('master-search').getBoundingClientRect(); 2339 log.debug($b) 2340 if ($b && event.clientX > $b.x-20 && event.clientX < $b.width + $b.x +20) { 2341 if ( event.clientY > $b.y -20 && event.clientY < $b.height + $b.y +20) 2342 { 2343 log.debug('ignore click'); 2344 $closeIt = false; 2345 } 2346 2347 } 2348 return $closeIt; 2349} 2350 2351 2352 function updateToolTip(msg) { 2353 //var copyText = document.getElementById("myInput"); 2354 // copyText.select(); 2355 // copyText.setSelectionRange(0, 99999); 2356 // navigator.clipboard.writeText(copyText.value); 2357 2358 var tooltip = document.getElementById("myTooltip"); 2359 tooltip.innerHTML = msg; 2360} 2361 2362function showToolTip(msg) { 2363 var tooltip = document.getElementById("myTooltip"); 2364 tooltip.innerHTML = msg; 2365 tooltip.style.visibility='visible'; 2366 tooltip.style.opacity='1'; 2367 2368 2369 var fadeEffect = setInterval(function () { 2370 if (!tooltip.style.opacity) { 2371 tooltip.style.opacity = 1; 2372 } 2373 if (tooltip.style.opacity > 0) { 2374 tooltip.style.opacity -= 0.1; 2375 } else { 2376 clearInterval(fadeEffect); 2377 tooltip.style.visibility='hidden'; 2378 } 2379 }, 300); 2380 2381 2382} 2383 2384 2385 2386/*function isElementPartiallyInViewport(el) { 2387 const rect = el.getBoundingClientRect(); 2388 const windowHeight = (window.innerHeight || document.documentElement.clientHeight); 2389 const windowWidth = (window.innerWidth || document.documentElement.clientWidth); 2390 2391 // Check if any part of the element is within the viewport boundaries 2392 const vertInView = (rect.top <= windowHeight) && (rect.bottom >= 0); 2393 const horInView = (rect.left <= windowWidth) && (rect.right >= 0); 2394 2395 return vertInView && horInView; 2396} */ 2397 2398 2399 2400function isElementPartiallyInViewport(el) { 2401 2402 const bottomOfElementInViewport = el.getBoundingClientRect().bottom; 2403 let p = bottomOfElementInViewport/window.innerHeight; 2404 2405 if (p<0.82 && p>.4) { 2406 return true; 2407 } else { 2408 return false; 2409 } 2410 2411 2412} 2413 2414 2415 2416function stripHtml(html) { 2417 var temporalDivElement = document.createElement("div"); // 2418 temporalDivElement.innerHTML = html; // 2419 return temporalDivElement.textContent || temporalDivElement.innerText || ""; 2420} 2421 2422 2423 2424 2425 2426 2427var isEmailPopupInited = false ; 2428 2429function setCookie(name, value, daysToLive) { 2430 // Encode the value to handle special characters or spaces safely 2431 let cookieString = encodeURIComponent(name) + "=" + encodeURIComponent(value); 2432 2433 if (daysToLive) { 2434 // Calculate seconds from days 2435 const maxAge = daysToLive * 24 * 60 * 60; 2436 cookieString += "; max-age=" + maxAge; 2437 } 2438 2439 // Add path and security flags 2440 cookieString += "; path=/; secure; samesite=lax"; 2441 2442 // Assign to the browser 2443 document.cookie = cookieString; 2444} 2445 2446function showEmailPopup(){ 2447 2448 2449 let currentCookie= getCookie('pm_email_popup_status'); 2450 // console.log('pm_email_popup_status: ' + currentCookie); 2451 //https://www.pastemagazine.com/music/goat-girl/goat-girl-announce-self-titled-debut-album-share-n 2452 let curl = window.location.pathname; 2453 2454 //console.log(curl) 2455 //curl == 'https://www.pastemagazine.com/music/goat-girl/goat-girl-announce-self-titled-debut-album-share-n' 2456 ///do-you-love-your-baby-enough-to-spend-1500-on-a-stroll-5789997 2457 if (curl!="/" && ( currentCookie == undefined || currentCookie == null || currentCookie =='')){ 2458 2459 // if (curl == '/do-you-love-your-baby-enough-to-spend-1500-on-a-stroll-5789997'){ 2460 // || currentCookie == undefined || currentCookie == null || currentCookie ==''
2461 setCookie('pm_email_popup_status', "paused", 7); 2462 2463 document.querySelector(".email-popup").showModal(); 2464 document.querySelector(".email-popup #email").focus(); 2465 if (!isEmailPopupInited ){ 2466 console.log('populate email form' ); 2467 document.querySelector(".email-popup #submitemail").addEventListener('click', () => { 2468 submitEmailPopup(); 2469 }); 2470 2471 document.querySelector(".email-popup #nothanks").addEventListener('click', () => { 2472 hideEmailPopup(); 2473 }); 2474 document.querySelector(".email-popup #continue").addEventListener('click', () => { 2475 hideEmailPopup(); 2476 }); 2477 document.querySelector(".email-popup #close").addEventListener('click', () => { 2478 hideEmailPopup(); 2479 }); 2480 } 2481 } else {console.log('no need to show email popup');} 2482 isEmailPopupInited=true; 2483} 2484 2485function submitEmailPopup() { 2486 console.log("submitEmailPopup()"); 2487 if (validateEmail(document.querySelector(".email-popup #email").value)) { 2488 sendEmailSignUp(document.querySelector(".email-popup #email").value); 2489 // hideEmailPopup(); 2490 } else { 2491 document.querySelector(".email-popup .msg").innerHTML='Please enter a valid email.'; 2492 2493 } 2494 2495} 2496function hideEmailPopup(){ 2497 console.log("hideEmailPopup"); 2498 document.querySelector(".email-popup").close(); 2499 document.querySelector(".email-popup .msg").innerHTML=''; 2500 document.querySelector("#email-popup-form").style.display="block"; 2501 document.querySelector("#continue").style.display="none"; 2502 2503} 2504async function sendEmailSignUp($email) { 2505 const url = 'https://www.jezebel.com/wp-content/themes/pastemagazine/mycustomajax.php'; 2506 2507 2508 2509 2510 const requestData = { 2511 action: 'submit_email', 2512 email: $email 2513 }; 2514 2515 console.log(new URLSearchParams(requestData).toString() ); 2516 try { 2517 const response = await fetch(url, { 2518 method: 'POST', 2519 headers: { 2520 'Content-Type': 'application/x-www-form-urlencoded' 2521 }, 2522 body: new URLSearchParams(requestData).toString() 2523 }); 2524 2525 if (!response.ok) { 2526 throw new Error('HTTP error! Status: ' + response.status ); 2527 } 2528 2529 const responseData = await response.json(); // Parse JSON response from server 2530 console.log('Success:', responseData); 2531 2532 document.querySelector(".email-popup .msg").innerHTML='Thank you!'; 2533 document.querySelector("#email-popup-form").style.display="none"; 2534 document.querySelector("#continue").style.display="block"; 2535 } catch (error) { 2536 console.error('Error:', error); 2537 } 2538} 2539 2540function validateEmail(email) { 2541 const regex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; 2542 return regex.test(email); 2543} 2544
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.