|
Post by Wormopolis on Jul 20, 2009 15:23:26 GMT -8
Browser Tested: IE and FF placement: board footer
Lets you create a selection list of possible prefixes/meanings that will be appended to the beginning of the thread title on submit. selection list only appears when creating the thread and not when modifying. admins can still see the selection list if it needs to be changed to a different prefix.
code:
<style type="text/css"> .prfx {background-color: EEEEEE; border: #000000 1px solid;} </style>
<script type="text/javascript"> <!-- // Prefix on posts using checkboxes // v 2.251 // By Wormopolis - Request by Kami // keep header intact
var chkBxArray = [ ["[CD]","Code"], //format: PREFIX , checkbox label, (optional: color of prefix) ["[GR]","Graphic"], ["[SG]","Signature","FFFF00"], ["[BN]","Banner"], ["[QU]","Question","00AAFF"], ["[CM]","Complaint"], ["[<3]","I love wormo","FF0000"] //no comma last entry ];
var disableSubmitButton=true; //set false if you dont want prefixes mandatory var explanationOFsubmitdisabled="Submit button disabled until request reason is chosen"; var additionalInstruction="Please read the board rules before posting! You must choose a reason for starting this thread"; var leftSideLabel="Request Reason:";
// no need to edit below unless you know what you are doing
adminCheck=false; for (adm=document.getElementsByTagName('a'), i=0; i<adm.length; i++) { if (adm[i].href.match(/action=admin/)) adminCheck=true; }
if (location.href.match(/board=/) && !location.href.match(/action=display/)) { for (tbar=document.getElementsByTagName('td'), pr=0; pr<tbar.length; pr++) { if (tbar[pr].className=='windowbg' && tbar[pr].width.match(/(48|43)%/)) {
ttl=tbar[pr].getElementsByTagName('font')[0]; for (pf=0; pf<chkBxArray.length; pf++) { if (escape(ttl.innerHTML).match(escape(chkBxArray[pf][0]))) { tmp="<font class='prfx' "+(chkBxArray[pf][2] ? "color='"+chkBxArray[pf][2]+"'" : "")+">"+chkBxArray[pf][0]+"</font>"; ttl.innerHTML=ttl.innerHTML.replace(chkBxArray[pf][0], tmp) break; } } } } } if (document.postForm && !location.href.match(/createpoll/)) { frm=document.postForm.subject;
frmTbl=frm.parentNode.parentNode.parentNode;
chkbxCell=document.postForm.subject.parentNode.cloneNode(true); descCell=document.postForm.subject.parentNode.previousSibling.cloneNode(true); descCell.firstChild.innerHTML=leftSideLabel; chkbxCell.colSpan=frmTbl.rows[1].cells.length-1; chkbxCell.innerHTML=""; chkbxCell.id="prefixes"; keepchk=false; nwchkbx=additionalInstruction +"<br>"; for (k=0; k<chkBxArray.length; k++) { if (postForm.subject.value.match(chkBxArray[k][0])) { postForm.subject.value=postForm.subject.value.replace(chkBxArray[k][0]+' ',''); if (document.getElementById('rfSub')) document.getElementById('rfSub').value=document.getElementById('rfSub').value.replace(chkBxArray[k][0]+' ',''); defchk="checked='checked'"; keepchk=true; } else { defchk=""; } nwchkbx+="<input name='prfix' type='radio' style='background-color=\"transparent\"' onclick='document.getElementById(\"sbmit\").disabled=\"\"; document.getElementById(\"distext\").style.display=\"none\"' "+defchk+" value='"+chkBxArray[k][0]+"'><font size='2' "+(chkBxArray[k][2] ? "color='"+chkBxArray[k][2]+"'" : "")+">"+chkBxArray[k][1]+"</font><br>"; } chkbxCell.innerHTML=nwchkbx; rowIwant=frmTbl.insertRow(2); rowIwant.appendChild(descCell); rowIwant.appendChild(chkbxCell); for (inp=document.getElementsByTagName('input'), j=0; j<inp.length; j++) { if (inp[j].type=='submit' && (inp[j].tabIndex==3 || inp[j].tabIndex==5)) { if (!keepchk && disableSubmitButton) { inp[j].disabled=true; inp[j].id="sbmit"; inp[j].parentNode.appendChild(document.createElement('br')); distext=document.createElement('font'); distext.id="distext"; distext.innerHTML=explanationOFsubmitdisabled; inp[j].parentNode.appendChild(distext); } } } function addin() { choices=document.getElementById('prefixes').getElementsByTagName('input'); for ( i=0; i<choices.length; i++) { if (choices[i].checked) postForm.subject.value=choices[i].value+" "+postForm.subject.value; if (choices[i].checked && document.getElementById('rfSub')) document.getElementById('rfSub').value=choices[i].value+" "+document.getElementById('rfSub').value; } }
if (document.addEventListener) { document.postForm.addEventListener('submit',addin,false); } else { document.postForm.attachEvent('onsubmit',addin); }
}
// --> </script>
Preview: I might put something in the graphics request section if my moderator is willing.
|
|
|
Post by Wormopolis on Jan 24, 2010 21:20:57 GMT -8
updated to have colored prefixes in list and on thread titles as a request.
|
|
|
Post by Wormopolis on May 27, 2010 2:47:00 GMT -8
updated to v2.01: support for use on Cali's predefined template as well as fix for guest posting.
|
|
|
Post by Wormopolis on May 27, 2010 23:06:15 GMT -8
updated to v 2.2: fixed a few bugs from that last update and made the color part work again. if no color chosen, prefix defaults to normal text color.
NOTE: this code must now run AFTER the predefined template code in order to work.
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Jul 18, 2010 8:19:31 GMT -8
updated to v 2.2: fixed a few bugs from that last update and made the color part work again. if no color chosen, prefix defaults to normal text color. NOTE: this code must now run AFTER the predefined template code in order to work. I tried to update to the new version on my Classified Board since the colors are no longer working and nothing happened. It's not showing up at all for me to even choose a prefix when I start a new thread. So I had to revert back to 2.0. The only thing I changed in your new code was this: var chkBxArray = [ ["SELL","Want to sale a product (SELL)","004F00”], //format: PREFIX , checkbox label, (optional: color of prefix) ["BUY","Want to buy a product (BUY)","CD0000"], ["TRADE","Want to trade a product (TRADE)","303030"], ["ENDED","Item no longer available (ENDED)","191970"] //no comma last entry ];
var explanationOFsubmitdisabled="Post Message button disabled until Request Type chosen!"; var additionalInstruction="Please read 'When the deal is SEALED' sticky before posting! A prefix will be added to your subject line depending on Request Type!"; var leftSideLabel="Request Type:";
|
|
|
Post by Wormopolis on Jul 18, 2010 17:09:09 GMT -8
look aT THIS LINE:
["SELL","Want to sale a product (SELL)","004F00”],
notice those quote marks at the end?
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Jul 18, 2010 20:46:26 GMT -8
look aT THIS LINE: ["SELL","Want to sale a product (SELL)","004F00”], notice those quote marks at the end? What about them? I took them out same result. I copied the BUY line and deleted SELL Line and then retyped the SELL stuff in the copied 2nd BUY Line without deleting the quotes and same result. I even copied it from the one that's working on the board and still nothing. What am I doing wrong?
|
|
|
Post by Wormopolis on Jul 18, 2010 21:45:23 GMT -8
They werent regular quote marks. they were rich text quote marks that you usually get when you edit codes with a word processor like Word or something.
var chkBxArray = [ ["SELL","Want to sale a product (SELL)","004F00"], //format: PREFIX , checkbox label, (optional: color of prefix) ["BUY","Want to buy a product (BUY)","CD0000"], ["TRADE","Want to trade a product (TRADE)","303030"], ["ENDED","Item no longer available (ENDED)","191970"] //no comma last entry ];
var explanationOFsubmitdisabled="Post Message button disabled until Request Type chosen!"; var additionalInstruction="Please read 'When the deal is SEALED' sticky before posting! A prefix will be added to your subject line depending on Request Type!"; var leftSideLabel="Request Type:";
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Jul 18, 2010 23:17:11 GMT -8
Thanks but there is definitely something wrong with the new code. I made the changes and the code is not working. It does not even showing up.
|
|
|
Post by Wormopolis on Jul 19, 2010 21:22:43 GMT -8
link to the board so I can see the whole code?
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Jul 19, 2010 23:55:40 GMT -8
I had to revert to the old one because I could not get the new one to work so I will now change it to the new one that don't work until later on today. sonyreaderboards.com/
|
|
|
Post by Wormopolis on Jul 20, 2010 21:36:27 GMT -8
I see whats happening.
The new feature PB added that lets you preview a thread's first post contents when you over over the thread title has killed this code. if you hover, you will notice its trying to put the color info in THERE.
Im going to write in a fix and I want you to try it out. get new version above.
|
|
victory1
Full Member
Posts: 102
victory1 said 0 great things
|
Post by victory1 on Jul 20, 2010 23:51:36 GMT -8
Still don't work. Not showing up at all like the other one. The one I have on the board now works (version 2.0), except that the colors only show in the var leftSideLabel="Request Reason:" when you are choosing a prefix and not the actual thread. I went back to it.
|
|
|
Post by Wormopolis on Jul 22, 2010 23:00:56 GMT -8
dammit. ok. I have to pull this back into a testing board to see if I can hash out whats going on. I could have sworn that would work...
|
|
|
Post by Wormopolis on Jul 23, 2010 19:40:01 GMT -8
This code is conflicting. /* Title on Image/Link Hover by SubDevo */
Im trying to find a way to make them work together. you COULD try reversing the order and see what happens..
|
|