Post by Moose on Sept 28, 2006 14:06:22 GMT -8
Cross Browser
This code will add the IF style "Close All Tags" link which will close all ubbc tags when pressed and it will also the IF style "Open Tags" which will tell you how many tags are open when posting.
Here's a preview:
http://img./v312/gbeerbower/ifstyleubbccloseall.png
Global Footer:
This code will add the IF style "Close All Tags" link which will close all ubbc tags when pressed and it will also the IF style "Open Tags" which will tell you how many tags are open when posting.
Here's a preview:
http://img./v312/gbeerbower/ifstyleubbccloseall.png
Global Footer:
<script type="text/javascript">
<!--
/*
IF Style Close All Tags
Coded By Greg/Moose
Don't edit or repost
*/
if(document.postForm){
function closetags(){
var otagbold = document.getElementById('otagbold');
otagbold.innerHTML = "0";
var closebbar = new Array();
var alrclose = new Array();
var postcopy = document.postForm.message.value;
while(postcopy.match(/\[(b|i|u|s|glow(=.+?)?|shadow(=.+?)?|move|pre|left|center|right|size(=.+?)?|font(=.+?)?|blockquote|url(=.+?)?|ftp|img|email(=.+?)?|table|tr|td|sup|sub|tt|code|quote(.+?)?|list)\]/i)){
var bbname = RegExp.$1;
if(bbname.match(/\s/)){
bbname = bbname.split(/\s/)[0];
} else if(bbname.match(/=/)){
bbname = bbname.split(/=/)[0];
}
closebbar.push('[/'+bbname+']');
postcopy = postcopy.replace(/\[(b|i|u|s|glow(=.+?)?|shadow(=.+?)?|move|pre|left|center|right|size(=.+?)?|font(=.+?)?|blockquote|url(=.+?)?|ftp|img|email(=.+?)?|table|tr|td|sup|sub|tt|code|quote(.+?)?|list)\]/i,'');
}
closebbar.reverse();
closebbstr = closebbar.join("");
postcopy = document.postForm.message.value;
while(postcopy.match(/\[\/(b|i|u|s|glow|shadow|move|pre|left|center|right|size|font|blockquote|url|ftp|img|email|table|tr|td|sup|sub|tt|code|quote|list)\]/i)){
var bbname = RegExp.$1;
alrclose.push('[/'+bbname+']');
postcopy = postcopy.replace(/\[\/(b|i|u|s|glow|shadow|move|pre|left|center|right|size|font|blockquote|url|ftp|img|email|table|tr|td|sup|sub|tt|code|quote|list)\]/i,'');
}
for(a=0;a<alrclose.length;a++){
var matcher = alrclose[a];
matcher = matcher.replace("[","\\[");
matcher = matcher.replace("/","\\/");
matcher = matcher.replace("]","\\]");
matcher = new RegExp(matcher,'i');
if(closebbstr.match(matcher)){
closebbstr = closebbstr.replace(matcher,'');
}}
document.postForm.message.value += closebbstr;
}
function countOpenTags(){
var otagbold = document.getElementById('otagbold');
var opentags = 0;
var closedtags = 0;
var postcopy = document.postForm.message.value;
while(postcopy.match(/\[(b|i|u|s|glow(=.+?)?|shadow(=.+?)?|move|pre|left|center|right|size(=.+?)?|font(=.+?)?|blockquote|url(=.+?)?|ftp|img|email(=.+?)?|table|tr|td|sup|sub|tt|code|quote(.+?)?|list)\]/i)){
opentags++;
postcopy = postcopy.replace(/\[(b|i|u|s|glow(=.+?)?|shadow(=.+?)?|move|pre|left|center|right|size(=.+?)?|font(=.+?)?|blockquote|url(=.+?)?|ftp|img|email(=.+?)?|table|tr|td|sup|sub|tt|code|quote(.+?)?|list)\]/i,'');
}
while(postcopy.match(/\[\/(b|i|u|s|glow|shadow|move|pre|left|center|right|size|font|blockquote|url|ftp|img|email|table|tr|td|sup|sub|tt|code|quote|list)\]/i)){
closedtags++;
postcopy = postcopy.replace(/\[\/(b|i|u|s|glow|shadow|move|pre|left|center|right|size|font|blockquote|url|ftp|img|email|table|tr|td|sup|sub|tt|code|quote|list)\]/i,'');
}
var stillopen = opentags - closedtags;
if(stillopen < 0){
stillopen = 0;
}
otagbold.innerHTML = stillopen;
}
var td = document.getElementsByTagName('td');
for(t=0;t<td.length;t++){
if(td[t].width == "30%" && td[t].className == "windowbg2" && td[t].innerHTML.match(/Add Tags:/) && td[t+1].width == "70%" && td[t+1].className == "windowbg2"){
td[t+1].innerHTML += ' <a href="javascript: closetags()">Close All Tags</a><br />Open Tags: <b id="otagbold">0</b>';
break;
}}
if(document.addEventListener){
document.postForm.message.addEventListener('keyup',countOpenTags,false);
document.postForm.message.addEventListener('focus',countOpenTags,false);
} else {
document.postForm.message.attachEvent('onkeyup',countOpenTags);
document.postForm.message.attachEvent('onfocus',countOpenTags);
}}
//-->
</script>