/* Widget Name: Javascript blogger widget for WebReader Widget URI: http://www.voice-corp.com Description: Widget will allow users to listen to Blogger Blogs Version: 1.0 */ function getTitleAndLinkAndPlacement(thepost) { var titleNode=undefined; var titlelink=''; var timestamplink=''; var els=thepost.getElementsByTagName("*"); for (j=0;j=0) { // search for a hx element with a class containing the word title titleNode=els[j]; if (titleNode!=undefined) { var links=titleNode.getElementsByTagName("a"); // get link in title hx if (links.length>0) titlelink=links.item(0).href; } } else if (els[j].nodeName=="A" && els[j].className.indexOf('timestamp-link')>=0) { // get time stamp link timestamplink=els[j].href; } else if (els[j].nodeName=='DIV' && els[j].className=='post-header-line-1') { // pick out placement div place=els[j]; } } if (titleNode!=undefined) { if (titleNode.innerText) // pick title text, varies between browsers title=titleNode.innerText; else if (titleNode.textContent) title=titleNode.textContent; } else { // use start of post content if no title node was found if (thepost.innerText) // pick title text, varies between browsers content=thepost.innerText; else if (thepost.textContent) content=thepost.textContent; title=content.substring(0,30); } if (timestamplink!='') { // use time stamp link if exists permalink=timestamplink; } else if (titlelink!='') { // otherwise use the link from the title element permalink=titlelink; } } function foundPost(thediv) { // check if class post is present on the div if (thediv.className=='post') return true; else if (thediv.className.indexOf(' post ')>=0) return true; else if (thediv.className.substring(0,5)=='post ') return true; else if (thediv.className.substring(thediv.className.length-5,5)==' post') return true; else return false; } function addButton(i,thepost,theplace) { // build webReader href var wrhref="http://wr.readspeaker.com/a/webreader/webreader.php?cid=814902af1214ce84a3115eeafda18f8d&t=blogger&url=REPLCACE_URL&title=REPLACE_TITLE"; wrhref=wrhref.replace('REPLCACE_URL', escape(permalink)); wrhref=wrhref.replace('REPLACE_TITLE', escape(title)); // build webReader image var wrimgsrc='http://wr.readspeaker.com/m/wr/images/listen_en_us.gif'; var theimg=document.createElement("img"); theimg.setAttribute("src",wrimgsrc); theimg.setAttribute("style","border-style: none;"); theimg.setAttribute("alt",'Listen with webReader'); // build webReader button var thebutton=document.createElement("a"); thebutton.setAttribute("href",wrhref); thescript="readpage(this.href,"+(i+1)+");return false;"; thebutton.setAttribute("onclick",thescript); thebutton.onclick=new Function(thescript); // some browsers does not parse setAttribute values thebutton.appendChild(theimg); // create player expanding area var theplayerdiv=document.createElement("div"); theplayerdiv.setAttribute("id","WR_"+(i+1)); tmp=document.createTextNode(" "); theplayerdiv.appendChild(tmp); // build webReader html conde fragment var thecode=document.createDocumentFragment(); thecode.appendChild(thebutton); thecode.appendChild(theplayerdiv); if(theplace.parentNode.className == 'post-header') { thepost.insertBefore(thecode,theplace.parentNode); // add button immediate before the placement div } else { thepost.insertBefore(thecode,theplace); } } window.onload=function() { // this executes when blog is loaded permalink=''; title=''; place=undefined; var posts=document.getElementsByTagName("div"); // assume all posts are wrapped in a div for (i=0;i