Nieuw lid |
|
dat gaat niet omdat alle forms nodig zijn en die worden gewijzigd.
Ik zal de gehele code even geven (gedeelte van het stukje is van phpbb)
function bbstyle(bbnumber, test) {
//alert( 'form' + test);
var txtarea = document.form+test+.msg;
donotinsert = false;
theSelection = false;
bblast = 0;
if (bbnumber == -1) { // Close all open tags & default button names
while (bbcode[0]) {
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.form' + test + '.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
//imageTag = true; // All tags are closed including image tags :D
txtarea.focus();
return;
}
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection) {
// Add tags around selection
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
txtarea.focus();
theSelection = '';
return;
}
}
else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
{
mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
return;
}
// Find last occurance of an open tag the same as the one just clicked
for (i = 0; i < bbcode.length; i++) {
if (bbcode[i] == bbnumber+1) {
bblast = i;
donotinsert = true;
}
}
if (donotinsert) { // Close all open tags up to the one just clicked & default button names
while (bbcode[bblast]) {
butnumber = arraypop(bbcode) - 1;
txtarea.value += bbtags[butnumber + 1];
buttext = eval('document.form' + test + '.addbbcode' + butnumber + '.value');
eval('document.form' + test + '.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
imageTag = false;
}
txtarea.focus();
return;
} else { // Open tags
if (imageTag && (bbnumber != 14)) { // Close image tag before adding another
txtarea.value += bbtags[15];
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.form1066.addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
}
// Open tag
txtarea.value += bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.form' + test + '.addbbcode'+bbnumber+'.value += "*"');
txtarea.focus();
return;
}
storeCaret(txtarea);
}
function bbstyle(bbnumber, test) { //alert( 'form' + test); var txtarea = document.form+test+.msg; donotinsert = false; theSelection = false; bblast = 0; if (bbnumber == -1) { // Close all open tags & default button names while (bbcode[0]) { butnumber = arraypop(bbcode) - 1; txtarea.value += bbtags[butnumber + 1]; buttext = eval('document.post.addbbcode' + butnumber + '.value'); eval('document.form' + test + '.addbbcode' + butnumber + '.value ="' + buttext .substr(0,(buttext .length - 1)) + '"'); } //imageTag = true; // All tags are closed including image tags :D txtarea.focus(); return; } if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; // Get text selection if (theSelection) { // Add tags around selection document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1]; txtarea.focus(); theSelection = ''; return; } } else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) { mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]); return; } // Find last occurance of an open tag the same as the one just clicked for (i = 0; i < bbcode.length; i++) { if (bbcode[i] == bbnumber+1) { bblast = i; donotinsert = true; } } if (donotinsert) { // Close all open tags up to the one just clicked & default button names while (bbcode[bblast]) { butnumber = arraypop(bbcode) - 1; txtarea.value += bbtags[butnumber + 1]; buttext = eval('document.form' + test + '.addbbcode' + butnumber + '.value'); eval('document.form' + test + '.addbbcode' + butnumber + '.value ="' + buttext .substr(0,(buttext .length - 1)) + '"'); imageTag = false; } txtarea.focus(); return; } else { // Open tags if (imageTag && (bbnumber != 14)) { // Close image tag before adding another txtarea.value += bbtags[15]; lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list document.form1066.addbbcode14.value = "Img"; // Return button back to normal state imageTag = false; } // Open tag txtarea.value += bbtags[bbnumber]; if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag arraypush(bbcode,bbnumber+1); eval('document.form' + test + '.addbbcode'+bbnumber +'.value += "*"'); txtarea.focus(); return; } storeCaret(txtarea); }
|