1<script type="text/javascript"> 2 function resizeBoxId(obj,size) { 3 var arows = document.getElementById(obj).rows; 4 document.getElementById(obj).rows = arows + size; 5 } 6 function doHLine(tag1,obj) 7 { textarea = document.getElementById(obj); 8 if (document.selection) 9 { // Code for IE 10 textarea.focus(); 11 var sel = document.selection.createRange(); 12 sel.text = tag1 + sel.text; 13 } 14 else 15 { // Code for Mozilla Firefox 16 var len = textarea.value.length; 17 var start = textarea.selectionStart; 18 var end = textarea.selectionEnd; 19 20 var scrollTop = textarea.scrollTop; 21 var scrollLeft = textarea.scrollLeft; 22 23 var sel = textarea.value.substring(start, end); 24 var rep = tag1 + sel; 25 textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); 26 27 textarea.scrollTop = scrollTop; 28 textarea.scrollLeft = scrollLeft; 29 } 30 } 31 function doLink(tag1,tag2,obj) 32 { var sel; 33 textarea = document.getElementById(obj); 34 var url = prompt('Enter the URL:','http://'); 35 var scrollTop = textarea.scrollTop; 36 var scrollLeft = textarea.scrollLeft; 37 38 if (url != '' && url != null) 39 { if (document.selection) 40 { textarea.focus(); 41 var sel = document.selection.createRange(); 42 43 if(sel.text=='') { sel.text = '<a href=\"' + url + '\">' + url + '</a>'; } 44 else { sel.text = '<a href=\"' + url + '\">' + sel.text + '</a>'; } 45 } 46 else 47 { var len = textarea.value.length; 48 var start = textarea.selectionStart; 49 var end = textarea.selectionEnd; 50 var sel = textarea.value.substring(start, end); 51 52 if(sel==''){ sel=url; } 53 else { var sel = textarea.value.substring(start, end); } 54 55 var rep = '<a href=\"' + url + '\">' + sel + '</a>'; 56 textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); 57 textarea.scrollTop = scrollTop; 58 textarea.scrollLeft = scrollLeft; 59 } 60 } 61 } 62 function doAddTags(tag1,tag2,obj) 63 { textarea = document.getElementById(obj); 64 // Code for IE 65 if (document.selection) 66 { textarea.focus(); 67 var sel = document.selection.createRange(); 68 sel.text = tag1 + sel.text + tag2; 69 } 70 else 71 { // Code for Mozilla Firefox 72 var len = textarea.value.length; 73 var start = textarea.selectionStart; 74 var end = textarea.selectionEnd; 75 76 var scrollTop = textarea.scrollTop; 77 var scrollLeft = textarea.scrollLeft; 78 79 var sel = textarea.value.substring(start, end); 80 var rep = tag1 + sel + tag2; 81 textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); 82 83 textarea.scrollTop = scrollTop; 84 textarea.scrollLeft = scrollLeft; 85 } 86 } 87 88 function doList(tag1,tag2,obj) 89 { 90 textarea = document.getElementById(obj); 91 92 if (document.selection) 93 { // Code for IE 94 textarea.focus(); 95 var sel = document.selection.createRange(); 96 var list = sel.text.split("\n"); 97 98 for(i=0;i<list.length;i++) 99 { 100 list[i] = "[li]" + list[i] + "[/li]"; 101 } 102 sel.text = tag1 + "\n" + list.join("\n") + "\n" + tag2; 103 } 104 else 105 { // Code for Firefox 106 var len = textarea.value.length; 107 var start = textarea.selectionStart; 108 var end = textarea.selectionEnd; 109 var i; 110 111 var scrollTop = textarea.scrollTop; 112 var scrollLeft = textarea.scrollLeft; 113 114 var sel = textarea.value.substring(start, end); 115 var list = sel.split("\n"); 116 117 for(i=0;i<list.length;i++) 118 { list[i] = "[li]" + list[i] + "[/li]"; } 119 120 var rep = tag1 + "\n" + list.join("\n") + "\n" +tag2; 121 textarea.value = textarea.value.substring(0,start) + rep + textarea.value.substring(end,len); 122 123 textarea.scrollTop = scrollTop; 124 textarea.scrollLeft = scrollLeft; 125 } 126 } 127 </script>