it's for put the smiley and text form where you want when you click on the corresponding image .
that puts the code corresponding to the image on which you have click on the left and on the right of the position of the cursor when it is in the area of text.
the first argument of the function will be put on the left, the second on the right.
the second argument is not obligatory.
function TAinsert(text1,text2)
{
var ta = document.getElementById('pfc_words');
if (document.selection)
{ // IE
var str = document.selection.createRange().text;
ta.focus();
var sel = document.selection.createRange();
if (text2!="")
{
if (str=="")
{
var instances = countInstances(text1,text2);
if (instances%2 != 0){ sel.text = sel.text + text2;}
else{ sel.text = sel.text + text1;}
}
else
{
sel.text = text1 + sel.text + text2;
}
}
else
{
sel.text = sel.text + text1;
}
}
else if (ta.selectionStart | ta.selectionStart == 0)
{ // Mozilla
if (ta.selectionEnd > ta.value.length) { ta.selectionEnd = ta.value.length; }
var firstPos = ta.selectionStart;
var secondPos = ta.selectionEnd+text1.length;
ta.value=ta.value.slice(0,firstPos)+text1+ta.value.slice(firstPos);
ta.value=ta.value.slice(0,secondPos)+text2+ta.value.slice(secondPos);
ta.selectionStart = firstPos+text1.length;
ta.selectionEnd = secondPos;
ta.focus();
}
else
{ // Autres
var sel = document.contenu.texte;
var instances = countInstances(text1,text2);
if (instances%2 != 0 && text2 != ""){ sel.value = sel.value + text2; }
else{ sel.value = sel.value + text1; }
}
}
your image smiley (not second argument):
<a href="javascript:TAinsert('{r2}','')"><img border="0" src="modules/chatbox/smiles/r2.gif" alt="r2" title="r2" /></a>
your text form:
<a href="javascript:TAinsert('{i}','{/i}')"><img border="0" src="modules/chatbox/form/i.gif" alt="italique" title="italique" /></a>
and it's finish , your parser will make the remainder, not need to modify it.