Show More
@@ -0,0 +1,34 b'' | |||
|
1 | function addMarkToMsg(start, end) { | |
|
2 | var textarea = document.getElementById('id_text'); | |
|
3 | if(!textarea) return; | |
|
4 | if( document.selection ) { | |
|
5 | textarea.focus(); | |
|
6 | sel = document.selection.createRange(); | |
|
7 | sel.text = start + sel.text + end; | |
|
8 | } else if(textarea.selectionStart || textarea.selectionStart == '0') { | |
|
9 | textarea.focus(); | |
|
10 | var startPos = textarea.selectionStart; | |
|
11 | var endPos = textarea.selectionEnd; | |
|
12 | textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length ); | |
|
13 | } else { | |
|
14 | textarea.value += start + end; | |
|
15 | } | |
|
16 | return false; | |
|
17 | } | |
|
18 | ||
|
19 | function addMarkPanel() { | |
|
20 | $('.mark_btn').on('click', function() { | |
|
21 | switch($(this).attr('id')) { | |
|
22 | case "italic": | |
|
23 | return addMarkToMsg('_', '_'); | |
|
24 | case "bold": | |
|
25 | return addMarkToMsg('__', '__'); | |
|
26 | case "spoiler": | |
|
27 | return addMarkToMsg('%%', '%%'); | |
|
28 | case "comment": | |
|
29 | return addMarkToMsg('//', ''); | |
|
30 | case "quote": | |
|
31 | return addMarkToMsg('>', ''); | |
|
32 | } | |
|
33 | }); | |
|
34 | } |
General Comments 0
You need to be logged in to leave comments.
Login now