User:Zocky/wc.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
function $(id){return document.getElementById(id)} addOnloadHook(wcInit); function wcInit() { code = '<textarea id="wcText" style="width:100%;height:400px"></textarea>' + '<div id="wcResult" style="height:7em;background:#def"></div>' + '<input type="button" value="go" onclick="wcGo()"><p>'; $('content').innerHTML=code+$('content').innerHTML; } function wcGo() { text = $('wcText').value; result=text.length+" characters<br>"; result+=(n = text.replace(/\s+/g,'').length) + " non-space characters<br>"; result+=text.split(/\s+/).length + " words<br>"; result+=Math.ceil(n/750)/2 + " standard pages<br>"; $('wcResult').innerHTML=result; }