1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
function substr_count(str, ssstr)
{
num = 0;
while(str.indexOf(ssstr) != -1)
{
str = str.substr(str.indexOf(ssstr) + ssstr.length, str.length - (str.indexOf(ssstr)+ssstr.length));
num++;
}
return num;
}
function BBcode_close_" . $BBtext . "()
{
texte=document.formulaire." . $BBtext . ".value;
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote','[/quote]','[code]','[/code]','[li]','[/li]','[img','[/img]','[url','[/url]','[email]','[/email]','[center]','[/center]','[flash','[/flash]','[color','[/color]','[font','[/font]','[size','[/size]','[align','[/align]');
size= bbtags.length;
for (var i =0; i < size; i+=2)
{
nb_open=substr_count(texte, bbtags[i]);
nb_close=substr_count(texte, bbtags[i+1]);
if (nb_open>nb_close)
{
for (var z =nb_open; z > nb_close; z--)
{
texte+=bbtags[i+1];
}
}
if (nb_open<nb_close)
{
for (var a =nb_open; a < nb_close; a++)
{
texte=bbtags[i]+texte;
}
}
}
document.formulaire." . $BBtext . ".value=texte;
} |
Partager