| 1 |
sysadm |
1.1 |
function text_process(textArea, t_begin, t_end)
|
| 2 |
|
|
{
|
| 3 |
|
|
// Obtain the index of the first selected character
|
| 4 |
|
|
var start = textArea.selectionStart;
|
| 5 |
|
|
// Obtain the index of the last selected character
|
| 6 |
|
|
var finish = textArea.selectionEnd;
|
| 7 |
|
|
// Obtain the selected text
|
| 8 |
|
|
var ch_text = t_begin + textArea.value.substring(start, finish) + t_end;
|
| 9 |
|
|
// Update textArea
|
| 10 |
|
|
textArea.value = textArea.value.substring(0, start) + ch_text + textArea.value.substring(finish + 1);
|
| 11 |
|
|
}
|
| 12 |
|
|
|
| 13 |
|
|
function b_bold(textArea)
|
| 14 |
|
|
{
|
| 15 |
|
|
text_process(textArea, "[b]", "[/b]");
|
| 16 |
|
|
}
|
| 17 |
|
|
|
| 18 |
|
|
function b_italic(textArea)
|
| 19 |
|
|
{
|
| 20 |
|
|
text_process(textArea, "[i]", "[/i]");
|
| 21 |
|
|
}
|
| 22 |
|
|
|
| 23 |
|
|
function b_underline(textArea)
|
| 24 |
|
|
{
|
| 25 |
|
|
text_process(textArea, "[u]", "[/u]");
|
| 26 |
|
|
}
|
| 27 |
|
|
|
| 28 |
|
|
function b_size(textArea)
|
| 29 |
|
|
{
|
| 30 |
|
|
var arg = prompt("请输入希望设置的字体大小:","");
|
| 31 |
|
|
if (arg != "" && arg != null)
|
| 32 |
|
|
{
|
| 33 |
|
|
text_process(textArea, "[size " + arg + "]", "[/size]");
|
| 34 |
|
|
}
|
| 35 |
|
|
}
|
| 36 |
|
|
|
| 37 |
|
|
function b_color(textArea)
|
| 38 |
|
|
{
|
| 39 |
|
|
var arg = prompt("请输入希望设置的字体颜色:", "");
|
| 40 |
|
|
if (arg != "" && arg != null)
|
| 41 |
|
|
{
|
| 42 |
|
|
text_process(textArea, "[color " + arg + "]", "[/color]");
|
| 43 |
|
|
}
|
| 44 |
|
|
}
|
| 45 |
|
|
|
| 46 |
|
|
function b_link(textArea)
|
| 47 |
|
|
{
|
| 48 |
|
|
var arg1 = prompt("请输入希望链接的URL:", "http://");
|
| 49 |
|
|
if (arg1 != "" && arg1 != null)
|
| 50 |
|
|
{
|
| 51 |
|
|
var arg2 = prompt("请输入希望链接的名称:", arg1);
|
| 52 |
|
|
if (arg2 !="" && arg2 != null)
|
| 53 |
|
|
text_process(textArea, "", "[link " + arg1 + "]" + arg2 + "[/link]");
|
| 54 |
|
|
}
|
| 55 |
|
|
}
|
| 56 |
|
|
|
| 57 |
|
|
function b_article(textArea)
|
| 58 |
|
|
{
|
| 59 |
|
|
var arg1 = prompt("请输入希望链接的主题文章编号:","");
|
| 60 |
|
|
if (arg1 != "" && arg1 != null)
|
| 61 |
|
|
{
|
| 62 |
|
|
var arg2 = prompt("请输入希望链接的名称:", arg1);
|
| 63 |
|
|
if (arg2 !="" && arg2 != null)
|
| 64 |
|
|
text_process(textArea, "", "[article " + arg1 + "]" + arg2 + "[/article]");
|
| 65 |
|
|
}
|
| 66 |
|
|
}
|
| 67 |
|
|
|
| 68 |
|
|
function b_email(textArea)
|
| 69 |
|
|
{
|
| 70 |
|
|
var arg = prompt("请输入希望发送的邮件地址:","@");
|
| 71 |
|
|
if (arg != "" && arg != null)
|
| 72 |
|
|
{
|
| 73 |
|
|
text_process(textArea, "", "[email " + arg + "]" + arg + "[/email]");
|
| 74 |
|
|
}
|
| 75 |
|
|
}
|
| 76 |
|
|
|
| 77 |
|
|
function b_image(textArea)
|
| 78 |
|
|
{
|
| 79 |
|
|
var arg = prompt("请输入希望插入的图片的URL:","http://");
|
| 80 |
|
|
if (arg != "" && arg != null)
|
| 81 |
|
|
{
|
| 82 |
|
|
text_process(textArea, "", "[image " + arg + "]");
|
| 83 |
|
|
}
|
| 84 |
|
|
}
|
| 85 |
|
|
|
| 86 |
|
|
function b_marquee(textArea)
|
| 87 |
|
|
{
|
| 88 |
|
|
var arg = prompt("请输入滚动字幕的参数:","");
|
| 89 |
|
|
if (arg !="" && arg != null)
|
| 90 |
|
|
{
|
| 91 |
|
|
text_process(textArea, "[marquee " + arg + "]", "[/marquee]");
|
| 92 |
|
|
}
|
| 93 |
|
|
}
|
| 94 |
|
|
|
| 95 |
|
|
function b_left(textArea)
|
| 96 |
|
|
{
|
| 97 |
|
|
text_process(textArea, "", "[left]");
|
| 98 |
|
|
}
|
| 99 |
|
|
|
| 100 |
|
|
function b_right(textArea)
|
| 101 |
|
|
{
|
| 102 |
|
|
text_process(textArea, "", "[right]");
|
| 103 |
|
|
}
|