Citation :
// JavaScript Document
var textarea = window.opener.id_textarea;
var smilies = new Array(':magicien:',':colere:',':diable:',':ange:',':ninja:','>_<',':pirate:',':zorro:',':honte:',':soleil:',':\'(',':waw:','',':D','',
':p',':lol:',':euh:','',':o',':colere:','o_O','^^',':-°');
var smilies_url = new Array('magicien.png','angry.gif','diable.png','ange.png','ninja.png','pinch.png','pirate.png','zorro.png','rouge.png','soleil.png',
'pleure.png','waw.png','smile.png','heureux.png','clin.png','langue.png','rire.gif','unsure.gif','triste.png','huh.png','mechant.png',
'blink.gif','hihi.png','siffle.png');
function insere(smiley)
{
var champ = window.opener.document.getElementById(textarea);
var scroll = champ.scrollTop;
smiley = ' ' + smiley + ' ';
if (champ.curseur)
{
champ.curseur.text = smiley;
}
else if (champ.selectionStart != 'undefined' && champ.selectionEnd != 'undefined')
{
var debut = champ.value.substring(0, champ.selectionStart);
var fin = champ.value.substring(champ.selectionEnd);
champ.value = debut + smiley + fin;
champ.focus();
champ.setSelectionRange(debut.length + smiley.length, champ.value.length - fin.length);
}
else
{
champ.value += smiley;
champ.focus();
}
champ.scrollTop = scroll;
var champ = window.opener.document.getElementById(textarea);
var div_prev = window.opener.document.getElementById('prev_'+textarea);
var contenu = champ.value;
if (document.body.scrollTop)
var scroll = window.opener.document.body.scrollTop;
else
var scroll = window.opener.document.window.pageYOffset;
for (i=0;i<smilies.length;i++)
contenu = remplace(contenu, smilies[i], '<img src="images/smilies/'+smilies_url[i]+'" alt="" title="" />');
div_prev.innerHTML = contenu;
if (window.opener.document.getElementById('prev_ancre_suivi'))
window.opener.document.getElementById('prev_ancre_suivi').focus();
window.opener.document.getElementById(textarea).focus();
}
function remplace(data, search, replace)
{
var temp = data;
var longueur = search.length;
while (temp.indexOf(search) > -1)
{
pos= temp.indexOf(search);
temp = (temp.substring(0, pos) + replace + temp.substring((pos + longueur), temp.length));
}
return temp;
}
|