2012-07-25, 07:55 AM
Hello, I was wondering is it possible to modify this invisionfree code to work for mybb:
It adds word count bar at the bottom of a new thread/reply/edit field.
Thanks in advance!
<script type="text/javascript">
/* Created by HolySavior of iFusion
Hows my post v2 */
function word_count() {
var post_words = document.forms['REPLIER'].Post.value.split(/ /g); var count = 0;
for(i=0;i<post_words.length;i++) if(post_words[i].length > 2) count++;
var iObj = document.getElementById('count');
iObj.innerHTML = "<table><tr><td><div id='status_bar_holder' class='postbar'><div id='status_bar' style='width: "+count + "%;' class='innerbar'></div></div></td><td>"+ count+" words</td></tr></table>" ;
if(count >= 100){ iObj.innerHTML += "<span class='howspost'>Hows My Post? </span><span style='color:#308014'>Super iPost extraveganza!!</span>";
}else if(count >= 40){ iObj.innerHTML += "<span class='howspost'>Hows My Post? </span><span style='color:#308014'> Excellent Post!</span>";
}else if (count >=10){ iObj.innerHTML += "<span class='howspost'>Hows My Post? </span><span style='color:#308014'> Good Post!</span>";
} else if(count < 10){ iObj.innerHTML += "<span class='howspost'>Hows My Post? </span>You can do better than that!";
}}
var itd = document.getElementsByTagName("td");
for(x=0;x<itd.length;x++){
if(itd[x].className == "pformleft" && itd[x].innerHTML.match(/Post Options/i)) {
itd[x-1].innerHTML += "<br/><div id='count'><span class='howspost'>Hows My Post? </span></div>";
}}
var idiv = document.getElementsByTagName("div");
for(z=0;z<idiv.length;z++){
if(idiv[z].className == "tablepad" && idiv[z].innerHTML.match(/Enable Smilies/i)) {
idiv[z].innerHTML += "<br/> <div id='count'><span class='howspost'>Hows My Post? </span></div>";
}
}
function check_count(){
var post_words = document.forms['REPLIER'].Post.value.split(/ /g); var count = 0;
for(i=0;i<post_words.length;i++) if(post_words[i].length > 2) count++;
if(count < 6){
return confirm("Post Length Alert!!\r\n\r\nYour post has only " + count + " words with over three letters. Are you sure you want to add it?");
}
}
if(document.forms['REPLIER']){
if(document.getElementById('count') )
document.forms['REPLIER'].Post.onkeyup = function(){ word_count(); }
document.forms['REPLIER'].submit.onclick = function(){ return check_count(); }
}
</script>
.postbar {
border: 1px solid #e0e0e0;
background-color: #F5F5F5;
font-size: 8px;
color: #E0E0E0;
font-weight: bold;
width: 500px;
height: 30px;
background-image:url(http://img370.imageshack.us/img370/2441/testonecopy12ol1.gif);
overflow:hidden;
background-repeat:no-repeat;
text-align:left;
}
.innerbar {
font-size: 12px;
height: 27px;
padding:5px 15px 0px 5px;
background-color: #555555;
background-image:url(http://img370.imageshack.us/img370/6621/testonecopy2yj8.gif);
background-repeat:no-repeat;
overflow:hidden;
}
.howspost {
font-weight:bold;
color:#000000
}
It adds word count bar at the bottom of a new thread/reply/edit field.
Thanks in advance!