Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
 
<!--
function insertion(repdeb, repfin) {
  var input = document.forms['createNews'].elements['contenuNews'];
  input.focus();
  /* pour l'Explorer Internet */
  if(typeof document.selection != 'undefined') {
    /* Insertion du code de formatage */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;
    /* Ajustement de la position du curseur */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -repfin.length);
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
  /* pour navigateurs plus récents basés sur Gecko*/
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* pour les autres navigateurs */
  else
  {
    /* requête de la position d'insertion */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Insertion du code de formatage */
    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}
 
 
 
function url_img()
{
	var lien=prompt('Veuillez renseigner l\'URL de l\'image :','');
	insertion('[img]'+lien+'','[/img]');
}
 
function url()
{
	var lien=prompt('Veuillez renseigner l\'URL de l\'image :','');
	insertion('[lien='+lien+']','[/lien]');
}	
 
 
function listapuce()
{
insertion('[ul]\n','[/ul]');
var n=1;
var a=0;
var liste;
	while(a==0)
	{
		liste=prompt('Element n°'+n);
		if(liste==""||liste==null)
		{
			a++;
		}
 
		else
		{
			n++;
			insertion('[li]'+liste+'[/li]\n','');
		}
	}
 
}
 
 
 
 
 
 
 
 
 
var timer=0;
var ptag=String.fromCharCode(5,6,7);
function  previsualisation() {
titre=document.getElementById('titreNews').value
t=document.getElementById('contenuNews').value 
t=code_to_html(t)
if (document.getElementById) document.getElementById("prev").innerHTML=t; document.getElementById("titrePrev").innerHTML=titre;
if (document.getElementById('auto').checked) timer=setTimeout(previsualisation,1)
<!-- le "1" est le temps que met le texte à s'afficher, "1" : le texte s'affichera en même temps que l'on écrit (en s) -->
}
function automatique() {
if (document.getElementById('auto').checked) previsualisation() <!-- si on a cocher la case d'aperçu automatique -->
}
function code_to_html(t) {
t=nl2khol(t)
// balise Gras <!-- on lui dis que telles balises correspondent à tels codes en HTML -->
t=deblaie(/(\[\/b\])/g,t)
t=remplace_tag(/\[b\](.+)\[\/b\]/g,'<span style="font-weight: bold;">$1</span>',t) 
t=remblaie(t)
 
// balise Italic
t=deblaie(/(\[\/i\])/g,t)
t=remplace_tag(/\[i\](.+)\[\/i\]/g,'<span style="font-style: italic;">$1</span>',t) 
t=remblaie(t)
 
 
//balise souligne
t=deblaie(/(\[\/u\])/g,t)
t=remplace_tag(/\[u\](.+)\[\/u\]/g,'<span style="text-decoration: underline;">$1</span>',t) 
t=remblaie(t)
 
 
// balise barre
t=deblaie(/(\[\/barre\])/g,t)
t=remplace_tag(/\[barre\](.+)\[\/barre\]/g,'<span style="text-decoration: line-through;">$1</span>',t) 
t=remblaie(t)
 
 
 
// balise clignotant
t=deblaie(/(\[\/blink\])/g,t)
t=remplace_tag(/\[blink\](.+)\[\/blink\]/g,'<span style="text-decoration: blink;">$1</span>',t) 
t=remblaie(t)
 
 
 
 
// balise Citation
t=deblaie(/(\[\/quote\])/g,t)
t=remplace_tag(/\[quote=([\s\S]*?)\](.+)\[\/quote\]/g,'<div style="margin-left: 50px;"><strong style="color: green;"><font color="red">$1</font> a dit:</strong><div style="padding: 4px;color: rgb(244,98,0);border: #0487bb 1px solid; width: 55%; font-family: Verdana, \'Trebuchet MS\', Tahoma, \'Times New Roman\', Times, serif; text-align: left; font-size: 12px;background-color: #ece9d8;" align="center">$2</div></div>',t) 
t=remblaie(t)
 
 
 
 
// balise couleur
t=deblaie(/(\[\/color\])/g,t)
t=remplace_tag(/\[color=([\s\S]*?)\](.+)\[\/color\]/g,'<font style="color: $1;">$2</font>',t) 
t=remblaie(t)
 
 
 
// balise Image
t=deblaie(/(\[\/img\])/g,t)
t=remplace_tag(/\[img\](.+)\[\/img\]/g,'<img src="$1" alt=""/>',t)
t=remblaie(t)
 
 
// balise ul
t=deblaie(/(\[\/ul\])/g,t)
t=remplace_tag(/\[ul\](.+)\[\/ul\]/g,'<ul>$1</ul>',t) 
t=remblaie(t)
 
 
// balise li
t=deblaie(/(\[\/li\])/g,t)
t=remplace_tag(/\[li\](.+)\[\/li\]/g,'<li>$1</li>',t) 
t=remblaie(t)
 
 
 
// balise URL   
t=deblaie(/(\[\/lien\])/g,t)
t=remplace_tag(/\[\lien=([\s\S]*?)\](.+)\[\/lien\]/g,'<a href="$1">$2</a>',t)
t=remblaie(t)
 
 
// balise align( left)    
t=deblaie(/(\[\/align\])/g,t)
t=remplace_tag(/\[\align=left\](.+)\[\/align\]/g,'<div style="text-align: left;">$1</div>',t)
t=remblaie(t)
 
 
 
 
// balise align( center)    
t=deblaie(/(\[\/align\])/g,t)
t=remplace_tag(/\[\align=center\](.+)\[\/align\]/g,'<div style="text-align: center;">$1</div>',t)
t=remblaie(t)
 
 
 
 
// balise align( right)    
t=deblaie(/(\[\/align\])/g,t)
t=remplace_tag(/\[\align=right\](.+)\[\/align\]/g,'<div style="text-align: right;">$1</div>',t)
t=remblaie(t)
 
 
 
 
 
// balise police  verdana  
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=verdana\](.+)\[\/police\]/g,'<span style="font-family: verdana;">$1</span>',t) 
t=remblaie(t)
 
 
 
 
 
