1 2 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| function visibilite(thingId)
{
var targetElement;
targetElement = document.getElementById(thingId) ;
if (targetElement.style.display == "none")
{
targetElement.style.display = "" ;
} else {
targetElement.style.display = "none" ;
}
}
var timer=0;
var ptag=String.fromCharCode(5,6,7);
function previsualisation() {
t=document.formulaire.message.value
t=code_to_html(t)
if (document.getElementById) document.getElementById("prev_reponse").innerHTML=t
if (document.formulaire.chkb_prev_reponse.checked) timer=setTimeout(previsualisation,1)
}
function code_to_html(t) {
t=nl2khol(t)
// balise Gras <!-- on lui dis que telles balises correspondent à tels codes en HTML -->
t=deblaie(/(<\/gras\>)/g,t)
t=remplace_tag(/<gras>(.+)<\/gras>/g,'<span style="font-weight: bold;">$1</span>',t)
t=remblaie(t)
// balise Italique
t=deblaie(/(<\/italique>)/g,t)
t=remplace_tag(/<italique>(.+)<\/italique>/g,'<span style="font-style: italic;">$1</span>',t)
t=remblaie(t)
// balise Souligné
t=deblaie(/(<\/souligné>)/g,t)
t=remplace_tag(/<souligné>(.+)<\/souligné>/g,'<span style="text-decoration:underline;">$1</span>',t)
t=remblaie(t)
// balise Barré
t=deblaie(/(<\/barré>)/g,t)
t=remplace_tag(/<barré>(.+)<\/barré>/g,'<span style="text-decoration:line-through;">$1</span>',t)
t=remblaie(t)
// balise Image
t=deblaie(/(\<\/image\>)/g,t)
t=remplace_tag(/\<image\>(.+)\<\/image\>/g,'<img src="$1" />',t)
t=remblaie(t)
// balise Lien 1
t=deblaie(/(<\/url\>)/g,t)
t=remplace_tag(/<\lien>http:\/\/(.+)<\/lien>/,'<a href="$1">http://$1</a>',t)
t=remblaie(t)
// balise Lien 2
t=deblaie(/(<\/url\>)/g,t)
t=remplace_tag(/<\lien:([\s\S]*?)>(.+)<\/lien>/,'<a href="$1">$2</a>',t)
t=remblaie(t)
// balise Citation 1
t=deblaie(/(<\/quote>)/g,t)
t=remplace_tag(/<quote>(.+)<\/quote>/g,'<div style="background:white; border:1px solid #85b4e1; padding:2px; margin:10px;"><span style="display:block; font-size:10px; font-weight:bold; margin-bottom:5px; padding-bottom:2px; border-bottom:1px solid #85b4e1;">Citation :</span>$1</div>',t)
t=remblaie(t)
// balise Citation 2
t=deblaie(/(<\/quote>)/g,t)
t=remplace_tag(/<quote:([\s\S]*?)>(.+)<\/quote>/g,'<div style="background:white; border:1px solid #85b4e1; padding:2px; margin:10px;"><span style="display:block; font-size:10px; font-weight:bold; margin-bottom:5px; padding-bottom:2px; border-bottom:1px solid #85b4e1;">Citation : $1</span>$2</div>',t)
t=remblaie(t)
// smileys
t=remplace_tag(/:D:/,'<img src="styles/images/smileys/biggrin.gif" alt=":D" />',t)
t=remblaie(t)
t=unkhol(t)
t=nl2br(t)
return t
}
function deblaie(reg,t) {
textarea=new String(t);
return textarea.replace(reg,'$1\n');
}
function remblaie(t) {
textarea=new String(t);
return textarea.replace(/\n/g,'');
}
function remplace_tag(reg,rep,t) {
textarea=new String(t);
return textarea.replace(reg,rep);
}
function nl2br(t) {
textarea=new String(t);
return textarea.replace(/\n/g,'<br/>');
}
function nl2khol(t) {
textarea=new String(t);
return textarea.replace(/\n/g,ptag);
}
function unkhol(t) {
textarea=new String(t);
return textarea.replace(new RegExp(ptag,'g'),'\n');
} |