https://wizaz.pl/assets/bundles/publishercomment/js/controllers/comments_async_controller-aY2iz2k.js
1import{Controller}from"@hotwired/stimulus";import{createLogger}from"publishercore/logger";let fosCommentScriptPromise,newCommentListenerRegistered=!1;const log=createLogger("commentsAsync");export default class extends Controller{static values={apiBaseUrl:String,scriptSrc:String,threadId:String,view:String};connect(){if(this.handleVisibility=this.handleVisibility.bind(this),this.loaded=!1,this.loading=!1,this.configureFosComment(),this.registerNewCommentListener(),"IntersectionObserver"in window){this.observer=new IntersectionObserver(e=>{for(const t of e){if(!t.isIntersecting)continue;this.loadComments();break}}),this.observer.observe(this.element);return}window.addEventListener("scroll",this.handleVisibility,{passive:!0}),this.handleVisibility()}disconnect(){this.disconnectObserver(),window.removeEventListener("scroll",this.handleVisibility)}handleVisibility(){if(!this.isVisible())return;this.loadComments()}configureFosComment(){window.FosComment=window.FosComment||{},window.FosComment.config={threadId:this.threadIdValue,view:this.viewValue||"tree",apiBaseUrl:this.apiBaseUrlValue}}loadComments(){if(this.loaded||this.loading)return;this.loading=!0,loadFosCommentScript(this.scriptSrcValue).then(()=>{this.loaded=!0,this.loading=!1,this.disconnectObserver(),window.removeEventListener("scroll",this.handleVisibility)}).catch(e=>{this.loading=!1,this.showLoadError(),log.error("Unable to load FOSComment script",e)})}isVisible(){const e=this.element.getBoundingClientRect();return e.top<window.innerHeight&&e.bottom>=0}disconnectObserver(){if(!this.observer)return;this.observer.disconnect(),this.observer=null}registerNewCommentListener(){if(newCommentListenerRegistered)return;document.addEventListener("fos_comment_new_comment",()=>{const t=document.getElementById("js-publisher-comment-counter");if(!t)return;const n=t.textContent||"",s=parseInt(n.split(" ")[0],10),e=s+1;if(e===1){t.textContent=`${e} komentarz`;return}if(e>1&&e<5){t.textContent=`${e} komentarze`;return}t.textContent=`${e} komentarzy`}),newCommentListenerRegistered=!0}showLoadError(){this.element.textContent="Komentarze sÄ
chwilowo niedostÄpne."}}function loadFosCommentScript(e){return fosCommentScriptPromise||(fosCommentScriptPromise=new Promise((t,n)=>{const o=document.querySelector(`script[src="${e}"]`);if(o){t();return}const s=document.createElement("script");s.src=e,s.async=!0,s.onload=()=>t(),s.onerror=()=>{fosCommentScriptPromise=null,s.remove(),n(new Error(`Unable to load comments script: ${e}`))},(document.head||document.body).appendChild(s)}),fosCommentScriptPromise)}
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.