Aide pour javascript : prévisualisation en direct !

Aide pour javascript : prévisualisation en direct ! - HTML/CSS - Programmation

Marsh Posté le 30-11-2005 à 13:14:29    

Bonjour, pour la version 3 de http://www.journaweb.info , je suis en train d'installer un systeme de prévisualisation en dirrect !
Mais voilà, le script que j'ai téléchargé ne prend pas en compte les smileys...
Je voudrait que par exemple, remplacer les :), par des <img src="images/smile.png">.
 
Voici le code javascript que j'ai téléchargé :

Code :
  1. // JavaScript Auteur: http://tofem.net/ressources
  2. var timer=0;
  3. var ptag=String.fromCharCode(5,6,7);
  4. function  visualisation() {
  5. t=document.formu.texte.value  // modifier si le champ de formulaire ou le formulaire ont un nom différent
  6. t=code_to_html(t)
  7. if (document.getElementById) document.getElementById("previsualisation" ).innerHTML=t
  8. if (document.formu.auto.checked) timer=setTimeout(visualisation,1000)
  9. }
  10. function automatique() {
  11. if (document.formu.auto.checked) visualisation()
  12. }
  13. function code_to_html(t) {
  14. t=nl2khol(t)
  15. // balise Gras
  16. t=deblaie(/(\[\/b\])/g,t)
  17. t=remplace_tag(/\[b\](.+)\[\/b\]/g,'<b>$1</b>',t) 
  18. t=remblaie(t)
  19. // balise Italique
  20. t=deblaie(/(\[\/i\])/g,t)
  21. t=remplace_tag(/\[i\](.+)\[\/i\]/g,'<i>$1</i>',t) 
  22. t=remblaie(t)
  23. // balise Underline
  24. t=deblaie(/(\[\/u\])/g,t)
  25. t=remplace_tag(/\[u\](.+)\[\/u\]/g,'<u>$1</u>',t) 
  26. t=remblaie(t)
  27. // balise quote
  28. t=deblaie(/(\[\/quote\])/g,t)
  29. t=remplace_tag(/\[quote\](.+)\[\/quote\]/g,'<p class="quote">$1</p>',t) 
  30. t=remblaie(t)
  31. // balise code  
  32. t=remplace_tag(/\[code\](.+)\[\/code\]/g,'<code>$1</code>',t) 
  33. // balise Img
  34. t=deblaie(/(\[\/img\])/g,t)
  35. t=remplace_tag(/\[img\](.+)\[\/img\]/g,'<img src="$1"/>',t)
  36. t=remblaie(t)
  37. // balise URL  
  38. t=remplace_tag(/\[url=([^\s<>]+)\](.+)\[\/url\]/g,'<a href="$1" target="_blank">$2</a>',t)
  39. // balise Color  
  40. t=deblaie(/(\[\/color\])/g,t)
  41. t=remplace_tag(/\[color=(#[a-fA-F0-9]{6})\](.+)\[\/color\]/g,'<font color="$1">$2</font>',t)
  42. t=remblaie(t)
  43. // balise size  
  44. t=deblaie(/(\[\/size\])/g,t)
  45. t=remplace_tag(/\[size=([+-]?[0-9])\](.+)\[\/size\]/g,'<font size="$1">$2</font>',t)
  46. t=remblaie(t)
  47. t=unkhol(t)
  48. t=nl2br(t)
  49. return t
  50. }
  51. function deblaie(reg,t) {
  52. texte=new String(t);
  53. return texte.replace(reg,'$1\n');
  54. }
  55. function remblaie(t) {
  56. texte=new String(t);
  57. return texte.replace(/\n/g,'');
  58. }
  59. function remplace_tag(reg,rep,t) {
  60. texte=new String(t);
  61. return texte.replace(reg,rep);
  62. }
  63. function nl2br(t) {
  64. texte=new String(t);
  65. return texte.replace(/\n/g,'<br/>');
  66. }
  67. function nl2khol(t) {
  68. texte=new String(t);
  69. return texte.replace(/\n/g,ptag);
  70. }
  71. function unkhol(t) {
  72. texte=new String(t);
  73. return texte.replace(new RegExp(ptag,'g'),'\n');
  74. }


 
Si quelqu'un pouvait m'indiquer l'exemple pour un seul, ça serais sumpa !  :hello:

Reply

Marsh Posté le 30-11-2005 à 13:14:29   

Reply

Marsh Posté le 30-11-2005 à 15:27:41    

On ne fait pas de support pour les scripts externes, va voir son auteur.


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box, and replicate and expand beyond their wildest dreams by throwing away the limits imposed by overbearing genetic r
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed