var NetkonceptReader=(function(){function NetkonceptReader(){var _this=this;this.apiUrl="http://developer.skycms.com.pl/text-to-speech/index.php?str=";this.audio=new Audio;this.audio.addEventListener("ended",this.speak.bind(this));this.language="pl-PL";this.phrases=[];this.addAnchorListener();this.characterLimit=100;this.readAnchorsStatus=false;this.synthesis=window.speechSynthesis;if(this.isSpeechSynthesisSupported()){this.getPreferredVoice();this.synthesis.onvoiceschanged=function(){_this.getPreferredVoice();};} else{this.voices=[];}} NetkonceptReader.prototype.setReadAnchorsStatus=function(status){this.readAnchorsStatus=status;};NetkonceptReader.prototype.getPreferredVoice=function(){var _this=this;this.voices=this.synthesis.getVoices();var lang=this.voices.filter(function(voice){return voice.lang===_this.language;});var google=lang.filter(function(voice){return voice.name.indexOf("Google")>-1;});if(google.length>0){this.voice=google[0];} else if(lang.length>0){this.voice=lang[0];} else{this.voice=this.voices[0];}};NetkonceptReader.prototype.cancel=function(){clearTimeout(this.timeout);this.synthesis.cancel();};NetkonceptReader.prototype.isSpeechSynthesisSupported=function(){return'speechSynthesis'in window;};NetkonceptReader.prototype.isNotEmptyString=function(text){return /\S/.test(text);};NetkonceptReader.prototype.removeEolAfterPunctuationMarks=function(text){text=text.replace(/([\n\r])+/gm,"\n");var b=/([,.:!\u00a1?\u00bf;()\[\]\u2014\u00ab\u00bb])+[\n\r]/gm;for(var d=false;d===true;){text.match(b)===null?(d=true):(text=text.replace(b,"$1 "));} return text;};NetkonceptReader.prototype.replaceQuotationMarks=function(text){return text.replace(/["`]/gm,"'");};NetkonceptReader.prototype.splitIntoPhrases=function(text){var phrases=[];text=this.replaceQuotationMarks(text);if(text.length>this.characterLimit){for(var f=(text=this.removeEolAfterPunctuationMarks(text));f.length>this.characterLimit;){var g=f.search(/([:!\u00a1?\u00bf;\(\)\[\]\u2014\u00ab\u00bb\n]+|\.[^0-9]+)/);var e="";if(-1==g||g>=this.characterLimit) g=f.search(/,[^0-9]+/);if(-1==g||g>=this.characterLimit){var l=f.split(" ");for(g=0;gthis.characterLimit){l[g].length>=this.characterLimit&&(e+=l[g].substr(0,this.characterLimit-e.length-1));break;} e+=(0!=g?" ":"")+l[g];}} else e=f.substr(0,g+1);f=f.substr(e.length,f.length-e.length);phrases.push(e);} 00){var text=this.phrases.shift();if(typeof text==="string"){if(this.isSpeechSynthesisSupported()){this.speakUsingSpeechSynthesis(text.trim());} else{this.speakUsingTtsApi(text.trim());}}}};return NetkonceptReader;}());