Warning! The site which the script uses to provide the service contains a malicious iframe. While most probably the site itself is not malicious, I don’t recommend using the script below until the issues have been cleared up. If you included it in your site, please disable it until the problems have been cleared up. (If you subscribe to the blog, I’ll post a note when this is the case.)
As I’ve said many times, in the computer domain we are especially tempted to forget things that came before us, solutions that have already been found, even though there are lots of very cool things if we just dig.
For example via this Perl Advent Calendar entry I found out about SMOG – Simple Measure of Gobbledygook. It is a relatively simple formula, which claims to have “an outstandingly high 0.985 correlation with the grades of readers who had 100% comprehension of test materials”. Very interesting.
So I added a button after each post title using which you can submit the given article for a SMOG evaluation. Because RSS readers usually don’t render JS, you’ll have to visit the blog on the web to see these buttons. If you want to add them to your blog, here is the source:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<style>
.smog-button {
border: 1px solid black; background-color: #dfffbf; color: rgb(51, 0, 0);
}
</style>
<script>
/* <![CDATA[ */
$(document).ready(function() {
$('div.post').each(function(i, e) {
var titleElement = $('.post-title', e);
var postBodyText = $('.post-body', e).html();
//remove <code> and <pre> entirely
postBodyText = postBodyText.replace(/<s*(?:code|pre)[sS]*?/(?:code|pre)[sS]*?>/gi, '');
//strip the other tags
postBodyText = postBodyText.replace(/<[sS]*?>/gi, '');
if (postBodyText.length < 100) return;
//escape " and limit length
var title = titleElement.text().substring(0, 40).replace(/"/g, '"');
postBodyText = postBodyText.substring(0, 10000).replace(/"/g, '"');
$('a', titleElement).after(
'<form name="dataForm" method="post" target = "_blank" action="http://wordscount.info/hw/service/smog/analyze.jsp">'
+ '<input type="hidden" name="document_title" value="' + title + '" />'
+ '<input type="hidden" name="user_text" value="' + postBodyText + '" />'
+ '<input type="hidden" name="service_id" value="WordsCount">'
+ '<input type="hidden" name="service_name" value="SMOG Calculator">'
+ '<input class="smog-button" type="submit" value="SMOG" />'
+ '</form>');
});
});
/* ]]> */
</script>
PS. Most of my posts seem to have a surprisingly high SMOG score – somewhere in the some college-post-graduate degree interval – considering that English is my second language…