Show time for reading a post
You can see the DEMO in this blog.
Here are some steps to put this tip into your blog:
- Step 1: Put the code below above the </head>.
<script type='text/javascript'>
//<![CDATA[
Step 2: Find <div class='post-header-line-1'/> and put the below code above it:// Estimate-time-to-read-blogspot-post Scriptvar wordsperminute = 300;var imagesperminute = 30;function timeperpostreading(id) {var postcontent = document.getElementById(id);var img = postcontent.getElementsByTagName("img");var numimg = img.length;var strx = postcontent.innerHTML;if(strx.indexOf("<")!=-1) {var s = strx.split("<");for(var i=0;i<s.length;i++){if(s[i].indexOf(">")!=-1){s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);}}strx = s.join("");}var blankfirst = /^ /;var blankfinal = / $/;var blanktotal = /[ ]+/g;strx = strx.replace(blanktotal," ");strx = strx.replace(blankfirst,"");strx = strx.replace(blankfinal,"");var words = strx.split(" ");var numwords = words.length;var minutes = parseInt((numwords/wordsperminute)+(numimg/imagesperminute));var seconds = parseInt((((numwords/wordsperminute)+(numimg/imagesperminute))-minutes)*60);minutes=("0" + minutes).slice (-1);seconds=("0" + seconds).slice (-2);var forreturn = "Time for reading this post: "+minutes+":"+seconds;document.getElementById("timeperpost").innerHTML = forreturn;}//]]></script>
<p id='timeperpost'/>
Next, you find: <data:post.body/> (or <p><data:post.body/></p>) and replace it by the below code:
<div expr:id='data:post.id'><div expr:id='data:post.id'><p><data:post.body/></p></div><script type='text/javascript'>timeperpostreading("<data:post.id/>");</script>
Save template and see the result.
