(function () { var scriptName = "embed.js"; //name of this script, used to get reference to own tag var jQuery; //noconflict reference to jquery var jqueryPath = "https://ajax.googleapis.com/ajax/libs/jquery/1.12.1/jquery.min.js"; var jqueryVersion = "1.12.1"; var scriptTag; //reference to the html script tag /******** Get reference to self (scriptTag) *********/ var allScripts = document.getElementsByTagName('script'); var targetScripts = []; for (var i in allScripts) { var name = allScripts[i].src if(name && name.indexOf(scriptName) > 0) targetScripts.push(allScripts[i]); } scriptTag = targetScripts[targetScripts.length - 1]; audiomeIsLoaging = false; /******** helper function to load external scripts *********/ function loadScript(src, onLoad) { var script_tag = document.createElement('script'); script_tag.setAttribute("type", "text/javascript"); script_tag.setAttribute("src", src); if (script_tag.readyState) { script_tag.onreadystatechange = function () { if (this.readyState == 'complete' || this.readyState == 'loaded') { onLoad(); } }; } else { script_tag.onload = onLoad; } (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } /******** helper function to load external css *********/ function loadCss(href) { var link_tag = document.createElement('link'); link_tag.setAttribute("type", "text/css"); link_tag.setAttribute("rel", "stylesheet"); link_tag.setAttribute("href", href); (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(link_tag); } /******** load jquery into 'jQuery' variable then call main ********/ if (window.jQuery === undefined || window.jQuery.fn.jquery !== jqueryVersion) { loadScript(jqueryPath, initjQuery); } else { initjQuery(); } function initjQuery() { jQuery = window.jQuery.noConflict(true); main(); } function audiomeConsoleLog(strlog) { if (audiomeLog == true) { //console.log(strlog); } } function readMeAudioEnd(){ // console.log("--> readMeAudioEnd INIT <--"); jQuery("#readmeerror").append("
ReadMeAudioEnd ") audiomePlayCount = audiomePlayCount + 1; if (audiomePlayCount <= audiomeMp3List.length - 1) { //console.log('Next file'); audiomeAudioSeek = 0 audiomeSeekPercent = 0 playAudioTTS(audiomeMp3List[audiomePlayCount]) } else { rewindAudioTTS(); audiomeConsoleLog('Finished! Playlist'); } } function playAudioTTS(mp3) { // console.log("--> playAudioTTS INIT <--"); jQuery("#readmeerror").append("
playAudioTTS ") FireAnalytics("PlayAudio"); FireAnalyticsClienteReadme("PlayAudio"); jQuery("#audiomebtn-loader").hide(); if (audiomeSeekPercent > 0) { audioMeProgress = audiomeSeekPercent * audiomeTotalTime; audiomePlayCount = 0; audiomeAudioSeek = audioMeProgress; var audiomeAcumulador = 0 for ( i = 0 ; i < audiomeMp3List.length ; i++ ) { audiomeAcumulador = audiomeAcumulador + audiomeMp3List[i].TotalSeconds if (audiomeAcumulador < audioMeProgress) { audiomePlayCount = i + 1; audiomeAudioSeek = audioMeProgress - audiomeAcumulador } } } // console.log("--> PLAY <--"); // console.log("--> src --> " + audiomeMp3List[audiomePlayCount]); // console.log("--> PlayCount --> " + audiomePlayCount); // console.log("--> Seek --> " + audiomeAudioSeek); readmeTTSAudio.src = audiomeMp3List[audiomePlayCount].url + "#t=" + audiomeAudioSeek //readmeTTSAudio.src = "http://www.readme.com/file.mp3"; // console.log(" --> SRCLOAD ok"); var playPromise = readmeTTSAudio.play(); if (playPromise !== undefined) { playPromise.then(_ => { readmeTTSAudio.playbackRate = readmeAudioSpeed // Automatic playback started! // Show playing UI. // console.log("automatic play started"); }) .catch(error => { // Auto-play was prevented // Show paused UI. audiomeErrorCount = audiomeErrorCount + 1; // console.log("UPS, automatic play ERROR"); FireAnalytics("playPromise Error"); if (audiomeErrorCount < 6) { // console.log("UPS, automatic play ERROR - TRY AGAIN " + audiomeErrorCount); FireAnalytics("playPromise Error retry - " + audiomeErrorCount); playAudioTTS(audiomeMp3List[audiomePlayCount]); } else { // console.log("UPS, automatic play ERROR - DIE"); FireAnalytics("playPromise Error DIE - "); audiomeLoadAudio = false audiomeIsLoaging = false audiomeErrorCount = 0; rewindAudioTTS(); } }); } FireAnalyticsClienteReadme("PlayAudio"); } function playSponsoredAudioTTS(){ readmeTTSAudioSponsored.src = audiomeSponsoredAudio.SponsorFileName // console.log(" --> SPONSOR SRCLOAD ok"); var playPromise = readmeTTSAudioSponsored.play(); if (playPromise !== undefined) { playPromise.then(_ => { // Automatic playback started! // Show playing UI. // console.log("automatic SPONSOR play started"); }) .catch(error => { // Auto-play was prevented // Show paused UI. audiomeSponsorErrorCount = audiomeSponsorErrorCount + 1; // console.log("UPS, automatic SPONSOR play ERROR"); FireAnalytics("playPromise SPONSOR Error"); if (audiomeSponsorErrorCount < 3) { // console.log("UPS, automatic SPONSOR play ERROR - TRY AGAIN " + audiomeSponsorErrorCount); FireAnalytics("playPromise SPONSOR Error retry - " + audiomeSponsorErrorCount); playSponsoredAudioTTS(); } else { // console.log("UPS, automatic SPONSOR play ERROR - DIE"); FireAnalytics("playPromise SPONSOR Error DIE - "); playAudioTTS(audiomeMp3List[audiomePlayCount]); } }); } } function playSponsoredSpotTTS(){ //readmeTTSSpotSponsored.src = "" + "http://localhost:27080/img/" + audiomeSponsoredSpot.banerKey readmeTTSSpotSponsored.src = audiomeSponsoredSpot.SponsorFileName // console.log(" --> SPONSOR SRCLOAD ok"); var playPromise = readmeTTSSpotSponsored.play(); if (playPromise !== undefined) { playPromise.then(_ => { // Automatic playback started! // Show playing UI. // console.log("automatic SPONSOR SPOT play started"); }) .catch(error => { // Auto-play was prevented // Show paused UI. audiomeSpotErrorCount = audiomeSpotErrorCount + 1; // console.log("UPS, automatic SPONSOR SPOT play ERROR"); FireAnalytics("playPromise SPONSOR SPOT Error"); if (audiomeSpotErrorCount < 3) { // console.log("UPS, automatic SPONSOR play ERROR - TRY AGAIN " + audiomeSpotErrorCount); FireAnalytics("playPromise SPONSOR Error retry - " + audiomeSpotErrorCount); playSponsoredSpotTTS(); } else { // console.log("UPS, automatic SPONSOR play ERROR - DIE"); FireAnalytics("playPromise SPONSOR Error DIE - "); playAudioTTS(audiomeMp3List[audiomePlayCount]); } }); } } function pauseAudioTTS() { console.log("--> pauseAudioTTS INIT <--"); jQuery("#audiomeProgressBarAlpha").stop(); readmeTTSAudio.pause(); audiomeStatus = "pause" jQuery("#audiomebtn-loader").hide(); jQuery("#audiomebtn-pause").hide(); jQuery("#audiomebtn-play").show(); //audiomeAudioSeek = audiomeHowlerList[audiomePlayCount].seek(); audiomeAudioSeek = readmeTTSAudio.currentTime; // console.log('audiomeAudioSeek - ' + audiomeAudioSeek) // console.log('audiomePlayCount - ' + audiomePlayCount) jQuery("#audiomebtn-loader").hide(); setTimeout(function(){ audiomeIsLoaging = false; }, 500); } function rewindAudioTTS() { // console.log("--> rewindAudioTTS INIT <--"); FireAnalytics("EndAudio"); jQuery("#audiomeProgressBarAlpha").stop(); audiomePlayCount = 0 audiomeAudioSeek = 0 readmeTTSAudio.pause; audiomeStatus = "pause"; jQuery("#audiomebtn-loader").hide(); jQuery("#audiomebtn-pause").hide(); jQuery("#audiomebtn-play").show(); } function audioMeCalculatetotalTime() { // console.log("--> audioMeCalculatetotalTime INIT <--"); var audioCount = 0 contaAudios = audiomeMp3List.length; contaLoaded = 0; audiomeMp3List.forEach(function(element) { var audiotimmer = new Audio(); audiotimmer.src = element.url; audiotimmer.addEventListener('loadedmetadata', (event) => { var source = audiotimmer.src; // console.log("source -> " + source) var TotalSeconds = parseInt(audiotimmer.duration); audiomeTotalTime = audiomeTotalTime + TotalSeconds // console.log( "Seconds - " + TotalSeconds); // console.log( "audiomeTotalTime - " + audiomeTotalTime); audioCount = audioCount + 1 audiomeMp3List.forEach(function(item) { if (item.url == audiotimmer.src) { item.TotalSeconds = audiotimmer.duration; } }); if (audioCount >= audiomeMp3List.length){ var minutes = parseInt(audiomeTotalTime / 60, 10); var seconds = parseInt(audiomeTotalTime % 60); if (minutes < 10 ) {minutes = "0" + minutes} if (seconds < 10 ) {seconds = "0" + seconds} audiomeTotalTimeDisplay = minutes + ":" + seconds ; // console.log( "TotalTime display - " + audiomeTotalTimeDisplay); audiomeMp3List.forEach(function(x) { // console.log("audiomeMp3List.url " + x.url) // console.log("audiomeMp3List.TotalSeconds " + x.TotalSeconds) }); } contaLoaded = contaLoaded + 1; if(contaLoaded >= contaAudios && contaAudios > 0) // Significa que termonou o load dos audios { if (audiomeSponsoredBannerFlag == "ON") { // mostra o banner patrocinado console.log("Show Sponsored Banner") var img = new Image(); img.src = audiomeSponsoredBanner.SponsorFileName; img.id = "audiomeSponsoredImage" var link = document.createElement("a"); link.id = "audiomeSponsoredLink"; // Create a

element link.href = audiomeSponsoredBanner.bannerClick link.target = "_blank" document.getElementById('audiome-container').appendChild(link); document.getElementById('audiomeSponsoredLink').appendChild(img); jQuery("#audiomeSponsoredLink").fadeIn(); document.getElementById("audiomeSponsoredLink").addEventListener("click", audiomeSponsorClick); } if ( audiomeSponsoredAudioFlag == "ON") { playSponsoredAudioTTS(); } else if ( audiomeSponsoredSpotFlag == "ON") { playSponsoredSpotTTS() } else { playAudioTTS(audiomeMp3List[0]); } // audiomeHowlerList[0].play(); } },0); }); } function AddPauseToContent(content, classname, tagname){ if (strip(tagname) != "") { var x = document.getElementsByTagName(tagname); ////console.log("AddPauseToContent -> TAG " + tagname) } if (strip(classname) != "") { var x = document.getElementsByClassName(classname); ////console.log("AddPauseToContent -> CLASS " + classname) } var i; for (i = 0; i < x.length; i++) { text = x[i].textContent.trim() //console.log ("AddPauseToContent -> " + classname + tagname + " -> " + text) if (strip(text) != ""){ var replace = strip(text); var re = new RegExp(replace,"g"); content = content.replace( re , text + '. '); //console.log ("content -> " + classname + tagname + " -> " + content) } } return content } function getHostName(fullurl){ var url = fullurl; var hostname = (new URL(url)).hostname; // console.log("hostname -> " + hostname) return hostname; } function getTextElementByClass(classname){ var textbyclass = "" var x = document.getElementsByClassName(classname); var i; for (i = 0; i < x.length; i++) { textbyclass = x[i].textContent.trim() + " " } return textbyclass; } function getTextElementByTag(tagname) { var element = document.querySelector(tagname); if (element) { return element.innerText; } else { return ''; } } function HideElementByClass(documentClone, classname){ var x = documentClone.getElementsByClassName(classname); var i; for (i = 0; i < x.length; i++) { x[i].style.display = "none"; //console.log("HideElementByClass " + classname + " " + x[i].innerText) } return documentClone; } function HideElementByTagName(documentClone, tagname){ var x = documentClone.getElementsByTagName(tagname); var i; for (i = 0; i < x.length; i++) { //console.log("hide tagname" + tagname) x[i].style.display = "none"; } return documentClone; } function HideElementByID(documentClone, idname){ // console.log(" HideElementByID -> " + idname) var x = documentClone.getElementById(idname); if (x != null ) { x.style.display = "none"; //console.log("HideElementByID " + idname + " " + x.innerText) } return documentClone; } const format = num => { const n = String(num), p = n.indexOf('.') return n.replace( /\d(?=(?:\d{3})+(?:\.|$))/g, (m, i) => p < 0 || i < p ? `${m},` : m ) } function ReadabilityAjust(textIn){ textOut = textIn textOut = textOut.replace(/\n{2,}/g, '. '); textOut = textOut.replace(/\n/g, '. '); textOut = textOut.replace(/\n|\s{2,}/g, ' '); textOut = textOut.replace(/\. \./g, '. '); textOut = textOut.replace(/\&/g, ' E '); textOut = textOut.trim() var str = textOut var regex = /(\.)([ABCDEFGHIJKLMNOPQRSTUVXYZ])/g; textOut = str.replace(regex, "$1 $2"); var str = textOut var regex = /(\!)([ABCDEFGHIJKLMNOPQRSTUVXYZ])/g; textOut = str.replace(regex, "$1 $2"); return textOut; } function strip(html) { var tmp = document.createElement("DIV"); tmp.innerHTML = html; return tmp.textContent||tmp.innerText; } function clearString(mystring) { return mystring.replace(/&/g, "&").replace(/>/g, ">").replace(/ LoadReadability INIT <--"); var documentClone = document.cloneNode(true); // bloqueios padrao documentClone = HideElementByID(documentClone, "audiome-container"); documentClone = HideElementByClass(documentClone, "twitter-tweet"); documentClone = HideElementByClass(documentClone, "instagram-media"); documentClone = HideElementByID(documentClone, "fb-root"); documentClone = HideElementByClass(documentClone, "OUTBRAIN"); documentClone = HideElementByID(documentClone, "taboola-below-article-thumbnails"); documentClone = HideElementByTagName(documentClone, "figure"); documentClone = HideElementByTagName(documentClone, "header"); documentClone = HideElementByTagName(documentClone, "figcaption"); documentClone = HideElementByTagName(documentClone, "button"); documentClone = HideElementByTagName(documentClone, "footer"); // bloqueios do cliente documentClone = HideElementByClass(documentClone, "accept-cookies-container"); documentClone = HideElementByClass(documentClone, "ad-wrapper"); documentClone = HideElementByClass(documentClone, "newsletter-form"); documentClone = HideElementByClass(documentClone, "hidden-print"); article = new Readability(documentClone).parse(); articlecontent = article.content.replace(/
/g, ".
"); articlecontent = articlecontent.replace(/<\/li>/g, ". "); articlecontent = articlecontent.replace(/<\/h2>/g, ". "); articlecontent = articlecontent.replace(/<\/h3>/g, ". "); articlecontent = articlecontent.replace(/<\/p>/g, ".

"); audioMeContent = strip(articlecontent) audioMeTitle = article.title.trim() + ". " audioMeExcerpt = article.excerpt.trim() + ". " console.log('title -> ' + audioMeTitle) console.log('excerpt -> ' + audioMeExcerpt) ; console.log('audioMeContent -> ' + strip(article.content)) audiomeFullcontent = ReadabilityAjust(audioMeTitle + audioMeExcerpt + audioMeContent); console.log("audiomeFullcontent ->" + audiomeFullcontent) console.log('audiomeFullcontent Size -> ' + audiomeFullcontent.length) } function audioMeCleartitle (audioMeTitle) { //ClearTitle.forEach(function(current, i) { //audiomeMp3List.push(data.urls[i]) // audioMeTitle = audioMeTitle.replace(ClearTitle[i], "") //console.log('audiome title replace ' + data.urls[i]) //}); audiomeConsoleLog("clearTitle " + audioMeTitle) return audioMeTitle } function audioMeFillProgressBar(){ audiomeConsoleLog('audioMeFillProgressBar') var i; var min=15; var max=30; for (i = 1; i < 200 ; i++) { var random =Math.floor(Math.random() * (+max - +min)) + +min; jQuery('
', { id: 'audiomeProgressBarItem-' + i, "class": 'audiomeProgressBarItem', style: 'height:'+ random + 'px;' }).appendTo('#audiomeProgressBar'); //jQuery( "#audiomeProgressBar" ).append(div); } } function audioMeCalcETA() { // console.log("--> audioMeCalcETA INIT <--"); var audiomePlayed = 0 var audiomeETA = 0 for (i = 0 ; i < audiomePlayCount ; i ++ ) { audiomePlayed = audiomePlayed + audiomeMp3List[i].TotalSeconds; console.log ("Duration loop -> " + audiomeMp3List[i].TotalSeconds) } audiomeETA = audiomeTotalTime - audiomePlayed - audiomeAudioSeek // console.log("audiomePlayed -> " + audiomePlayed); // console.log("audiomeAudioSeek -> " + audiomeAudioSeek); // console.log("audiomePlayCount -> " + audiomePlayCount); // console.log("audiomeETA -> " + audiomeETA); return audiomeETA; } function audioMeProgressBarAnimate() { // console.log("--> audioMeProgressBarAnimate INIT <--"); jQuery("#readmeerror").append("
ProgressBar Animate ") jQuery("#audiomeProgressBarAlpha").stop(); var audiomeETA = audioMeCalcETA() var totalwith = jQuery("#audiomeProgressBar").width() var newWidth = totalwith * (audiomeETA / audiomeTotalTime) jQuery("#audiomeProgressBarAlpha").width(newWidth); var ReadmeAnimaeEta = audiomeETA; console.log("readmeAudioSpeed " + readmeAudioSpeed) jQuery('#audiomeProgressBarAlpha' ).animate({ width: 0}, parseInt(ReadmeAnimaeEta * 1000 * (1/readmeAudioSpeed) ), "linear", function() { audiomeConsoleLog("done animate"); }); } function audioMeLoadTTS () { // console.log("--> audioMeLoadTTS INIT <--"); audiomeConsoleLog ('audioMeLoadTTS') FireAnalytics("LoadAudio"); var url = 'https://u6bdxq3r4k.execute-api.us-east-1.amazonaws.com/default/PollyFunction'; var contaAudios = -1; var contaLoaded = -1; formData = JSON.stringify({ //'filename': 'filenaleaudiome.mp3', 'voice' : audiomeVoiceName, 'text': audiomeFullcontent, 'clientid' : audiomeClientId , //'path' : window.location.pathname , 'url' : window.location.pathname , //'url' : audioMeTitle , 'bgprocess' : 'Y', 'domain' : getHostName(document.location), 'brief': 'N', // Y OR N 'audiopromo': readmeAudioPromo }) jQuery.post( url, formData) .done(function( data ) { audiomeConsoleLog( "status " + data.status ); audiomeConsoleLog( "deltaTime " + data.deltaTime ); audiomeConsoleLog( "textSize " + data.textSize ); audiomeLoadAudio = true if (data.status == "NOK"){ FireAnalytics("ERRO - " + window.location.pathname); } if (data.status == "WAIT"){ FireAnalytics("WAIT - " + window.location.pathname); console.log("WAIT - will try again") readmeAudioPromo = "N" var myTimeoutWait = setTimeout(audioMeLoadTTS, 10000); } if (data.status == "OK"){ data.urls.forEach(function(current, i) { var dictaudio = {}; dictaudio.url = data.urls[i] audiomeMp3List.push(dictaudio) }); audiomeConsoleLog ('audiomeMp3List length ' + audiomeMp3List.length) FireAnalytics ("dbAudio-" + data.actionDB ) audioMeCalculatetotalTime(); } }) .fail(function() { console.log("timeout - will try again") readmeAudioPromo = "N" var myTimeoutFail = setTimeout(audioMeLoadTTS, 10000); }) } function audioMePlayClick() { // console.log("--> audioMePlayClick INIT <--"); if (audiomeLoadAudio == false) { readmeTTSAudio.play(); readmeTTSAudioSponsored.play(); readmeTTSSpotSponsored.play(); } if (audiomeIsLoaging == false) { audiomeConsoleLog('button pressed'); audiomeIsLoaging = true //jQuery("#audiomebtn-loader").html('.....'); jQuery("#audiomebtn-pause").hide(); jQuery("#audiomebtn-play").hide(); jQuery("#audiomebtn-loader").hide(); jQuery("#audiomebtn-loader").show(); if (audiomeLoadAudio == false) { audioMeLoadTTS(); } else { if (audiomeStatus == "stop" || audiomeStatus == "pause") { //audiomeStatus == "play" audiomeSeekPercent = 0 playAudioTTS(audiomeMp3List[audiomePlayCount]) } else { audiomeStatus == "pause" pauseAudioTTS(); } } } else{ // console.log("else!") } } function audioMeTouchBarClick (event){ console.log("--> audioMeTouchBarClick INIT <--"); if (audiomeIsLoaging == false) { audiomeConsoleLog('click'); audiomeIsLoaging = true; if (audiomeStatus == "play") { pauseAudioTTS() } jQuery("#audiomeProgressBarAlpha").stop(); var offset = jQuery("#audiomeProgressBar").offset(); var relativeX = (event.pageX - offset.left); audiomeConsoleLog('relativeX - ' + relativeX); var totalwith = jQuery("#audiomeProgressBar").width(); var perceltualbar = 1 - (relativeX / totalwith) audiomeConsoleLog('perceltual - ' + perceltualbar); var newWidth = perceltualbar * totalwith audiomeConsoleLog('newWidth - ' + newWidth); jQuery("#audiomeProgressBarAlpha").width(newWidth); audiomePercentual = relativeX / totalwith audiomeConsoleLog('audiomePercentual - ' + audiomePercentual); audiomeSeekPercent = audiomePercentual jQuery("#audiomebtn-pause").hide(); jQuery("#audiomebtn-play").hide(); jQuery("#audiomebtn-loader").show(); if (audiomeLoadAudio == false) { audioMeLoadTTS(); } else { playAudioTTS(audiomeMp3List[audiomePlayCount]); } } } function FireAnalytics (eventAction) { try { loadScript( "https://www.googletagmanager.com/gtag/js?id=G-VV4TQTEC54" , function() { window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-VV4TQTEC54'); gtag('event', eventAction, {'event_category' : audiomeClientId}); console.log("ga4 ok"); }); } catch(err) { console.log("catch ga4 FireAnalytics"); } } function FireAnalyticsClienteReadme (eventAction) { var currentLocation = window.location.protocol + '//' + window.location.hostname + window.location.pathname //console.log("FireAnalyticsClienteReadme - " + eventAction); var sm_my_image = new Image(); var sm_cid = Math.floor(Math.random() * 0x7FFFFFFF) + "." + Math.floor(Date.now() / 1000); // sm_my_image.src = 'https://www.google-analytics.com/collect?v=1&tid=UA-53443223-1&cid=' + sm_cid + '&t=event&ec=ReadMe&ea=' + eventAction + "&dl=" + currentLocation; try { //ga('send', 'event', 'Readme', eventAction); __gaTracker('send', 'event', 'Readme', eventAction); // console.log("event ga ok"); } catch(err) { // console.log("erro ga"); } try { gtag('event', eventAction, {'event_category' : 'ReadMe'}); // console.log("event gtag ok"); } catch(err) { // console.log("erro gtag"); } } function audiomeSponsorClick(){ FireAnalyticsClienteReadme("BannerClick"); FireAnalytics("BannerClick"); } function getP(name){ if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) return decodeURIComponent(name[1]); } function audiomelinkClick(){ console.log("audiomelinkClick") window.open('https://www.readme.ai/pt') } function readmeisPlaying() { //console.log("currentTime -> " + readmeTTSAudio.currentTime) //console.log("paused -> " + readmeTTSAudio.paused) //console.log("ended -> " + readmeTTSAudio.ended) //console.log("readyState -> " + readmeTTSAudio.readyState) return readmeTTSAudio.currentTime > 0 && !readmeTTSAudio.paused && !readmeTTSAudio.ended && readmeTTSAudio.readyState > 2; } function readpespeedClick(){ console.log("readpespeedClick click") var speed = document.getElementById("readpespeed").textContent console.log("speed " + speed) if (speed == '1.0x') { document.getElementById("readpespeed").textContent = "1.5x" readmeAudioSpeed = 1.5 readmeTTSAudio.playbackRate = readmeAudioSpeed } if (speed == '1.5x') { document.getElementById("readpespeed").textContent = "2.0x" readmeAudioSpeed = 2.0 readmeTTSAudio.playbackRate = readmeAudioSpeed } if (speed == '2.0x') { document.getElementById("readpespeed").textContent = "0.8x" readmeAudioSpeed = 0.8 readmeTTSAudio.playbackRate = readmeAudioSpeed } if (speed == '0.8x') { document.getElementById("readpespeed").textContent = "1.0x" readmeAudioSpeed = 1.0 readmeTTSAudio.playbackRate = readmeAudioSpeed } var readmePlaying = readmeisPlaying() if (readmePlaying == true) { console.log("readmePlaying TRUE") pauseAudioTTS() //audioMeProgressBarAnimate() playAudioTTS(audiomeMp3List[audiomePlayCount]); } else { console.log("readmePlaying FALSE") } } function audioMeOpenLead(){ // console.log("Local Storage -> " + localStorage.getItem(audiomeClientId)) // console.log("audiomeLeadConfig -> " + audiomeLeadConfig) if ((audiomeLeadConfig == "1" || audiomeLeadConfig == "2") && (localStorage.getItem(audiomeClientId) == "false")) { jQuery('#audiome-player' ).animate({height: 120}, 1000, "swing", function() { audiomeConsoleLog("done animate"); FireAnalytics("OpenLead") }); } } function audioMeCloseLead(){ jQuery('#audiome-lead ' ).fadeOut() jQuery('#audiome-player' ).animate({height: 50}, 1000, "swing", function() { audiomeConsoleLog("done animate"); FireAnalytics("CloseLead") //FireAnalyticsSemParar("NovoLead") }); } function audioMeCriticEmail(msg){ jQuery('#audiome-lead-label' ).css("display", "none"); jQuery('#audiome-lead-label' ).css("color", "red"); jQuery('#audiome-lead-label' ).text(msg) jQuery('#audiome-lead-label' ).fadeIn(); } function audioMevalidateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); } function audiomeLeadSubmit(){ // console.log("audiomeLeadSubmit") var audiomeNome = jQuery('#audiome-nome-input' ).val() var audiomeEmail = jQuery('#audiome-email-input' ).val() var urlLead = audioMeRemoteUrl + "/lead/saveLead" var IsValideEmail = audioMevalidateEmail(audiomeEmail) submitLead = true if (IsValideEmail == false ) { audioMeCriticEmail("Ops. Por favor, informe um e-mail válido") submitLead = false; } // console.log("audiomeNome -> " + audiomeNome) // console.log("audiomeEmail -> " + audiomeEmail) if (submitLead == true) { jQuery.ajax({ url: urlLead, type: "post", data: { 'audiomeNome' : audiomeNome, 'audiomeEmail' : audiomeEmail, 'readmeSlug' : audiomeClientId, 'readmeDomain' : getHostName(document.location) } }) .done(function( msg ) { // alert( "Data Saved: " + msg ); if (msg.status == "ok") { audioMeCloseLead() localStorage.setItem(audiomeClientId,"true"); } else { audioMeCriticEmail(msg.message) } }); } } function realBackgroundColor(elem) { var transparent = 'rgba(0, 0, 0, 0)'; var transparentIE11 = 'transparent'; if (!elem) return transparent; var bg = getComputedStyle(elem).backgroundColor; if (bg === transparent || bg === transparentIE11) { return realBackgroundColor(elem.parentElement); } else { return bg; } } /******** starting point for your widget ********/ function main() { //your widget code goes here //configuracoes aqui console.log("--> readme.ai INIT 2302 <--"); var SM_Widget = "portaldaindustria"; //ReadMeColor = realBackgroundColor(document.querySelector('.title')); //console.log("ReadMeColor -> " + ReadMeColor) //var ReadMeColor = "red"; //document.documentElement.style.setProperty('--client-color', ReadMeColor); var SM_RemoteUrl = 'https://readme.ai' var audiomeHostName = getHostName(document.location) readmeAudioSpeed = 1.0 if (audiomeHostName == "localhost") { SM_RemoteUrl = "http://localhost:8080" } if (audiomeHostName.search("ngrok") > 0) { SM_RemoteUrl = "https://" + audiomeHostName; } // console.log ("audiomeHostName -> " + audiomeHostName) // console.log ("SM_RemoteUrl -> " + SM_RemoteUrl) homeUrl = SM_RemoteUrl audiomeClientId = SM_Widget; audioMeRemoteUrl = SM_RemoteUrl; audiomeStatus = "stop" audiomeLoadAudio = false // controle se ja fez o request no server audiomeSound = null audiomeMp3List = [] // lista de urls de mp3 audiomePlayCount = 0 // controle de qual objeto esta sendo tocado audiomeTotalTime = 0 // tempo total da soma dos arquivos audiomeAudioDuration = 0 audiomeAudioSeek = 0 // tempo local audiomeSeekPercent = 0 // tempo percentual audiomeVoiceName = "" // voz / linguagem para solicitar ao server audiomeLog = true // controle de log audiomeIsLoaging = false; audiomeErrorCount = 0; audiomeLeadConfig = "0"; audioMeLeadShow = localStorage.getItem(audiomeClientId); readmeAudioPromo = "N" // controla a atualizacao forcada audiomeSponsoredBanner = {} // lista para controle dos banners patrocinados audiomeSponsoredBannerFlag = "OFF" // flag para controle dos banners patrocinados audiomeSponsoredAudio = {} // lista para controle dos audios patrocinados audiomeSponsoredAudioFlag = "OFF" // flag para controle dos audios patrocinados audiomeSponsoredSpot = {} // lista para controle dos audios patrocinados audiomeSponsoredSpotFlag = "OFF" // flag para controle dos audios patrocinados audiomeSponsorErrorCount = 0; audiomeSpotErrorCount = 0; if (audioMeLeadShow === null) {localStorage.setItem(audiomeClientId,"false");} localStorage.setItem(audiomeClientId,"false"); //console.log("audioMeLeadShow ->" + localStorage.getItem(audiomeClientId) ) loadCss(SM_RemoteUrl + "/static/widget/" + SM_Widget + ".css"); //loadCss(SM_RemoteUrl + "/static/webfonts/all.min.css"); //loadCss("https://maxst.icons8.com/vue-static/landings/line-awesome/font-awesome-line-awesome/css/all.min.css") //example jsonp call var jsonp_url = SM_RemoteUrl + "/widget/?site=" + SM_Widget; //var jsonp_url = "https://readme.ai/widget/?site=" + "revistaoeste"; loadScript( SM_RemoteUrl + "/static/js/readability.js" , function() { LoadReadability(); }); // " + myParam) if (myParam == "") { console.log("PARAMUPDATE -> UPDATE") readmeAudioPromo = "Y" } readmeTTSAudio = new Audio(); readmeTTSAudioSponsored = new Audio(); readmeTTSSpotSponsored = new Audio(); readmeTTSAudio.addEventListener('ended', function(){ // console.log("audio end"); readMeAudioEnd(); }); readmeTTSAudio.addEventListener('playing', function(){ window.onbeforeunload = function(e) { return "Sair do Site?"; }; console.log("== PLAYING ") audiomeStatus = "play" jQuery("#audiomebtn-play").hide(); // jQuery("#audiomebtn-loader").hide(); jQuery("#audiomebtn-pause").show(); audioMeProgressBarAnimate() jQuery("#audiomebtn-loader").hide(); setTimeout(function(){ audiomeIsLoaging = false; }, 1000); audioMeOpenLead(); }); readmeTTSAudioSponsored.addEventListener('ended', function(){ console.log("Sponsored audio end"); setTimeout(function(){ var divReadMe = document.createElement("div"); divReadMe.id = "audiomelink"; // Create a

element divReadMe.class = "audiomeref"; // Create a

element divReadMe.innerHTML = "readme.ai"; jQuery("#audiome-ref").html("www.readme.ai"); //jQuery("#audiome-ref").html(divReadMe); //document.getElementById("audiomelink").addEventListener("click", audiomelinkClick); if (audiomeSponsoredSpotFlag == "ON") { playSponsoredSpotTTS(); } else { playAudioTTS(audiomeMp3List[audiomePlayCount]); } }, 500); }); readmeTTSAudioSponsored.addEventListener('playing', function(){ // console.log("Sponsored audio playing"); FireAnalyticsClienteReadme("PlayAudioPatrocinado"); FireAnalytics("PlayAudioPatrocinado"); jQuery("#audiome-ref").html("seu áudio iniciará após a publicidade"); }); readmeTTSSpotSponsored.addEventListener('ended', function(){ // console.log("Sponsored audio end"); setTimeout(function(){ jQuery("#audiome-ref").html("www.readme.ai"); //jQuery("#audiome-ref").html(divReadMe); //document.getElementById("audiomelink").addEventListener("click", audiomelinkClick); playAudioTTS(audiomeMp3List[audiomePlayCount]); }, 500); }); readmeTTSSpotSponsored.addEventListener('playing', function(){ // console.log("Sponsored audio playing"); FireAnalyticsClienteReadme("PlaySpotPatrocinado"); FireAnalytics("PlaySpotPatrocinado"); jQuery("#audiome-ref").html("seu áudio iniciará após a publicidade"); }); // verifica o parametro de testes var readmebuild = getP('readmebuild') if (readmebuild === undefined) {readmebuild = "OFF";} if (readmebuild == "ON") { // readmebuild converte faz o build do tts de forma antecipada setTimeout(function(){ audioMeLoadTTS(); }, 3000); } //FireAnalytics("PageView"); //FireAnalyticsSemParar("PageView"); jQuery.getJSON(jsonp_url, function(result) { // console.log('SM window width -> ' + jQuery(window).width()); // var SM_window = jQuery(window).width(); if (result.site.Main == "ON") { var localurl = window.location.pathname jQuery('#audiome-container').html(result.html); audiomeVoiceName = result.site.Voice; console.log("audiomeVoiceName -> " + audiomeVoiceName) // loadScript( SM_RemoteUrl + "/static/js/feather.min.js" , function() { feather.replace()}); audioMeFillProgressBar(); audiomeClearTitle = result.site.ClearTitle document.getElementById("audiome-button").addEventListener("click", audioMePlayClick); document.getElementById("audiomeouca").addEventListener("click", audioMePlayClick); document.getElementById("audiomeTouchBar").addEventListener("click", audioMeTouchBarClick); document.getElementById("audiomelink").addEventListener("click", audiomelinkClick); document.getElementById("audiomelogo").addEventListener("click", audiomelinkClick); document.getElementById("audiome-lead-button").addEventListener("click", audiomeLeadSubmit); document.getElementById("readpespeed").addEventListener("click", readpespeedClick); FireAnalytics("LoadPlayer"); // FireAnalyticsClienteReadme("LoadPlayer"); var ListSponsorBanner = [] var ListSponsorAudio = [] var ListSponsorSpot = [] result.Sponsor.forEach(function(current, i) { console.log("sponsor forEach ") var tipo = result.Sponsor[i].Tipo; var sponsorRule = result.Sponsor[i].SponsorAudioRule; var localURL = window.location.pathname; if (localurl.indexOf(sponsorRule) != -1 || sponsorRule == "*"){ if (tipo == "banner") { audiomeSponsoredBanner.tipo = result.Sponsor[i].Tipo audiomeSponsoredBanner.banerKey = result.Sponsor[i].banerKey audiomeSponsoredBanner.SponsorFileName = result.Sponsor[i].SponsorFileName audiomeSponsoredBanner.SponsorAudioRule = result.Sponsor[i].SponsorAudioRule audiomeSponsoredBanner.bannerClick = result.Sponsor[i].bannerClick audiomeSponsoredBannerFlag = "ON" // flag para controle dos banners patrocinados // console.log("sponsor banner add + " + i) } if (tipo == "audio") { audiomeSponsoredAudio.tipo = result.Sponsor[i].Tipo audiomeSponsoredAudio.SponsorFileName = result.Sponsor[i].SponsorFileName audiomeSponsoredAudio.SponsorAudioRule = result.Sponsor[i].SponsorAudioRule audiomeSponsoredAudioFlag = "ON" // flag para controle dos audios patrocinados // console.log("sponsor audio add + " + i) } if (tipo == "spot") { SpotItem = {} SpotItem.tipo = result.Sponsor[i].Tipo SpotItem.SponsorFileName = result.Sponsor[i].SponsorFileName SpotItem.SponsorAudioRule = result.Sponsor[i].SponsorAudioRule SpotItem.banerKey = result.Sponsor[i].banerKey ListSponsorSpot.push(SpotItem) console.log("sponsor spot add + " + i) } } }); if (ListSponsorSpot.length > 0) { console.log("ListSponsorSpot -> " + ListSponsorSpot.length) const randomSpot = Math.floor(Math.random() * ListSponsorSpot.length); console.log("randomSpot -> " + randomSpot) audiomeSponsoredSpot.tipo = result.Sponsor[randomSpot].Tipo audiomeSponsoredSpot.SponsorFileName = result.Sponsor[randomSpot].SponsorFileName audiomeSponsoredSpot.SponsorAudioRule = result.Sponsor[randomSpot].SponsorAudioRule audiomeSponsoredSpot.banerKey = result.Sponsor[randomSpot].banerKey audiomeSponsoredSpotFlag = "ON" // flag para controle dos audios patrocinados } // NAO TOCA PUBLICIDADE QUANDO O CONTEUDO FOR DA REVISTA if (localurl.indexOf('/revista/') != -1) { audiomeSponsoredSpotFlag = "OFF" console.log("audiomeSponsoredSpotFlag OFF") } audiomeLeadConfig = result.site.LeadConfig; if (audiomeLeadConfig === null) {audiomeLeadConfig = "0"} } }); jQuery(document).ready(function ($) { }); } })();