// balise police   tahoma
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=tahoma\](.+)\[\/police\]/g,'<span style="font-family: tahoma;">$1</span>',t) 
t=remblaie(t)
 
 
 
 
 
// balise police   impact
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=impact\](.+)\[\/police\]/g,'<span style="font-family: impact;">$1</span>',t) 
t=remblaie(t)
 
 
 
 
 
// balise police   arial
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=arial\](.+)\[\/police\]/g,'<span style="font-family: arial;">$1</span>',t) 
t=remblaie(t)
 
 
 
 
// balise police   comic sans ms
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=comic sans ms\](.+)\[\/police\]/g,'<span style="font-family: \'comic sans ms\';">$1</span>',t) 
t=remblaie(t)
 
 
 
 
// balise police   arial black
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=arial black\](.+)\[\/police\]/g,'<span style="font-family: \'arial black\';">$1</span>',t) 
t=remblaie(t)
 
 
 
 
// balise police   TNRoman
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=times new roman\](.+)\[\/police\]/g,'<span style="font-family: \'times new roman\';">$1</span>',t) 
t=remblaie(t)
 
 
 
 
// balise police   courier new
t=deblaie(/(\[\/police\])/g,t)
t=remplace_tag(/\[police=courier new\](.+)\[\/police\]/g,'<span style="font-family: \'courier new\';">$1</span>',t) 
t=remblaie(t)
 
 
 
 
// balise taille de police
t=deblaie(/(\[\/h1\])/g,t)
t=remplace_tag(/\[h1\](.+)\[\/h1\]/g,'<h1 style="font-weight: normal;">$1</h1>',t) 
t=remblaie(t)
 
 
// balise taille de police
t=deblaie(/(\[\/h2\])/g,t)
t=remplace_tag(/\[h2\](.+)\[\/h2\]/g,'<h2 style="font-weight: normal;">$1</h2>',t) 
t=remblaie(t)
 
 
// balise taille de police
t=deblaie(/(\[\/h3\])/g,t)
t=remplace_tag(/\[h3\](.+)\[\/h3\]/g,'<h3 style="font-weight: normal;">$1</h3>',t) 
t=remblaie(t)
 
 
// balise taille de police
t=deblaie(/(\[\/h4\])/g,t)
t=remplace_tag(/\[h4\](.+)\[\/h4\]/g,'<h4 style="font-weight: normal;">$1</h4>',t) 
t=remblaie(t)
 
 
// balise taille de police
t=deblaie(/(\[\/h5\])/g,t)
t=remplace_tag(/\[h5\](.+)\[\/h5\]/g,'<h5 style="font-weight: normal;">$1</h5>',t) 
t=remblaie(t)
 
 
// balise taille de police
t=deblaie(/(\[\/h6\])/g,t)
t=remplace_tag(/\[h6\](.+)\[\/h6\]/g,'<h6 style="font-weight: normal;">$1</h6>',t) 
t=remblaie(t)
 
 
// smilies Smile <!-- on oublie pas les smilies -->
t=remplace_tag(/:blabla:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/blabla.gif" alt="" />',t) 
t=remblaie(t)
 
t=remplace_tag(/:cry:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/cry.gif" alt="" />',t) 
t=remblaie(t)
 
t=remplace_tag(/:cry2:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/cry2.gif" alt="" />',t) 
t=remblaie(t)
 
t=remplace_tag(/:fuck:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/fuck.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:bg:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/groupie.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:D/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/lol.GIF" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:)/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/sourire.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:disput:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/dispute.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:huh:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/huh.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:hum:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/hum.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:langue:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/langue.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:love:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/love.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:love2:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/love2.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:mur:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/mur.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:think:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/reflexion.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:roll:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/roll.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:rolleyes:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/rolleyes.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:sad:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/sad.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:sad2:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/sad2.GIF" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:sex:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/sex.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:bigtouf:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/bigtouff.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:bipbip:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/hiphiphip.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:papi:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/papi.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:sleep:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/sleep.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:banane:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/banane.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:mdr:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/mdr.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:DD/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/lool.png" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:zen:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/zen.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:awe:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/awe.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=remplace_tag(/:gum:/g,'<img src="http://audipartoch.free-h.net/admin/news/smileys/gum.gif" alt="" />',t) 
t=remblaie(t)
 
 
t=unkhol(t)
t=nl2br(t)
return t
}
<!-- tout le code qui suit c'est pour transformer toutes les balises, comme les preg_replace en PHP -->
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');
}
Salut !
Voici un code qui marchait hier, mais plus aujourd'hui...je n'y ai pourtant pas touché donc d'où peut provenir le problème ?
Là je vois pas et ça m'énerve un peu car un code qui marche un jour et pas l'autre c'est complètement débile
merci

En fait j'ai un fichier javascript avec toute les fonction or apparement, certaines sont executées et d'autre pas !