|
Post by Wormopolis on Apr 27, 2011 16:34:56 GMT -8
Browsers Tested: IE and FF placement: Main footer
This code will put a drop down box above the code fields that make it easy to enable/disable all the codes you have. the codes need to have a title in order for it to find them correctly, otherwise it will list them as unknown
also, if a code has a "banner header" like:
/************************** This is my code blah blah **************************/
you will need to add your own title right above it to help codestriker correctly identify it:
// code for doing something /************************** This is my code blah blah **************************/
its perfect valid for you to add above a code header without violating the rule to not edit the code header (and you dont add your own name as author).
I have been testing it in beta and it seems to be working. Im sure there will be some sort of pattern I didnt account for. if you find one let me know.
also.. if you try this, be sure to back up your headers/footers just in case. or try it out on a forum you wouldnt mind losing all the scripts. It shouldnt do it, but there is always a risk if something goes haywire.
if you go to enable/disable a code and suddenly you are missing scripts that were there before, DONT save. go back out of the h/f.
as I said though.. I tested a lot and it wasnt doing that to me.
<script type="text/javascript"> <!-- // CodeStriker v1.21 // By Wormopolis - [url]www.wormocodes.com[/url] // special thanks to subdevo // do not repost - keep header intact // highly advisable to backup your headers/footers occasionally.
var usedWithSubdevosJumpCode=false; //set true if using his code
if (pb_action=='headersfooters2') { var txtareas=document.getElementsByTagName('textarea'); for (ta=0; ta<txtareas.length; ta++) { var test1=txtareas[ta].parentNode, test2=test1.parentNode; if (txtareas[ta] && txtareas[ta].name && ((test1.nodeName.match(/form/i) && test1.action.match(/headersfooters3/)) || (test2.nodeName.match(/form/i) && test2.action.match(/headersfooters3/)))) { var sectionTitleSpot=txtareas[ta].previousSibling.previousSibling; if (usedWithSubdevosJumpCode) sectionTitleSpot=sectionTitleSpot.previousSibling; var sectionTitle=sectionTitleSpot.firstChild.nodeValue; var nwselect=document.createElement('select'); var hold2=txtareas[ta].dd=nwselect.id=sectionTitle.toLowerCase()+'Striker'; var hold1=txtareas[ta].id=nwselect.fd=sectionTitle.toLowerCase()+'field'; nwselect.onchange=function() { strikeCode(this.id, this.fd); updateStrikerDD(this.id, this.fd);}; txtareas[ta].onmouseout=function() {updateStrikerDD(this.dd, this.id);}; sectionTitleSpot.appendChild(document.createElement('br')); sectionTitleSpot.appendChild(nwselect); updateStrikerDD(hold2, hold1); } } }
function updateStrikerDD(drpdwn, codefield) { var codefieldElement=document.getElementById(codefield); var drpdwnElement=document.getElementById(drpdwn); drpdwnElement.innerHTML=''; var codefieldArray=('#\n'+codefieldElement.value).split(new RegExp('\\n+\\s*?<scr'+'ipt','i')); var nwopt=document.createElement('option'); nwopt.value=''; nwopt.innerHTML='CodeStriker'; drpdwnElement.appendChild(nwopt); nwopt=document.createElement('option'); nwopt.value='enableALL'; nwopt.innerHTML='Enable all found codes'; drpdwnElement.appendChild(nwopt); nwopt=document.createElement('option'); nwopt.value='disableALL'; nwopt.innerHTML='Disable all found codes'; drpdwnElement.appendChild(nwopt); var helperrgx=new RegExp('^\\s*?(\\/[\\/|*]\\s*?(?!(--&g'+'t;|:)))',''); for (fc=1; fc<codefieldArray.length; fc++) { var fcSplit=codefieldArray[fc].split(new RegExp('<\/scr'+'ipt>(\\r|$)',''))[0].split(/\n/); scrptTag=fcSplit[0].split('>')[0]; var atts=(scrptTag.match(/type=('|")(.*?)('|")/) ? atts=RegExp.$2 : ''); var codeTitle='', linecounter=1; while(linecounter<fcSplit.length-1 && !fcSplit[linecounter].match(helperrgx)){linecounter++;} if (linecounter>=fcSplit.length-2) { codeTitle='Unknown Code '+fc; } else { tmp=fcSplit[linecounter].replace(/^\s*/,'').replace(/(\/\/\s*?|\/\*\s*?|\*\/|-{2,}|\*\\)/g,''); while (tmp.length<=1) {linecounter++; tmp=fcSplit[linecounter].replace(/^\s*?/,'').replace(/(\/\/\s*?|\/\*\s*?|\*\/)/g,'');} codeTitle=tmp; } nwopt=document.createElement('option'); nwopt.value='code'+fc; nwopt.innerHTML=codeTitle; if (atts && atts.match(/disable(d?)/)) {nwopt.title='disabled'; nwopt.style.backgroundColor='777777'; } drpdwnElement.appendChild(nwopt); } }
function strikeCode(drpdwn, codefield) { var codefieldElement=document.getElementById(codefield); var drpdwnElement=document.getElementById(drpdwn); var selCode=drpdwnElement.options[drpdwnElement.selectedIndex]; var codefieldArray=('#\n'+codefieldElement.value).split(new RegExp('\\n+\\s*?<scr'+'ipt','i')); if (!selCode.value.match(/ALL/)) { var selCodeId=parseInt(selCode.value.replace(/code/,'')); var currCode=codefieldArray[selCodeId]; var fcSplit=currCode.split(/\n/); scrptTag=fcSplit[0].split('>')[0]; var atts=''; if (scrptTag.match(/type=('|")(.*?)('|")/)) { atts=RegExp.$2; } else { scrptTag+=' type="text/javascript"'; }
if (selCode.title=='disabled') { scrptTag=scrptTag.replace(/-disable(d?)/,''); } else { scrptTag=scrptTag.replace(/type=('|")(.*?)('|")/,'type="text/javascript-disabled"'); }
fcSplit[0]=scrptTag+'>'; codefieldArray[selCodeId]=fcSplit.join('\n'); } else { for (fc=1; fc<codefieldArray.length; fc++) { var fcSplit=codefieldArray[fc].split(/\n/); scrptTag=fcSplit[0].split('>')[0]; var atts=''; if (scrptTag.match(/type=('|")(.*?)('|")/)) { atts=RegExp.$2; } else { scrptTag+=' type="text/javascript"'; }
if (selCode.value=='enableALL') { scrptTag=scrptTag.replace(/-disable(d?)/,''); } else { scrptTag=scrptTag.replace(/type=('|")(.*?)('|")/,'type="text/javascript-disabled"'); }
fcSplit[0]=scrptTag+'>'; codefieldArray[fc]=fcSplit.join('\n');
} } tmpmrk='\n\n<scr'+'ipt'; codefieldArray[0]=codefieldArray[0].replace(/#\n*/,''); var holdscroll=codefieldElement.scrollTop; codefieldElement.value=codefieldArray.join(tmpmrk); codefieldElement.scrollTop=holdscroll; } // --> </script>
|
|