MOD Lors d'une erreur lors d'en envoie de message le message n'est plus enlevé de...
[euphorik.git] / js / euphorik.js
1 // coding: utf-8
2
3 /**
4 * Contient la base javascript pour le site euphorik.ch.
5 * Chaque page possède son propre fichier js nommé "page<nom de la page>.js".
6 * Auteur : GBurri
7 * Date : 6.11.2007
8 */
9
10 /**
11 * La configuration.
12 * Normalement 'const' à la place de 'var' mais non supporté par IE7.
13 */
14 var conf = {
15 nbMessageAffiche : 80, // (par page)
16 pseudoDefaut : "<nick>",
17 tempsAffichageMessageDialogue : 4000, // en ms
18 smiles : {
19 "smile" : [/:\)/g, /:-\)/g],
20 "bigsmile" : [/:D/g, /:-D/g],
21 "clin" : [/;\)/g, /;-\)/g],
22 "cool" : [/8\)/g, /8-\)/g],
23 "eheheh" : [/:P/g, /:-P/g],
24 "oh" : [/:o/g, /:O/g],
25 "pascontent" : [/>\(/g, /&gt;\(/g],
26 "sniff" : [/:\(/g, /:-\(/g],
27 "argn" : [/\[:argn\]/g],
28 "bunny" : [/\[:lapin\]/g],
29 "chat" : [/\[:chat\]/g],
30 "renne" : [/\[:renne\]/g],
31 "lol" : [/\[:lol\]/g],
32 "spliff" : [/\[:spliff\]/g],
33 "star" : [/\[:star\]/g],
34 "triste" : [/\[:triste\]/g],
35 "kirby" : [/\[:kirby\]/g]
36 }
37 }
38
39 ///////////////////////////////////////////////////////////////////////////////////////////////////
40
41 String.prototype.trim = function()
42 {
43 return this.replace(/^\s+|\s+$/g, "");
44 }
45
46 String.prototype.ltrim = function()
47 {
48 return this.replace(/^\s+/, "");
49 }
50
51 String.prototype.rtrim = function()
52 {
53 return this.replace(/\s+$/, "");
54 }
55
56 String.prototype.dump = function()
57 {
58 if (typeof dump != "undefined")
59 {
60 dump("\n--- EUPHORIK.CH ---\n")
61 dump(this)
62 dump("\n------\n")
63 }
64 }
65
66 ///////////////////////////////////////////////////////////////////////////////////////////////////
67
68 /**
69 * Cette classe regroupe des fonctions utilitaires (helpers).
70 */
71 function Util()
72 {
73 if(typeof XMLSerializer != "undefined")
74 this.serializer = new XMLSerializer()
75
76 // fermeture des dialogues d
77 jQuery("#info .fermer").click(function(){
78 jQuery("#info").slideUp(50)
79 })
80 }
81
82 /**
83 * Affiche une boite de dialogue avec un message à l'intérieur.
84 * @param message le message (string)
85 * @param type voir 'messageType'. par défaut messageType.informatif
86 * @param les boutons sous la forme d'un objet ou les clefs sont les labels des boutons
87 * et les valeurs les fonctions executées lorsqu'un bouton est activé.
88 */
89 Util.prototype.messageDialogue = function(message, type, boutons)
90 {
91 if (type == undefined)
92 type = messageType.informatif
93
94 if (this.timeoutMessageDialogue != undefined)
95 clearTimeout(this.timeoutMessageDialogue)
96
97 var fermer = function(){jQuery("#info").slideUp(100)}
98 fermer()
99
100 jQuery("#info .message").html(message)
101 switch(type)
102 {
103 case messageType.informatif : jQuery("#info #icone").attr("class", "information"); break
104 case messageType.question : jQuery("#info #icone").attr("class", "interrogation"); break
105 case messageType.erreur : jQuery("#info #icone").attr("class", "exclamation"); break
106 }
107 jQuery("#info .boutons").html("")
108 for (var b in boutons)
109 jQuery("#info .boutons").append("<div>" + b + "</div>").find("div:last").click(boutons[b]).click(fermer)
110
111 jQuery("#info").slideDown(200)
112 this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue)
113 }
114 var messageType = {informatif: 0, question: 1, erreur: 2}
115
116 /**
117 * Transforme un document XML en string.
118 */
119 Util.prototype.serializeXML = function(documentXML)
120 {
121 if (this.serializer)
122 return this.serializer.serializeToString(documentXML)
123 else
124 return documentXML.xml
125 }
126
127 Util.prototype.creerDocumentXMLAction = function()
128 {
129 if (document.implementation && document.implementation.createDocument)
130 {
131 // var doc = document.implementation.createDocument("", "action", null)
132 var parser = new DOMParser();
133 var doc = parser.parseFromString("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<action/>", "text/xml")
134 //alert(this.serializeXML(doc))
135 return doc
136 }
137 else if (window.ActiveXObject)
138 {
139 var doc = new ActiveXObject("MSXML2.DOMDocument") //("Microsoft.XMLDOM")
140 doc.appendChild(doc.createElement("action"));
141 //doc.loadXML("<action></action>")
142 //alert(doc.documentElement)
143 //doc.createElement("action")
144 return doc
145 }
146 }
147
148 Util.prototype.xmlVersAction = function(xml)
149 {
150 //return {action: this.to_utf8(this.serializeXML(xml /*, "UTF-8"*/))}
151 return {action: this.serializeXML(xml)}
152 }
153
154 Util.prototype.md5 = function(chaine)
155 {
156 return hex_md5(chaine)
157 }
158
159 // pompé de http://www.faqts.com/knowledge_base/view.phtml/aid/13562/fid/130
160 Util.prototype.setSelectionRange = function(input, selectionStart, selectionEnd)
161 {
162 if (input.setSelectionRange)
163 {
164 input.focus()
165 input.setSelectionRange(selectionStart, selectionEnd)
166 }
167 else if (input.createTextRange)
168 {
169 var range = input.createTextRange()
170 range.collapse(true)
171 range.moveEnd('character', selectionEnd)
172 range.moveStart('character', selectionStart)
173 range.select()
174 }
175 }
176
177 Util.prototype.setCaretToEnd = function(input)
178 {
179 this.setSelectionRange(input, input.value.length, input.value.length)
180 }
181 Util.prototype.setCaretToBegin = function(input)
182 {
183 this.setSelectionRange(input, 0, 0)
184 }
185 Util.prototype.setCaretToPos = function(input, pos)
186 {
187 this.setSelectionRange(input, pos, pos)
188 }
189 Util.prototype.selectString = function(input, string)
190 {
191 var match = new RegExp(string, "i").exec(input.value)
192 if (match)
193 {
194 this.setSelectionRange (input, match.index, match.index + match[0].length)
195 }
196 }
197 Util.prototype.replaceSelection = function(input, replaceString) {
198 if (input.setSelectionRange)
199 {
200 var selectionStart = input.selectionStart
201 var selectionEnd = input.selectionEnd
202 input.value = input.value.substring(0, selectionStart) + replaceString + input.value.substring(selectionEnd)
203
204 if (selectionStart != selectionEnd) // has there been a selection
205 this.setSelectionRange(input, selectionStart, selectionStart + replaceString.length)
206 else // set caret
207 this.setCaretToPos(input, selectionStart + replaceString.length)
208 }
209 else if (document.selection)
210 {
211 var range = document.selection.createRange();
212 if (range.parentElement() == input)
213 {
214 var isCollapsed = range.text == ''
215 range.text = replaceString
216 if (!isCollapsed)
217 {
218 // there has been a selection
219 // it appears range.select() should select the newly
220 // inserted text but that fails with IE
221 range.moveStart('character', -replaceString.length);
222 range.select();
223 }
224 }
225 }
226 }
227
228 ///////////////////////////////////////////////////////////////////////////////////////////////////
229
230 function Pages()
231 {
232 this.pageCourante = null
233 this.pages = {}
234 }
235
236 Pages.prototype.ajouterPage = function(page)
237 {
238 page.pages = this // la magie des langages dynamiques : le foutoire
239 this.pages[page.nom] = page
240 }
241
242 Pages.prototype.afficherPage = function(nomPage, forcerChargement)
243 {
244 if (forcerChargement == undefined) forcerChargement = false
245
246 var page = this.pages[nomPage]
247 if (page == undefined || (!forcerChargement && page == this.pageCourante)) return
248
249 if (this.pageCourante != null && this.pageCourante.decharger)
250 this.pageCourante.decharger()
251
252 jQuery("#menu div").removeClass("courante")
253 jQuery("#menu div." + nomPage).addClass("courante")
254
255 this.pageCourante = page
256 jQuery("#page").html(this.pageCourante.contenu()).removeClass().addClass(this.pageCourante.nom)
257
258 if (this.pageCourante.charger)
259 this.pageCourante.charger()
260 }
261
262 ///////////////////////////////////////////////////////////////////////////////////////////////////
263
264 function Formateur()
265 {
266 this.smiles = conf.smiles
267 this.protocoles = "http|https|ed2k"
268
269 this.regexUrl = new RegExp("(?:(?:" + this.protocoles + ")://|www\\.)[^ ]*", "gi")
270 this.regexImg = new RegExp("^.*?\\.(gif|jpg|png|jpeg|bmp|tiff)$", "i")
271 this.regexDomaine = new RegExp("^(?:(?:" + this.protocoles + ")://|www\\.).*?([^/.]+\\.[^/.]+)(?:$|/).*$", "i")
272 this.regexTestProtocoleExiste = new RegExp("^(?:" + this.protocoles + ")://.*$", "i")
273 this.regexNomProtocole = new RegExp("^(.*?)://")
274 }
275
276 /**
277 * Formate un pseudo saise par l'utilisateur.
278 * @param pseudo le pseudo brut
279 * @return le pseudo filtré
280 */
281 Formateur.prototype.filtrerInputPseudo = function(pseudo)
282 {
283 return pseudo.replace(/{|}/g, "").trim()
284 }
285
286 Formateur.prototype.getSmilesHTML = function()
287 {
288 var XHTML = ""
289 for (var sNom in this.smiles)
290 {
291 XHTML += "<img class=\"" + sNom + "\" src=\"img/smileys/" + sNom + ".gif\" />"
292 }
293 return XHTML
294 }
295
296 Formateur.prototype.traitementComplet = function(M, pseudo)
297 {
298 return this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo))
299 }
300
301 /**
302 * FIXME : Cette méthode est attrocement lourde !!
303 */
304 Formateur.prototype.traiterSmiles = function(M)
305 {
306 for (var sNom in this.smiles)
307 {
308 ss = this.smiles[sNom]
309 for (var i = 0; i < ss.length; i++)
310 M = M.replace(ss[i], "<img src=\"img/smileys/" + sNom + ".gif\" />")
311 }
312 return M
313 }
314
315 Formateur.prototype.remplacerBalisesHTML = function(M)
316 {
317 return M.replace(/</g, "&lt;").replace(/>/g, "&gt;")
318 }
319
320 Formateur.prototype.traiterURL = function(M, pseudo)
321 {
322 thisFormateur = this
323
324 if (pseudo == undefined)
325 pseudo = ""
326
327 var traitementUrl = function(url)
328 {
329 // si ya pas de protocole on rajoute "http://"
330 if (!thisFormateur.regexTestProtocoleExiste.test(url))
331 url = "http://" + url
332 var extension = thisFormateur.getShort(url)
333 return "<a " + (extension[1] ? "title=\"" + thisFormateur.traiterPourFenetreLightBox(pseudo, url) + ": " + thisFormateur.traiterPourFenetreLightBox(M, url) + "\"" + " rel=\"lightbox[groupe]\"" : "") + " href=\"" + url + "\" >[" + extension[0] + "]</a>"
334 }
335 return M.replace(this.regexUrl, traitementUrl)
336 }
337
338 /**
339 * Renvoie une version courte de l'url.
340 * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient wikipedia.org
341 */
342 Formateur.prototype.getShort = function(url)
343 {
344 var estUneImage = false
345 var versionShort = null
346 var rechercheImg = this.regexImg.exec(url)
347 //alert(url)
348 if (rechercheImg != null)
349 {
350 versionShort = rechercheImg[1].toLowerCase()
351 if (versionShort == "jpeg") versionShort = "jpg" // jpeg -> jpg
352 estUneImage = true
353 }
354 else
355 {
356 var rechercheDomaine = this.regexDomaine.exec(url)
357 if (rechercheDomaine != null && rechercheDomaine.length >= 2)
358 versionShort = rechercheDomaine[1]
359 else
360 {
361 var nomProtocole = this.regexNomProtocole.exec(url)
362 if (nomProtocole != null && nomProtocole.length >= 2)
363 versionShort = nomProtocole[1]
364 }
365 }
366
367 return [versionShort == null ? "url" : versionShort, estUneImage]
368 }
369
370 /**
371 * Traite les pseudo et messages à être affiché dans le titre d'une image visualisé avec lightbox.
372 */
373 Formateur.prototype.traiterPourFenetreLightBox = function(M, urlCourante)
374 {
375 thisFormateur = this
376 var traitementUrl = function(url)
377 {
378 return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? ": image courante" : "") + "]"
379 }
380
381 return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl)
382 }
383
384
385 ///////////////////////////////////////////////////////////////////////////////////////////////////
386
387 var statutType = {enregistre: 0, identifie: 1, non_identifie: 2}
388
389 function Client(util)
390 {
391 this.util = util
392
393 this.cookie = null
394 this.regexCookie = new RegExp("^cookie=([^;]*)")
395
396 // Obsolète
397 //this.captchaCrypt = null
398
399 // données personnels
400 this.resetDonneesPersonnelles()
401
402 this.setStatut(statutType.non_identifie)
403
404 // le dernier message d'erreur recut du serveur (par exemple une connexion foireuse : "login impossible")
405 this.dernierMessageErreur = ""
406 }
407
408 Client.prototype.resetDonneesPersonnelles = function()
409 {
410 this.pseudo = conf.pseudoDefaut
411 this.login = ""
412 this.password = ""
413 this.email = ""
414 this.css = jQuery("link#cssPrincipale").attr("href")
415 }
416
417 Client.prototype.setCss = function(css)
418 {
419 if (this.css == css)
420 return
421
422 this.css = css
423 jQuery("link#cssPrincipale").attr("href", this.css)
424 this.majMenu()
425
426 /* enregistement automatique..
427 if (!this.identifie())
428 if (!this.enregistrement())
429 return
430 */
431 if (this.identifie())
432 this.flush()
433 }
434
435 Client.prototype.getXMLlogin = function(login, password)
436 {
437 var XMLDocument = this.util.creerDocumentXMLAction()
438 XMLDocument.documentElement.setAttribute("name", "login")
439
440 var nodeLogin = XMLDocument.createElement("login")
441 nodeLogin.appendChild(XMLDocument.createTextNode(login))
442 XMLDocument.documentElement.appendChild(nodeLogin)
443
444 var nodePassword = XMLDocument.createElement("password")
445 nodePassword.appendChild(XMLDocument.createTextNode(password))
446 XMLDocument.documentElement.appendChild(nodePassword)
447
448 return XMLDocument
449 }
450
451 Client.prototype.getXMLloginCookie = function()
452 {
453 var XMLDocument = this.util.creerDocumentXMLAction()
454 XMLDocument.documentElement.setAttribute("name", "login")
455
456 var nodeCookie = XMLDocument.createElement("cookie")
457 nodeCookie.appendChild(XMLDocument.createTextNode(this.cookie))
458 XMLDocument.documentElement.appendChild(nodeCookie)
459
460 return XMLDocument
461 }
462
463 /* Obsolète
464 Client.prototype.getXMLloginCaptcha = function(captchaCrypt, captchaInput)
465 {
466 var XMLDocument = this.util.creerDocumentXMLAction()
467 XMLDocument.documentElement.setAttribute("name", "loginCaptcha")
468
469 var nodecaptchaCrypt = XMLDocument.createElement("captchaCrypt")
470 nodecaptchaCrypt.appendChild(XMLDocument.createTextNode(captchaCrypt))
471 XMLDocument.documentElement.appendChild(nodecaptchaCrypt)
472
473 var nodecaptchaInput = XMLDocument.createElement("captchaInput")
474 nodecaptchaInput.appendChild(XMLDocument.createTextNode(captchaInput))
475 XMLDocument.documentElement.appendChild(nodecaptchaInput)
476
477 return XMLDocument
478 }*/
479
480 /* Obsolète
481 Client.prototype.getXMLgenerationCaptcha = function()
482 {
483 var XMLDocument = this.util.creerDocumentXMLAction()
484 XMLDocument.documentElement.setAttribute("name", "generationCaptcha")
485
486 return XMLDocument
487 }*/
488
489 Client.prototype.getXMLEnregistrement = function(login, password)
490 {
491 var XMLDocument = this.util.creerDocumentXMLAction()
492 XMLDocument.documentElement.setAttribute("name", "register")
493
494 var nodeLogin = XMLDocument.createElement("login")
495 nodeLogin.appendChild(XMLDocument.createTextNode(login))
496 XMLDocument.documentElement.appendChild(nodeLogin)
497
498 var nodePassword = XMLDocument.createElement("password")
499 nodePassword.appendChild(XMLDocument.createTextNode(password))
500 XMLDocument.documentElement.appendChild(nodePassword)
501
502 return XMLDocument
503 }
504
505 Client.prototype.getXMLProfile = function()
506 {
507 var XMLDocument = this.util.creerDocumentXMLAction()
508 XMLDocument.documentElement.setAttribute("name", "profile")
509
510 var nodeCookie = XMLDocument.createElement("cookie")
511 nodeCookie.appendChild(XMLDocument.createTextNode(this.cookie))
512 XMLDocument.documentElement.appendChild(nodeCookie)
513
514 var nodeLogin = XMLDocument.createElement("login")
515 nodeLogin.appendChild(XMLDocument.createTextNode(this.login))
516 XMLDocument.documentElement.appendChild(nodeLogin)
517
518 var nodePassword = XMLDocument.createElement("password")
519 nodePassword.appendChild(XMLDocument.createTextNode(this.password))
520 XMLDocument.documentElement.appendChild(nodePassword)
521
522 var nodePseudo = XMLDocument.createElement("pseudo")
523 nodePseudo.appendChild(XMLDocument.createTextNode(this.pseudo))
524 XMLDocument.documentElement.appendChild(nodePseudo)
525
526 var nodeEmail = XMLDocument.createElement("email")
527 nodeEmail.appendChild(XMLDocument.createTextNode(this.email))
528 XMLDocument.documentElement.appendChild(nodeEmail)
529
530 var nodeCSS = XMLDocument.createElement("css")
531 nodeCSS.appendChild(XMLDocument.createTextNode(this.css))
532 XMLDocument.documentElement.appendChild(nodeCSS)
533
534 return XMLDocument
535 }
536
537 /**
538 * Renvoie null si pas définit.
539 */
540 Client.prototype.getCookie = function()
541 {
542 var cookie = this.regexCookie.exec(document.cookie)
543 if (cookie == null) this.cookie = null
544 else this.cookie = cookie[1]
545 }
546
547 Client.prototype.delCookie = function()
548 {
549 document.cookie = "cookie=; max-age=0"
550 }
551
552 Client.prototype.setCookie = function(cookie)
553 {
554 if (this.cookie == null)
555 return
556
557 document.cookie =
558 "cookie="+this.cookie+
559 "; max-age=" + (60 * 60 * 24 * 365)
560 }
561
562 Client.prototype.identifie = function()
563 {
564 return this.statut == statutType.enregistre || this.statut == statutType.identifie
565 }
566
567 Client.prototype.setStatut = function(statut)
568 {
569 if(typeof(statut) == "string")
570 {
571 statut =
572 statut == "enregistre" ?
573 statutType.enregistre : (statut == "identifie" ? statutType.identifie : statutType.non_identifie)
574 }
575
576 if (statut == this.statut) return
577
578 this.statut = statut
579 this.majMenu()
580 }
581
582 /**
583 * Demande la génération d'un captcha au serveur et l'affiche.
584 */
585 /* Obsolète
586 Client.prototype.afficherCaptcha = function(query)
587 {
588 var thisClient = this
589
590 $.post("request", this.util.xmlVersAction(this.getXMLgenerationCaptcha()),
591 function(data, textStatus)
592 {
593 var chemin = jQuery("chemin", data.documentElement).text()
594 thisClient.captchaCrypt = jQuery("captchaCrypt", data.documentElement).text()
595 jQuery(query).prepend(
596 "<p id=\"captcha\" >Es-tu un bot ? <img class=\"captchaImg\" src=\"" + chemin + "\" />" +
597 "<input name=\"captchaInput\" type=\"text\" size=\"5\" max_length=\"5\" ></p>"
598 )
599 }
600 )
601 }
602
603 Client.prototype.cacherCaptcha = function()
604 {
605 jQuery("#captcha").remove()
606 }*/
607
608 /**
609 * Effectue la connexion vers le serveur.
610 * Cette fonction est bloquante tant que la connexion n'a pas été établie.
611 * S'il existe un cookie en local on s'authentifie directement avec lui.
612 * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot.
613 */
614 Client.prototype.connexionCookie = function()
615 {
616 this.getCookie()
617 if (this.cookie == null) return false;
618 return this.connexion(this.util.xmlVersAction(this.getXMLloginCookie()))
619 }
620
621 Client.prototype.connexionLogin = function(login, password)
622 {
623 return this.connexion(this.util.xmlVersAction(this.getXMLlogin(login, password)))
624 }
625
626 /* Obsolète
627 Client.prototype.connexionCaptcha = function()
628 {
629 return this.connexion(this.util.xmlVersAction(this.getXMLloginCaptcha(this.captchaCrypt, jQuery("#captcha input").val())))
630 }*/
631
632 Client.prototype.enregistrement = function(login, password)
633 {
634 if (this.identifie())
635 {
636 this.login = login
637 this.password = password
638 if(this.flush())
639 this.setStatut(statutType.enregistre)
640 return true
641 }
642 else
643 {
644 if (login == undefined) login = ""
645 if (password == undefined) password = ""
646 return this.connexion(this.util.xmlVersAction(this.getXMLEnregistrement(login, password)))
647 }
648 }
649
650 Client.prototype.connexion = function(action)
651 {
652 thisClient = this
653 jQuery.ajax(
654 {
655 async: false,
656 type: "POST",
657 url: "request",
658 dataType: "xml",
659 data: action,
660 success:
661 function(data)
662 {
663 thisClient.chargerDonnees(data)
664 }
665 }
666 )
667 return this.identifie()
668 }
669
670 Client.prototype.deconnexion = function()
671 {
672 this.setStatut(statutType.non_identifie) // deconnexion
673 this.resetDonneesPersonnelles()
674 this.delCookie ()
675 }
676
677 Client.prototype.chargerDonnees = function(data)
678 {
679 this.setStatut(jQuery("statut", data.documentElement).text())
680
681 if (this.identifie())
682 {
683 this.cookie = jQuery("cookie", data.documentElement).text()
684 this.setCookie()
685
686 this.login = jQuery("login", data.documentElement).text()
687 this.pseudo = jQuery("pseudo", data.documentElement).text()
688 this.email = jQuery("email", data.documentElement).text()
689 this.css = jQuery("css", data.documentElement).text()
690 // met à jour la css
691 if (this.css != "")
692 {
693 jQuery("link#cssPrincipale").attr("href", this.css)
694 this.majMenu()
695 }
696 }
697 this.dernierMessageErreur = jQuery("information", data.documentElement).text()
698 }
699
700 /**
701 * Met à jour les données personne sur serveur.
702 */
703 Client.prototype.flush = function()
704 {
705 thisClient = this
706 //thisClient.util.log(this.util.xmlVersAction(this.getXMLProfile()).action)
707 jQuery.ajax(
708 {
709 async: true,
710 type: "POST",
711 url: "request",
712 dataType: "xml",
713 data: this.util.xmlVersAction(this.getXMLProfile()),
714 success:
715 function(data)
716 {
717 //thisClient.util.log(thisClient.util.serializer.serializeToString(data))
718 }
719 }
720 )
721 // TODO : retourner false si un problème est survenu lors de l'update du profile
722 return true
723 }
724
725 Client.prototype.majMenu = function()
726 {
727 var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
728
729 // met à jour le menu
730 if (this.statut == statutType.enregistre)
731 {
732 jQuery("#menu .profile").css("display", displayType).text("profile")
733 jQuery("#menu .logout").css("display", displayType)
734 jQuery("#menu .register").css("display", "none")
735 }
736 else if (this.statut == statutType.identifie)
737 {
738 jQuery("#menu .profile").css("display", "none")
739 jQuery("#menu .logout").css("display", displayType)
740 jQuery("#menu .register").css("display", displayType)
741 }
742 else
743 {
744 jQuery("#menu .profile").css("display", displayType).text("login")
745 jQuery("#menu .logout").css("display", "none")
746 jQuery("#menu .register").css("display", displayType)
747 }
748 }
749
750 ///////////////////////////////////////////////////////////////////////////////////////////////////
751
752 jQuery.noConflict()
753
754
755 // le main
756 jQuery(document).ready(
757 function()
758 {
759 /* FIXME : ce code pose problème sur konqueror, voir : http://www.kde-forum.org/thread.php?threadid=17993
760 var p = new DOMParser();
761 var doc = p.parseFromString("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<action/>", "text/xml")
762 var s = new XMLSerializer()
763 alert(s.serializeToString(doc)) */
764
765 var util = new Util()
766 var client = new Client(util)
767 var pages = new Pages()
768 var formateur = new Formateur()
769
770 // connexion vers le serveur (utilise un cookie qui traine)
771 client.connexionCookie()
772
773 // les styles css
774 for (var i = 1; i <= 3; i++)
775 {
776 jQuery("#css"+i).click(function(){
777 client.setCss("css/" + jQuery(this).attr("id").charAt(3) + "/euphorik.css")
778 })
779 }
780
781 jQuery("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
782 jQuery("#menu .profile").click(function(){ pages.afficherPage("profile") })
783 jQuery("#menu .logout").click(function(){
784 util.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", messageType.question,
785 {"Oui" : function()
786 {
787 client.deconnexion();
788 pages.afficherPage("minichat", true)
789 },
790 "Non" : function(){}
791 }
792 )
793 })
794 jQuery("#menu .register").click(function(){ pages.afficherPage("register") })
795
796 pages.ajouterPage(new PageMinichat(client, formateur, util))
797 pages.ajouterPage(new PageProfile(client, formateur, util))
798 pages.ajouterPage(new PageRegister(client, formateur, util))
799 pages.afficherPage("minichat")
800 }
801 )
802