You need to hack some more files than the template to implement the hack. Each file that prints a <textarea> needs to be modified. for expample:
<textarea cols="80" rows="15" class="formboxes"
wrap="soft" name="Body" [:red] onChange=getActiveText(this) onclick=getActiveText(this)
onFocus=getActiveText(this) ></textarea>
Here comes the script we are using.
<script language="javascript"><!--
function getActiveText(selectedtext) {
text = (document.all) ? document.selection.createRange().text : document.getSelection();
if (selectedtext.createTextRange) {
selectedtext.caretPos = document.selection.createRange().duplicate();
}
return true;
}
function returnTag(tag) {
if (document.forms(0).Body.createTextRange && document.forms(0).Body.caretPos) {
var caretPos = document.forms(0).Body.caretPos;
caretPos.text = tag;
} else {
document.forms(0).Body.value+=tag;
}
document.forms(0).Body.focus();
}
function doppeltag(tag1,tag2,alt) {
if (document.forms(0).Body.createTextRange && document.forms(0).Body.caretPos) {
var caretPos = document.forms(0).Body.caretPos;
caretPos.text = tag1 + ((caretPos.text.length>0) ? caretPos.text : alt) + tag2;
} else {
document.forms(0).Body.value+=tag1+alt+tag2;
}
document.forms(0).Body.focus();
}
//--></script>
returnTag is the simple function for smileys. There is just one string to add at cursor position.
doppelTag (rename it to doubleTag if you want []/forum/images/icons/wink.gif[/] ) checks if there is a selection.
If yes, then it encloses the selection by tag1 and tag2.
If not, it prints the string specified by 'alt' enclosed by tag1 and tag2 at the cursor position.
Some examples how to call the functions:
<A HREF="javascript:returnTag('[ grin]')">...</A>
<A HREF="javascript:doppeltag('[ url]','[ /url]','link')">...</A>
<A HREF="javascript:doppeltag('[ url=',']description[ /url]','link')">...</A>
<A HREF="javascript:returnTag('[ Image]url[ /Image]')">...</A>
<A HREF="javascript:doppeltag('[ b]','[ /b]','text')">...</A>
This only works with IE. Using an other browser it will only add the smiley at the end of the textarea. (or it will do nothing at all []/forum/images/icons/wink.gif[/] )
PS: NeooeN and me are from the same board