inherit
93709
0
Jan 12, 2012 20:38:11 GMT -8
OH SO COOPERNATURAL !
you're just not her .
355
November 2006
winifred
|
Post by OH SO COOPERNATURAL ! on Nov 29, 2007 19:01:41 GMT -8
Description: I was wondering how to tweak the Word Count Code for my Roleplaying board. I wanted to be able to post less on certain boards, and have the 420 word minimum on others. (I had one a while back, but you had to put the code in the header/footer of every board created. I can't find that code, nor do I want to go through all the boards and add it.) Experienced By: Just me Code: <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>
Web Browser: Internet Explorer Code URL: support.proboards.com/index.cgi?board=codedatabase&action=display&n=1&thread=70705 Forum URL: manchesterhs.proboards54.com
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Nov 29, 2007 21:46:13 GMT -8
I modified the code to your request as well as included support for quick reply and made PMs no longer pay attention to wordCountLimit. Also made code more stringent by closing loophole where poster could exceed the minimum limit then backspace below the limit thus able to make a post less than specified amount of words. This new code has been tested only on a test forum so it may still contain bugs. Please reply to this thread should you find any or if you do not understand the instructions.
<script type="text/javascript"> <!-- /* Posting/PM Word Count - created by Eton Bones SELECTIVE BOARDS VERSION GLOBAL FOOTER */
/* OPTIONAL For each board you want a minimum word count limit on add boardID and minimum word allowed to post on that board (example next line) rpboardid:200, <-- board with ID rpboardid will have a 200 word minimum post Each boardID and limit gets it own line and should have a comma at the end of the line unless it is the last or only line. If you wish to apply one limit to all boards not specifically given a limit then use "all" (no quotes) as the boardID */ var wordCountLimit={ /*=====start examples===== rpboardid:200, all:100 <-- all boards except rpboardid will have a 100 word minimum =====end examples=====*/ }
if(document.getElementsByName('message').length){ var __submitBtn,__wc,__msg,__wcl var __boardID=""; __msg=document.getElementsByName('message')[0]; __submitBtn=document.getElementsByTagName('input'); for(var count=0;count<__submitBtn.length;count++){ if(__submitBtn[count].name=="board")__boardID=__submitBtn[count].value; if(__submitBtn[count].accessKey && __submitBtn[count].accessKey=='s'){__submitBtn=__submitBtn[count];break;} } if(typeof(__submitBtn.length)=="undefined"){ __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; __wcl=((__boardID.length && (__boardID in wordCountLimit))?wordCountLimit[__boardID]:(__boardID.length && ("all" in wordCountLimit))?wordCountLimit["all"]:0) if(count<__wcl){__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; __wcl=((__boardID.length && (__boardID in wordCountLimit))?wordCountLimit[__boardID]:(__boardID.length && ("all" in wordCountLimit))?wordCountLimit["all"]:0) if(count<__wcl){__submitBtn.disabled=true;}else{__submitBtn.disabled=false} __wc.lastChild.innerHTML=count;
} //--> </script>
edit: changed logic slightly so that "all" can be used to specify a word count limit only for boards not specifically given a minimum limit.
NOTE: minimum limits are still optional. If left unedited then only wordcount will be displayed and no minimum limit will be enforced
|
|
inherit
93709
0
Jan 12, 2012 20:38:11 GMT -8
OH SO COOPERNATURAL !
you're just not her .
355
November 2006
winifred
|
Post by OH SO COOPERNATURAL ! on Dec 4, 2007 23:35:51 GMT -8
I don't understand how to use that code. Call me illiterate, but everytime I try to piece together the edit, I get even more confused.
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Dec 5, 2007 17:38:26 GMT -8
For each board you want to set a unique limit for you add a line. If you want to set a 420 word limit on all boards except three which as an example are named suggestions(30 words minimum) ,support (10 words minimum) and ooc (no minimum) the wordCountLimit would look like this...
var wordCountLimit={ suggestions:30, support:10, ooc:0, all:420 }
If you still don't understand then give me the board IDs you want limits on and I'll plug them in for you.
TIP: If you don't know what a board ID is then go into admin panel and click the Modify Board link. The drop down list that comes up asking you to choose which board to modify will have the ID of the board in parentheses like this ...Coding support(id:codesupport)
|
|
Garyn Fett
Junior Member
The original Mando'a Jetii
Posts: 350
inherit
114722
0
Feb 29, 2008 16:45:59 GMT -8
Garyn Fett
The original Mando'a Jetii
350
November 2007
garynfett
|
Post by Garyn Fett on Dec 5, 2007 17:48:09 GMT -8
Eton, we implemented that code on another board, and it doesn't ignore the PM's. Just thought you should know.
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Dec 5, 2007 19:05:52 GMT -8
Eton, we implemented that code on another board, and it doesn't ignore the PM's. Just thought you should know. The updated code in this thread or the code from the database?
|
|
Garyn Fett
Junior Member
The original Mando'a Jetii
Posts: 350
inherit
114722
0
Feb 29, 2008 16:45:59 GMT -8
Garyn Fett
The original Mando'a Jetii
350
November 2007
garynfett
|
Post by Garyn Fett on Dec 5, 2007 19:18:26 GMT -8
The updated code.
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Dec 5, 2007 19:38:45 GMT -8
Oops I see why.. adding the "all" option reversed the logic. Code edited. Thanks Garyn
|
|
inherit
93709
0
Jan 12, 2012 20:38:11 GMT -8
OH SO COOPERNATURAL !
you're just not her .
355
November 2006
winifred
|
Post by OH SO COOPERNATURAL ! on Dec 6, 2007 17:30:01 GMT -8
I think I understand now. The part
[ rpboardid:200, all:100 <-- all boards except rpboardid will have a 100 word minimum
I just have to change "rpboardid" to the board i.d, and add a comma at the end, right? Do I do this for Each board that I want coded? Going all the way down the line? (Meaning "boardid1","etc." Not in each footer.) That makes sense.
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Dec 6, 2007 17:55:40 GMT -8
I think I understand now. The part [ rpboardid:200, all:100 <-- all boards except rpboardid will have a 100 word minimum I just have to change "rpboardid" to the board i.d, and add a comma at the end, right? Do I do this for Each board that I want coded? Going all the way down the line? (Meaning "boardid1","etc." Not in each footer.) That makes sense. Exactly. One line for each board you want to set a minimum limit on. Each line has a comma at the end except the last line. If you want to apply a minimum limit to all boards that don't have a line then use all as the boardid
|
|
inherit
93709
0
Jan 12, 2012 20:38:11 GMT -8
OH SO COOPERNATURAL !
you're just not her .
355
November 2006
winifred
|
Post by OH SO COOPERNATURAL ! on Dec 6, 2007 18:10:29 GMT -8
Great! Thank you So Much!
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Dec 6, 2007 20:24:19 GMT -8
You're welcome! Let me know if there are any more problems...
|
|
inherit
93709
0
Jan 12, 2012 20:38:11 GMT -8
OH SO COOPERNATURAL !
you're just not her .
355
November 2006
winifred
|
Post by OH SO COOPERNATURAL ! on Dec 6, 2007 22:15:02 GMT -8
It doesn't work Now I'm just looking for the first code. You have to put it in Every board's header/footer, but at least it works and I know how to use it.
|
|
Garyn Fett
Junior Member
The original Mando'a Jetii
Posts: 350
inherit
114722
0
Feb 29, 2008 16:45:59 GMT -8
Garyn Fett
The original Mando'a Jetii
350
November 2007
garynfett
|
Post by Garyn Fett on Dec 6, 2007 22:48:43 GMT -8
It works, Cooper. We have it installed on one of the boards I'm on. You just need to make sure that the board names and numbers aren't part of the commented out area. The red area is commented out, you need put your ID's and numbers under that, where I have boardID and board2ID and ##. You took the code out of your footers, so I can't tell you for sure that you had it commented out, but it sounds like what we did at first on our board (my admin doesn't know too much about coding).
var wordCountLimit={ /*=====start examples===== rpboardid:200, all:100 <-- all boards except rpboardid will have a 100 word minimum =====end examples=====*/ boardID:##, board2ID:##, all:## }
|
|
inherit
Official Code Helper
65613
0
1
Apr 15, 2024 17:01:41 GMT -8
Chris
"'Oops' is the sound we make when we improve"
8,870
December 2005
horace
|
Post by Chris on Dec 6, 2007 23:11:57 GMT -8
Thanks Garyn, I'll have to come up with an easier way of explaining. Good idea to remove those comments when editing since they are only there for illustration purposes and would save a few bytes in bandwidth
|
|