The following code inserts code at the cursor. If a selected region exists, the selected region takes effect.
1. In the vbcode. js File
The replacement function vbcode is as follows:
Copy codeThe Code is as follows:
Function vbcode (theform, vbcode, prompttext ){
If (theform. message. createTextRange & theform. message. caretPos ){
Var caretPos = theform. message. caretPos;
If (caretPos. text. length> 0)
CaretPos. text = "[" + vbcode + "]" + caretPos. text + "[/" + vbcode + "]";
Else
CaretPos. text = "[" + vbcode + "]" + "[/" + vbcode + "]";
}
Theform. message. focus ();
}
The replacement function fontformat is as follows:
Copy codeThe Code is as follows:
Function fontformat (theform, thevalue, thetype ){
If (theform. message. createTextRange & theform. message. caretPos ){
Var caretPos = theform. message. caretPos;
If (caretPos. text. length> 0)
CaretPos. text = "[" + thetype + "=" + thevalue + "]" + caretPos. text + "[/" + thetype + "]";
Else
CaretPos. text = "[" + thetype + "=" + thevalue + "]" + "[/" + thetype + "]";
}
Theform. sizeselect. selectedIndex = 0;
Theform. fontselect. selectedIndex = 0;
Theform. colorselect. selectedIndex = 0;
Theform. message. focus ();
}
Replace the smilie function with the following content:
Copy codeThe Code is as follows:
Function smilie (thesmilie ){
// Inserts smilie text
If (document. vbform. message. createTextRange & document. vbform. message. caretPos ){
Var caretPos = document. vbform. message. caretPos;
CaretPos. text = thesmilie;
}
Document. vbform. message. focus ();
}
Add the following code
Copy codeThe Code is as follows:
Function storeCaret (textEl ){
If (textEl. createTextRange)
TextEl. caretPos = document. selection. createRange (). duplicate ();
}
2. color. js File
Replace the search function insertTag with the following content:
Copy codeThe Code is as follows:
Function insertTag (MyString)
{
Bbopen =''
Bbclose = '';
If (MM_findObj ('message'). createTextRange & MM_findObj ('message'). caretPos ){
Var text = bbopen + bbclose;
Var caretPos = MM_findObj ('message'). caretPos;
If (caretPos. text. length> 0)
CaretPos. text = bbopen + caretPos. text + bbclose;
Else
CaretPos. text = text;
} Else {
MM_findObj ('message'). value + = bbopen + bbclose;
}
MM_findObj ('message'). focus ();
Return;
}
3. Modify the editpost, newthread, and newreply templates.
Search
$ Postinfo [message]
Replace
$ Postinfo [message]