Code:
this.wrap_tags = function(tagname, useoption, selection)
{
tagname = tagname.toUpperCase();
switch (tagname)
{
case 'CODE':
case 'HTML':
case 'PHP':
{
this.apply_format('removeformat');
}
break;
}
if (typeof selection == 'undefined')
{
selection = this.get_selection();
if (selection === false)
{
selection = '';
}
else
{
selection = new String(selection);
}
}
if (useoption === true)
{
var option = this.show_prompt(construct_phrase(vbphrase['enter_tag_option'], ('[' + tagname + ']')), '');
if (option = this.verify_prompt(option))
{
var opentag = '[' + tagname + '="' + option + '"' + ']';
}
else
{
return false;
}
}
else if (useoption !== false)
{
var opentag = '[' + tagname + '="' + useoption + '"' + ']';
}
else
{
var opentag = '[' + tagname + ']';
}
var closetag = '[/' + tagname + ']';
var text = opentag + selection + closetag;
this.insert_text(text, opentag.vBlength(), closetag.vBlength());
return false;
}; And heres the insert_text function:
Code:
this.insert_text = function(text, movestart, moveend)
{
this.check_focus();
if (typeof(this.editdoc.selection) != 'undefined' && this.editdoc.selection.type != 'Text' && this.editdoc.selection.type != 'None')
{
movestart = false;
this.editdoc.selection.clear();
}
var sel = this.editdoc.selection.createRange();
sel.pasteHTML(text);
if (text.indexOf('\n') == -1)
{
if (movestart === false)
{
// do nothing
}
else if (typeof movestart != 'undefined')
{
sel.moveStart('character', -text.vBlength() +movestart);
sel.moveEnd('character', -moveend);
}
else
{
sel.moveStart('character', -text.vBlength());
}
sel.select();
}
}; I think that is what this forum uses at the moment. I am not positive, this was what I got from a quick scan.
Of course this is vBulletin's, and it may be illegal to use, and not all those functions inside might need to be used but you can quickly search http://youngcoders.com/clientscript/...tedit.js?v=363 for it.