• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

method to use TAinsert for kerphi

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
2 posts • Page 1 of 1

Postby speedbad » Sun May 13, 2007 12:52 pm

hello kerphi, as agreed I indicate procedure to you for your next version of phpfreechat, sorry I do not have the time to make the patch. And sorry for my bad english.

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.
Last edited by speedbad on Sun May 13, 2007 12:53 pm, edited 1 time in total.
speedbad
New member
 
Posts: 1
Joined: Fri May 11, 2007 11:25 pm
Top

Postby phpfreechat » Mon Sep 10, 2007 7:33 am

speedbad,
"the insert at the cursor position" feature will be available in the next release (1.0-final).
Thank you for your idea and your code
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top


Post a reply
2 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 3 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub