PageSourceSearch

https://pgw.pl/js/prod/transpiled/text-to-speech.js?ts=1790683904

js pgw.pl collected 2026-10-02 18:41:12 UTC 2,387 bytes, 1 lines download raw bytes

1js_included.tts=!0;class TextToSpeech{constructor(){this.trigger=document.querySelector(".js__textToSpeech--trigger"),this.target=document.querySelector(".js__textToSpeech--target"),this.trigger&&this.target&&(this.speechIsSupported="speechSynthesis"in window&&"SpeechSynthesisUtterance"in window,this.speechIsSupported?(this.speakMap=this.createDOMMap(this.target),this.speakMap&&(this.setState("stop"),this.speechSynthesisUtterance=null,this.speakMapIndex=0,this.addEvent())):this.addEventIsUnsupported())}addEventIsUnsupported(){this.trigger.addEventListener("click",e=>{e.preventDefault(),this.speechIsUnsupportedAlert()})}addEvent(){this.trigger.addEventListener("click",e=>this.handleClick(e))}handleClick(e){if("speak"===e.currentTarget.dataset.state)this.setState("stop"),this.stop();else this.speakMap=this.createDOMMap(this.target),this.setState("speak"),this.speak()}handleBoundaryEvent(e,t){const s=window.getSelection();if(s.removeAllRanges(),"word"===e.name){const a=document.createRange();a.setStart(t.node.childNodes[t.position],e.charIndex),a.setEnd(t.node.childNodes[t.position],e.charIndex+e.charLength),s.addRange(a)}}setState(e){this.state=e,this.trigger.dataset.state=e,this.target.dataset.state=e}speak(){if("speak"===this.state&&this.speakMapIndex<this.speakMap.length){const e=this.speakMap[this.speakMapIndex];this.speechSynthesisUtterance=new SpeechSynthesisUtterance(e.text),this.speechSynthesisUtterance.lang=document.documentElement.lang||"pl",this.speechSynthesisUtterance.addEventListener("boundary",t=>this.handleBoundaryEvent(t,e)),this.speechSynthesisUtterance.addEventListener("end",e=>{this.speakMapIndex++,this.speak()}),window.speechSynthesis.speak(this.speechSynthesisUtterance)}else this.setState("stop"),this.stop()}stop(){this.speechSynthesisUtterance&&window.speechSynthesis.cancel(),this.speechSynthesisUtterance=null,this.speakMapIndex=0,window.getSelection().removeAllRanges()}speechIsUnsupportedAlert(){alert("Twoja przeglądarka nie wspiera czytania tekstu.")}createDOMMap(e,t=[]){if(e.nodeType===Node.TEXT_NODE){""!==e.textContent.trim()&&t.push({text:e.textContent,node:e.parentNode,position:Array.from(e.parentNode.childNodes).indexOf(e)})}else if(e.tagName&&"svg"!==e.tagName.toLowerCase())for(const s of e.childNodes)s.nodeType===Node.ELEMENT_NODE&&s.classList.contains("js__textToSpeech--trigger")||this.createDOMMap(s,t);return t}}

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.