| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 
 | <script language="JavaScript"> 
<?php 
 
 
function smiley(smiley,liste) 
{ 
 
var textarea = document.getElementById('liste'); //permet de désigner la liste en question 
var texta_valu = textarea.value; 
/* pour l'Explorer Internet */ 
 
if (typeof document.selection != 'undefined') //Pour IE 
{ 
textarea.focus(); 
/* Insertion du code de formatage */ 
 
var range = document.selection.createRange(); 
var selection = range.text; 
 
if (selection.length > 0) //Si on a sélectionné du texte 
range.text = smiley + selection + smiley; 
else //Si on a pas sélectionné de texte 
range.text = smiley; 
 
} //Fin du code pour IE 
 
else //Si on utilise un navigateur plus récent 
{ 
var ff_pos_selection_deb = textarea.selectionStart; //Retourne la position de départ su texte sélectionné 
var ff_pos_selection_fin = textarea.selectionEnd; //Retourne la position de fin du texte sélectionné 
var ff_size_text = textarea.value.length; 
 
var ff_string_deb = texta_valu.substring(0 , ff_pos_selection_deb); 
var ff_selection = texta_valu.substring(ff_pos_selection_deb ,ff_pos_selection_fin); 
var ff_string_fin = texta_valu.substring(ff_pos_selection_fin , ff_size_text); 
 
 
 
if (ff_selection.length > 0) //Si on a sélectionné du texte 
textarea.value = ff_string_deb + smiley + ff_selection + smiley + ff_string_fin; 
else //Si on a rien sélectionné 
textarea.value = ff_string_deb + smiley + ff_selection + ff_string_fin; 
 
var length_focus = ff_string_deb.length + smiley.length; 
 
//Ces trois lignes sont pour repositionner le focus à la suite du bbcode entrez: 
textarea.selectionStart = length_focus; 
textarea.selectionEnd = length_focus; 
textarea.focus(); 
}//Fin de si on utilise un navigateur type mozilla 
} 
 
?> 
</script> | 
Partager