Post by Mands on Mar 4, 2013 14:25:07 GMT -8
At the moment I do have a word count on the site thanks to another member. However the way it's been created I have had to put it into a sidebar container. It's working for now, but I've got so much stuff on my sidebar and plan to add more that I would love it if I could remove it from there. So is there a chance that someone could create a proper plugin that allowed for the word count to be added automatically to the post window when typing please? That's the way it used to work on V4. I can give the code that was given to me to put into the sidebar container - but I have no idea about what is in the actual plugin part, but I could take a look. If someone could do something to merge or whatever to make it work in the post window I would really appreciate it thanks.
But looking at the actual plugin - there appears to be nothing that you can amend anywhere. But a proper one that could be incorporated into the post window again would be ideal thanks.
This is the code from the sidebar container:-
<form>
<textarea cols=20 rows=5 name=x>
</textarea>
<br>
<input type=button value="Count Words" OnClick ="CountWords(this.form.x, true, true);">
</form>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
And this is what I had in place on V4 for it:-
<script type='text/javascript'>
<!--
/* Posting/PM Word Count - created by Eton Bones */
//set to minimum word count needed in order to make a post
//or set to 0 to disable word count enforcement.
var wordCountLimit=0;
if(document.postForm && document.postForm.message){
var __submitBtn,__wc,__msg
__msg=document.postForm.message;
__submitBtn=document.getElementsByTagName('input');
for(var count=0;count<__submitBtn.length;count++){
if(__submitBtn[count].accessKey && __submitBtn[count].accessKey=='s'){__submitBtn=__submitBtn[count];break;}
}
if(typeof(__submitBtn.length)=="undefined"){
__btnText=__submitBtn.value;
__wc=document.createElement('div'); __wc.id="wordcount";
__wc.appendChild(document.createTextNode('Word Count: '));
__wc.appendChild(document.createElement('span'));
__submitBtn.parentNode.appendChild(__wc);
count=__msg.value.match(/\b\w+\b/g);
count=(count)?count.length:0;
__wc.lastChild.innerHTML=count;
if(count<wordCountLimit){__submitBtn.disabled=true;}
if(document.addEventListener){
__msg.addEventListener("keyup",wordUp,false);
__msg.addEventListener("input",wordUp,false);
__msg.addEventListener("change",wordUp,false);
}else if(document.attachEvent){
__msg.attachEvent("onpropertychange",wordUp);
}else{
__msg.onkeyup=wordUp;
__msg.onmouseup=wordUp;
__msg.onchange=wordUp;
}
}
}
function wordUp(event){
if(this.document){var thiss=event.srcElement;}else{var thiss=this;}
var count=thiss.value.match(/\b\w+\b/g); count=(count)?count.length:0;
if(count>=wordCountLimit && wordCountLimit >0 && __submitBtn.disabled){
__submitBtn.disabled=false;
}
__wc.lastChild.innerHTML=count;
}
//-->
</script>
But looking at the actual plugin - there appears to be nothing that you can amend anywhere. But a proper one that could be incorporated into the post window again would be ideal thanks.
This is the code from the sidebar container:-
<form>
<textarea cols=20 rows=5 name=x>
</textarea>
<br>
<input type=button value="Count Words" OnClick ="CountWords(this.form.x, true, true);">
</form>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
And this is what I had in place on V4 for it:-
<script type='text/javascript'>
<!--
/* Posting/PM Word Count - created by Eton Bones */
//set to minimum word count needed in order to make a post
//or set to 0 to disable word count enforcement.
var wordCountLimit=0;
if(document.postForm && document.postForm.message){
var __submitBtn,__wc,__msg
__msg=document.postForm.message;
__submitBtn=document.getElementsByTagName('input');
for(var count=0;count<__submitBtn.length;count++){
if(__submitBtn[count].accessKey && __submitBtn[count].accessKey=='s'){__submitBtn=__submitBtn[count];break;}
}
if(typeof(__submitBtn.length)=="undefined"){
__btnText=__submitBtn.value;
__wc=document.createElement('div'); __wc.id="wordcount";
__wc.appendChild(document.createTextNode('Word Count: '));
__wc.appendChild(document.createElement('span'));
__submitBtn.parentNode.appendChild(__wc);
count=__msg.value.match(/\b\w+\b/g);
count=(count)?count.length:0;
__wc.lastChild.innerHTML=count;
if(count<wordCountLimit){__submitBtn.disabled=true;}
if(document.addEventListener){
__msg.addEventListener("keyup",wordUp,false);
__msg.addEventListener("input",wordUp,false);
__msg.addEventListener("change",wordUp,false);
}else if(document.attachEvent){
__msg.attachEvent("onpropertychange",wordUp);
}else{
__msg.onkeyup=wordUp;
__msg.onmouseup=wordUp;
__msg.onchange=wordUp;
}
}
}
function wordUp(event){
if(this.document){var thiss=event.srcElement;}else{var thiss=this;}
var count=thiss.value.match(/\b\w+\b/g); count=(count)?count.length:0;
if(count>=wordCountLimit && wordCountLimit >0 && __submitBtn.disabled){
__submitBtn.disabled=false;
}
__wc.lastChild.innerHTML=count;
}
//-->
</script>