Edit a post

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.