Post by Alex on May 11, 2009 19:55:01 GMT -8
This will modify the table that is created when you use the [code][/code] tags.
Preview
Open Source - This code is open source, so feel free to redistribute it, re-post it, modify it or anything else you want to.
Cross Browser.
Global Footer.
<script type="text/javascript">
<!--
/*Code Tag Modification - By Alex - Open Source*/
var Code_Tag_Modification={
Location_Check: function(){
if(window.location.href.match(/action=(display|(user)?recent|calendarview|pmview)/) || window.location.href.match(/index.cgi$/) && (document.postForm||document.title.match(/\s-\sSearch/))){
this.Execute_Loop();
}
},
Execute_Loop: function(){
var Table=document.getElementsByTagName('table');
var i=Table.length-1;
do{
if(Table.item(i).cellPadding=="2" && Table.item(i).cellSpacing=="0" && Table.item(i).className=="code" && Table.item(i).width=="100%"){
Table.item(i).parentNode.parentNode.parentNode.parentNode.style.backgroundColor = 'transparent';
Table.item(i).cellPadding='1';
var Font=Table.item(i).rows[0].cells[0].firstChild;
var Br=Font.getElementsByTagName('br');
var Lines='1\n';
for(var a=0;a<Br.length;a++){
Lines+=(a+2)+'\n';
}
Font.innerHTML='<table width="100%" align="center" cellspacing="0" cellpadding="4"><tr><td align="right" class="windowbg" width="5%" rowspan="2" valign="top"><textarea rows="'+(Br.length+3)+'" cols="5" style="font-size: 10px; text-align: right;" disabled="true">'+Lines+'</textarea></td><td align="left" class="windowbg" width="95%"><textarea rows="'+(Br.length+3)+'" style="font-size: 10px; width: 100%;" wrap="off" onfocus="this.select()">'+Font.innerHTML.replace(/<br\s?\/?>/ig, '\n').replace(new RegExp('&a'+'mp;nb'+'sp;', 'g'), ' ')+'</textarea></td></tr><tr><td class="windowbg" width="100%"><div style="float: left;"><textarea style="display: none;">'+Font.innerHTML.replace(/<br\s?\/?>/ig, '\n').replace(new RegExp('&a'+'mp;nb'+'sp;', 'g'), ' ')+'</textarea><input type="submit" value="Undo All" onclick="this.parentNode.parentNode.parentNode.previousSibling.cells[1].firstChild.value = this.previousSibling.value"/></div><div style="float: right;"><font size="1">Total Characters: <span></span></font></div></td></tr></table>';
Font.getElementsByTagName('span').item(0).innerHTML = Font.getElementsByTagName('textarea').item(1).value.length;
}
i--;
}
while(i>4);
}
};
Code_Tag_Modification.Location_Check();
//-->
</script>
Preview
Open Source - This code is open source, so feel free to redistribute it, re-post it, modify it or anything else you want to.
Cross Browser.
Global Footer.
<script type="text/javascript">
<!--
/*Code Tag Modification - By Alex - Open Source*/
var Code_Tag_Modification={
Location_Check: function(){
if(window.location.href.match(/action=(display|(user)?recent|calendarview|pmview)/) || window.location.href.match(/index.cgi$/) && (document.postForm||document.title.match(/\s-\sSearch/))){
this.Execute_Loop();
}
},
Execute_Loop: function(){
var Table=document.getElementsByTagName('table');
var i=Table.length-1;
do{
if(Table.item(i).cellPadding=="2" && Table.item(i).cellSpacing=="0" && Table.item(i).className=="code" && Table.item(i).width=="100%"){
Table.item(i).parentNode.parentNode.parentNode.parentNode.style.backgroundColor = 'transparent';
Table.item(i).cellPadding='1';
var Font=Table.item(i).rows[0].cells[0].firstChild;
var Br=Font.getElementsByTagName('br');
var Lines='1\n';
for(var a=0;a<Br.length;a++){
Lines+=(a+2)+'\n';
}
Font.innerHTML='<table width="100%" align="center" cellspacing="0" cellpadding="4"><tr><td align="right" class="windowbg" width="5%" rowspan="2" valign="top"><textarea rows="'+(Br.length+3)+'" cols="5" style="font-size: 10px; text-align: right;" disabled="true">'+Lines+'</textarea></td><td align="left" class="windowbg" width="95%"><textarea rows="'+(Br.length+3)+'" style="font-size: 10px; width: 100%;" wrap="off" onfocus="this.select()">'+Font.innerHTML.replace(/<br\s?\/?>/ig, '\n').replace(new RegExp('&a'+'mp;nb'+'sp;', 'g'), ' ')+'</textarea></td></tr><tr><td class="windowbg" width="100%"><div style="float: left;"><textarea style="display: none;">'+Font.innerHTML.replace(/<br\s?\/?>/ig, '\n').replace(new RegExp('&a'+'mp;nb'+'sp;', 'g'), ' ')+'</textarea><input type="submit" value="Undo All" onclick="this.parentNode.parentNode.parentNode.previousSibling.cells[1].firstChild.value = this.previousSibling.value"/></div><div style="float: right;"><font size="1">Total Characters: <span></span></font></div></td></tr></table>';
Font.getElementsByTagName('span').item(0).innerHTML = Font.getElementsByTagName('textarea').item(1).value.length;
}
i--;
}
while(i>4);
}
};
Code_Tag_Modification.Location_Check();
//-->
</script>