2 // Copyright 2008 Grégory Burri
4 // This file is part of Euphorik.
6 // Euphorik is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // Euphorik is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
20 * Contient la base javascript pour le site euphorik.ch.
21 * Chaque page possède son propre fichier js nommé "page<nom de la page>.js".
26 // tout euphorik est contenu dans cet objet
28 // ;; euphorik.include =
29 // ;; euphorik.include = function(f) { var s = document.createElement('script'); s.type = 'text/javascript'; s.src = "js/" + f + ".js"; document.getElementsByTagName('head')[0].appendChild(s); }
32 // version jQuery : function(f) { jQuery.ajax({async : false, url : "js/" + f + ".js", dataType : "script"}) }
33 // mais comme il n'est pas encore chargé...
34 ;; euphorik
.include = function(f
) {
35 ;; var req
, url
= 'js/' + f
+ '.js'
36 ;; if (window
.XMLHttpRequest
) {
37 ;; req
= new XMLHttpRequest(); req
.open("GET", url
, false /* async */); req
.send(null);
38 ;; } else if (window
.ActiveXObject
) {
39 ;; req
= new ActiveXObject((navigator
.userAgent
.toLowerCase().indexOf('msie 5') != -1) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
40 ;; if (req
) { req
.open("GET", url
, false); req
.send(); }
42 ;; if (req
!==false) { if (req
.status
==200) { window
.eval(req
.responseText
); } else if (req
.status
==404) { alert("erreur de chargement (404) de : " + url
) } }
45 ;; euphorik
.include("jquery")
46 ;; euphorik
.include("jquery.lightbox")
47 ;; euphorik
.include("md5")
48 ;; euphorik
.include("json2")
50 ;; euphorik
.include("conf")
51 ;; euphorik
.include("util")
53 ;; euphorik
.include("pageMinichat")
54 ;; euphorik
.include("pageAdmin")
55 ;; euphorik
.include("pageProfile")
56 ;; euphorik
.include("pageRegister")
57 ;; euphorik
.include("pageAbout")
60 // tout un tas d'améliorations des objets javascript ;)
62 * Pour chaque propriété de l'objet execute f(p, v) ou p est le nom de la propriété et v sa valeur.
63 * Ne parcours pas les propriétés des prototypes.
65 object
.prototype.each = function(f
) {
66 for (var b
in boutons
) {
67 if (boutons
.hasOwnProperty(b
)) {
73 String
.prototype.trim = function() {
74 return jQuery
.trim(this) // anciennement : this.replace(/^\s+|\s+$/g, "");
77 String
.prototype.ltrim = function() {
78 return this.replace(/^\s+/, "");
81 String
.prototype.rtrim = function() {
82 return this.replace(/\s+$/, "");
86 ///////////////////////////////////////////////////////////////////////////////////////////////////
90 this.pageCourante
= null
95 * Accepte soit un objet soit un string.
96 * un string correspond au nom de la page, par exemple : "page" -> "page.html"
98 Pages
.prototype.ajouterPage = function(page
)
100 if (typeof page
== "string")
102 this.pages
[page
] = page
106 page
.pages
= this // la magie des langages dynamiques : le foutoire
107 this.pages
[page
.nom
] = page
111 Pages
.prototype.afficherPage = function(nomPage
, forcerChargement
)
113 if (forcerChargement
== undefined) forcerChargement
= false
115 var page
= this.pages
[nomPage
]
116 if (page
== undefined || (!forcerChargement
&& page
== this.pageCourante
)) return
118 if (this.pageCourante
!= null && this.pageCourante
.decharger
)
119 this.pageCourante
.decharger()
121 $("#menu li").removeClass("courante")
122 $("#menu li." + nomPage
).addClass("courante")
124 this.pageCourante
= page
126 if (typeof page
== "string")
127 $.ajax({async: false, url: "pages/" + page
+ ".html", success : function(page
) { contenu
+= page
}})
130 contenu
+= this.pageCourante
.contenu()
132 $("#page").html(contenu
).removeClass().addClass(this.pageCourante
.nom
+
133 (this.pageCourante
.classes
!= undefined ? " " + this.pageCourante
.classes() : "") // l'objet peut fournire des classes css supplémentaires sous la forme d'un string
136 if (this.pageCourante
.charger
)
137 this.pageCourante
.charger()
140 ///////////////////////////////////////////////////////////////////////////////////////////////////
143 * Classe permettant de formater du texte par exemple pour la substitution des liens dans les
144 * message par "[url]".
145 * TODO : améliorer l'efficacité des méthods notamment lié au smiles.
149 this.smiles
= euphorik
.conf
.smiles
150 this.protocoles
= "http|https|ed2k"
152 this.regexUrl
= new RegExp("(?:(?:" + this.protocoles
+ ")://|www\\.)[^ ]*", "gi")
153 this.regexImg
= new RegExp("^.*?\\.(gif|jpg|png|jpeg|bmp|tiff)$", "i")
154 this.regexDomaine
= new RegExp("^(?:(?:" + this.protocoles
+ ")://|www\\.).*?([^/.]+\\.[^/.]+)(?:$|/).*$", "i")
155 this.regexTestProtocoleExiste
= new RegExp("^(?:" + this.protocoles
+ ")://.*$", "i")
156 this.regexNomProtocole
= new RegExp("^(.*?)://")
160 * Formate un pseudo saise par l'utilisateur.
161 * @param pseudo le pseudo brut
162 * @return le pseudo filtré
164 Formateur
.prototype.filtrerInputPseudo = function(pseudo
)
166 return pseudo
.replace(/{|}/g, "").trim()
169 Formateur
.prototype.getSmilesHTML = function()
172 for (var sNom
in this.smiles
)
174 XHTML
+= "<img class=\"" + sNom
+ "\" src=\"img/smileys/" + sNom
+ ".gif\" alt =\"" + sNom
+ "\" />"
180 * Formatage complet d'un texte.
182 * @pseudo facultatif, permet de contruire le label des images sous la forme : "<Pseudo> : <Message>"
184 Formateur
.prototype.traitementComplet = function(M
, pseudo
)
186 return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.traiterWikiSyntaxe(this.remplacerBalisesHTML(M
)), pseudo
)))
190 * Transforme les liens en entités clickables.
191 * Un lien vers une conversation permet d'ouvrire celle ci, elle se marque comme ceci dans un message :
192 * "{5F}" ou 5F est la racine de la conversation.
193 * Ce lien sera transformer en <span class="lienConv">{5F}</span> pouvant être clické pour créer la conv 5F.
195 Formateur
.prototype.traiterLiensConv = function(M
)
201 return "<span class=\"lienConv\">" + lien
+ "</span>"
207 * FIXME : Cette méthode est attrocement lourde ! A optimiser.
208 * moyenne sur échantillon : 234ms
210 Formateur
.prototype.traiterSmiles = function(M
)
212 for (var sNom
in this.smiles
)
214 var ss
= this.smiles
[sNom
]
215 for (var i
= 0; i
< ss
.length
; i
++)
216 M
= M
.replace(ss
[i
], "<img src=\"img/smileys/" + sNom
+ ".gif\" alt =\"" + sNom
+ "\" />")
221 Formateur
.prototype.remplacerBalisesHTML = function(M
)
223 return M
.replace(/</g
, "<").replace(/>/g
, ">").replace(/"/g, ""
;")
226 Formateur.prototype.traiterURL = function(M, pseudo)
228 var thisFormateur = this
230 var traitementUrl = function(url)
232 // si ya pas de protocole on rajoute "http://"
233 if (!thisFormateur
.regexTestProtocoleExiste
.test(url
))
234 url
= "http://" + url
235 var extension
= thisFormateur
.getShort(url
)
236 return "<a " + (extension
[1] ? "title=\"" + (pseudo
== undefined ? "" : thisFormateur
.traiterPourFenetreLightBox(pseudo
, url
) + ": ") + thisFormateur
.traiterPourFenetreLightBox(M
, url
) + "\"" + " rel=\"lightbox\"" : "") + " href=\"" + url
+ "\" >[" + extension
[0] + "]</a>"
238 return M
.replace(this.regexUrl
, traitementUrl
)
242 * Formatage en utilisant un sous-ensemble des règles de mediwiki.
243 * par exemple ''italic'' devient <i>italic</i>
245 Formateur
.prototype.traiterWikiSyntaxe = function(M
)
249 function(texte
, capture
)
251 return "<b>" + capture
+ "</b>"
255 function(texte
, capture
)
257 return "<i>" + capture
+ "</i>"
263 * Renvoie une version courte de l'url.
264 * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient wikipedia.org
266 Formateur
.prototype.getShort = function(url
)
268 var estUneImage
= false
269 var versionShort
= null
270 var rechercheImg
= this.regexImg
.exec(url
)
272 if (rechercheImg
!= null)
274 versionShort
= rechercheImg
[1].toLowerCase()
275 if (versionShort
== "jpeg") versionShort
= "jpg" // jpeg -> jpg
280 var rechercheDomaine
= this.regexDomaine
.exec(url
)
281 if (rechercheDomaine
!= null && rechercheDomaine
.length
>= 2)
282 versionShort
= rechercheDomaine
[1]
285 var nomProtocole
= this.regexNomProtocole
.exec(url
)
286 if (nomProtocole
!= null && nomProtocole
.length
>= 2)
287 versionShort
= nomProtocole
[1]
291 return [versionShort
== null ? "url" : versionShort
, estUneImage
]
295 * Traite les pseudo et messages à être affiché dans le titre d'une image visualisé avec lightbox.
297 Formateur
.prototype.traiterPourFenetreLightBox = function(M
, urlCourante
)
299 var thisFormateur
= this
300 var traitementUrl = function(url
)
302 return "[" + thisFormateur
.getShort(url
)[0] + (urlCourante
== url
? "*" : "") + "]"
305 return this.remplacerBalisesHTML(M
).replace(this.regexUrl
, traitementUrl
)
309 ///////////////////////////////////////////////////////////////////////////////////////////////////
311 // les statuts possibes du client
313 // mode enregistré, peut poster des messages et modifier son profile
315 // mode identifié, peut poster des messages mais n'a pas accès au profile
316 auth_not_registered : 1,
317 // mode déconnecté, ne peut pas poster de message
321 function Client(util
)
326 this.regexCookie
= new RegExp("^cookie=([^;]*)")
328 // données personnels
329 this.resetDonneesPersonnelles()
331 this.setStatut(statutType
.deconnected
)
333 // si true alors chaque modification du client est mémorisé sur le serveur
334 this.autoflush
= $.browser
["opera"]
337 Client
.prototype.resetDonneesPersonnelles = function()
340 this.pseudo
= euphorik
.conf
.pseudoDefaut
344 this.css
= $("link#cssPrincipale").attr("href")
345 this.chatOrder
= "reverse"
346 this.nickFormat
= "nick"
347 this.viewTimes
= true
348 this.viewTooltips
= true
349 this.cookie
= undefined
351 this.pagePrincipale
= 1
352 this.ekMaster
= false
353 this.ostentatiousMaster
= "light"
355 // les conversations, une conversation est un objet possédant les attributs suivants :
359 this.conversations
= []
362 Client
.prototype.setCss = function(css
)
364 if (this.css
== css
|| css
== "")
368 $("link#cssPrincipale").attr("href", this.css
)
369 if (this.autoflush
) this.flush(true)
372 Client
.prototype.pageSuivante = function(numConv
)
374 if (numConv
< 0 && this.pagePrincipale
> 1)
375 this.pagePrincipale
-= 1
376 else if (this.conversations
[numConv
].page
> 1)
377 this.conversations
[numConv
].page
-= 1
380 Client
.prototype.pagePrecedente = function(numConv
)
383 this.pagePrincipale
+= 1
385 this.conversations
[numConv
].page
+= 1
389 * Définit la première page pour la conversation donnée.
390 * @return true si la page a changé sinon false
392 Client
.prototype.goPremierePage = function(numConv
)
396 if (this.pagePrincipale
== 1)
398 this.pagePrincipale
= 1
402 if (this.conversations
[numConv
].page
== 1)
404 this.conversations
[numConv
].page
= 1
410 * Ajoute une conversation à la vue de l'utilisateur.
411 * Le profile de l'utilisateur est directement sauvegardé sur le serveur.
412 * @param racines la racine de la conversation (integer)
413 * @return true si la conversation a été créée sinon false (par exemple si la conv existe déjà)
415 Client
.prototype.ajouterConversation = function(racine
)
417 // vérification s'il elle n'existe pas déjà
418 for (var i
= 0; i
< this.conversations
.length
; i
++)
419 if (this.conversations
[i
].root
== racine
)
422 this.conversations
.push({root : racine
, page : 1, reduit : false})
423 if (this.autoflush
) this.flush(true)
428 Client
.prototype.supprimerConversation = function(num
)
430 if (num
< 0 || num
>= this.conversations
.length
) return
432 // décalage TODO : supprimer le dernier élément
433 for (var i
= num
; i
< this.conversations
.length
- 1; i
++)
434 this.conversations
[i
] = this.conversations
[i
+1]
435 this.conversations
.pop()
437 if (this.autoflush
) this.flush(true)
440 Client
.prototype.getJSONLogin = function(login
, password
)
443 "header" : { "action" : "authentification", "version" : euphorik
.conf
.versionProtocole
},
445 "password" : password
449 Client
.prototype.getJSONLoginCookie = function()
452 "header" : { "action" : "authentification", "version" : euphorik
.conf
.versionProtocole
},
453 "cookie" : this.cookie
458 * le couple (login, password) est facultatif. S'il n'est pas fournit alors il ne sera pas possible
459 * de s'autentifier avec (login, password).
461 Client
.prototype.getJSONEnregistrement = function(login
, password
)
463 var mess
= { "header" : { "action" : "register", "version" : euphorik
.conf
.versionProtocole
}}
465 if (login
!= undefined && password
!= undefined)
467 mess
["login"] = login
468 mess
["password"] = password
474 Client
.prototype.getJSONConversations = function()
476 var conversations
= new Array()
477 for (var i
= 0; i
< this.conversations
.length
; i
++)
478 conversations
.push({root : this.conversations
[i
].root
, minimized : this.conversations
[i
].reduit
})
482 Client
.prototype.getJSONProfile = function()
485 "header" : { "action" : "set_profile", "version" : euphorik
.conf
.versionProtocole
},
486 "cookie" : this.cookie
,
487 "login" : this.login
,
488 "password" : this.password
,
489 "nick" : this.pseudo
,
490 "email" : this.email
,
492 "chat_order" : this.chatOrder
,
493 "nick_format" : this.nickFormat
,
494 "view_times" : this.viewTimes
,
495 "view_tooltips" : this.viewTooltips
,
496 "conversations" : this.getJSONConversations(),
497 "ostentatious_master" : this.ostentatiousMaster
502 * Renvoie null si pas définit.
504 Client
.prototype.getCookie = function()
506 var cookie
= this.regexCookie
.exec(document
.cookie
)
507 if (cookie
== null) this.cookie
= null
508 else this.cookie
= cookie
[1]
511 Client
.prototype.delCookie = function()
513 document
.cookie
= "cookie=; max-age=0"
516 Client
.prototype.setCookie = function()
518 if (this.cookie
== null || this.cookie
== undefined)
521 // ne fonctionne pas sous IE....
522 /*document.cookie = "cookie=" + this.cookie + "; max-age=" + (60 * 60 * 24 * 365) */
525 "cookie="+this.cookie
+"; expires=" + new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365).toUTCString()
528 Client
.prototype.authentifie = function()
530 return this.statut
== statutType
.auth_registered
|| this.statut
== statutType
.auth_not_registered
533 Client
.prototype.setStatut = function(statut
)
535 // conversation en "enum" si en "string"
536 if (typeof(statut
) == "string")
539 statut
== "auth_registered" ?
540 statutType
.auth_registered :
541 (statut
== "auth_not_registered" ? statutType
.auth_not_registered : statutType
.deconnected
)
544 if (statut
== this.statut
) return
552 * Effectue la connexion vers le serveur.
553 * Cette fonction est bloquante tant que la connexion n'a pas été établie.
554 * S'il existe un cookie en local on s'authentifie directement avec lui.
555 * Si il n'est pas possible de s'authentifier alors on affiche un captcha anti-bot.
557 Client
.prototype.connexionCookie = function()
560 if (this.cookie
== null) return false;
561 return this.connexion(this.getJSONLoginCookie())
564 Client
.prototype.connexionLogin = function(login
, password
)
566 return this.connexion(this.getJSONLogin(login
, password
))
569 Client
.prototype.enregistrement = function(login
, password
)
571 if (this.authentifie())
574 this.password
= password
577 this.setStatut(statutType
.auth_registered
)
584 return this.connexion(this.getJSONEnregistrement(login
, password
))
589 * Connexion. Réalisé de manière synchrone.
591 Client
.prototype.connexion = function(messageJson
)
593 var thisClient
= this
600 data: this.util
.jsonVersAction(messageJson
),
604 if (data
["reply"] == "error")
606 thisClient
.util
.messageDialogue(data
["error_message"])
607 // suppression du cookie actuel, cas où le cookie du client ne permet pas une authentification
608 thisClient
.delCookie()
611 thisClient
.chargerDonnees(data
)
615 return this.authentifie()
618 Client
.prototype.deconnexion = function()
622 this.resetDonneesPersonnelles()
623 this.setStatut(statutType
.deconnected
) // deconnexion
626 Client
.prototype.chargerDonnees = function(data
)
628 // la modification du statut qui suit met à jour le menu, le menu dépend (page admin)
629 // de l'état ekMaster
630 this.ekMaster
= data
["ek_master"] != undefined ? data
["ek_master"] : false
632 this.setStatut(data
["status"])
634 if (this.authentifie())
636 this.cookie
= data
["cookie"]
640 this.login
= data
["login"]
641 this.pseudo
= data
["nick"]
642 this.email
= data
["email"]
643 this.setCss(data
["css"])
644 this.chatOrder
= data
["chat_order"]
645 this.nickFormat
= data
["nick_format"]
646 this.viewTimes
= data
["view_times"]
647 this.viewTooltips
= data
["view_tooltips"]
648 this.ostentatiousMaster
= data
["ostentatious_master"]
650 // la page de la conversation principale
651 this.pagePrincipale
= 1
654 this.conversations
= data
["conversations"]
655 for (var i
= 0; i
< this.conversations
.length
; i
++)
656 this.conversations
[i
] = {root : this.conversations
[i
].root
, page : 1, reduit : this.conversations
[i
].minimized
}
659 this.majCssSelectionee()
665 * Met à jour les données personne sur serveur.
666 * @param async de manière asynchrone ? défaut = true
667 * @return false si le flush n'a pas pû se faire sinon true
669 Client
.prototype.flush = function(async
)
671 if (async
== undefined)
674 if (!this.authentifie())
677 var thisClient
= this
685 data: this.util
.jsonVersAction(this.getJSONProfile()),
689 if (data
["reply"] == "error")
691 thisClient
.util
.messageDialogue(data
["error_message"])
696 thisClient
.majBulle()
705 Client
.prototype.majMenu = function()
707 var displayType
= "block"
709 $("#menu .admin").css("display", this.ekMaster
? displayType : "none")
711 // met à jour le menu
712 if (this.statut
== statutType
.auth_registered
)
714 $("#menu .profile").css("display", displayType
).text("profile")
715 $("#menu .logout").css("display", displayType
)
716 $("#menu .register").css("display", "none")
718 else if (this.statut
== statutType
.auth_not_registered
)
720 $("#menu .profile").css("display", "none")
721 $("#menu .logout").css("display", displayType
)
722 $("#menu .register").css("display", displayType
)
726 $("#menu .profile").css("display", displayType
).text("login")
727 $("#menu .logout").css("display", "none")
728 $("#menu .register").css("display", displayType
)
733 * Met à jour l'affichage des infos bulles en fonction du profile.
735 Client
.prototype.majBulle = function()
737 this.util
.bulleActive
= this.viewTooltips
741 * Met à jour la css sélectionnée, lors du chargement des données.
743 Client
.prototype.majCssSelectionee = function()
745 // extraction du numéro de la css courante
746 var numCssCourante
= this.css
.match(/^.*?\/(\d)\/.*$/)
747 if (numCssCourante
!= null && numCssCourante
[1] != undefined)
749 $("#menuCss option").removeAttr("selected")
750 $("#menuCss option[value=" + numCssCourante
[1]+ "]").attr("selected", "selected")
755 * Change la "class" du logo en fonction du statut de ekMaster.
757 Client
.prototype.majLogo = function()
760 $("#logo").addClass("ekMaster")
762 $("#logo").removeClass("ekMaster")
766 Client
.prototype.slap = function(userId
, raison
)
768 var thisClient
= this
774 data: this.util
.jsonVersAction(
776 "header" : { "action" : "slap", "version" : euphorik
.conf
.versionProtocole
},
777 "cookie" : thisClient
.cookie
,
784 if (data
["reply"] == "error")
785 thisClient
.util
.messageDialogue(data
["error_message"])
790 Client
.prototype.ban = function(userId
, raison
, minutes
)
792 var thisClient
= this
794 // par défaut un ban correspond à 3 jours
795 if (typeof(minutes
) == "undefined")
796 minutes
= euphorik
.conf
.tempsBan
;
802 data: this.util
.jsonVersAction(
804 "header" : { "action" : "ban", "version" : euphorik
.conf
.versionProtocole
},
805 "cookie" : thisClient
.cookie
,
806 "duration" : minutes
,
813 if (data
["reply"] == "error")
814 thisClient
.util
.messageDialogue(data
["error_message"])
819 Client
.prototype.kick = function(userId
, raison
)
821 this.ban(userId
, raison
, euphorik
.conf
.tempsKick
)
824 ///////////////////////////////////////////////////////////////////////////////////////////////////
827 * classe permettant de gérer les événements (push serveur).
828 * l'information envoyé est sous la forme :
830 * "header" : {"action" : "wait_event", "version" : <v> },
834 * l'information reçu est sous la forme :
840 function PageEvent(page
, util
)
845 // l'objet JSONHttpRequest représentant la connexion d'attente
846 this.attenteCourante
= null
848 // le multhreading du pauvre, merci javascript de m'offrire autant de primitives pour la gestion de la concurrence...
853 * Arrête l'attente courante s'il y en a une.
855 PageEvent
.prototype.stopAttenteCourante = function()
859 if (this.attenteCourante
!= null)
861 this.attenteCourante
.abort()
866 * Attend un événement lié à la page.
867 * @funSend une fonction renvoyant les données json à envoyer
868 * @funsReceive est un objet comprenant les fonctions à appeler en fonction du "reply"
869 * les fonctions acceptent un paramètre correspondant au données reçues.
870 * exemple : {"new_message" : function(data){ ... }}
872 PageEvent
.prototype.waitEvent = function(funSend
, funsReceive
)
874 this.stopAttenteCourante()
878 var thisPageEvent
= this
880 // on doit conserver l'ordre des valeurs de l'objet JSON (le serveur les veut dans l'ordre définit dans le protocole)
881 // TODO : ya pas mieux ?
884 "header" : { "action" : "wait_event", "version" : euphorik
.conf
.versionProtocole
},
887 var poulpe
= funSend()
888 for (var v
in poulpe
)
889 dataToSend
[v
] = poulpe
[v
]
891 this.attenteCourante
= jQuery
.ajax({
895 // TODO : doit disparaitre
896 timeout: 180000, // timeout de 3min. Gros HACK pas beau. FIXME problème décrit ici : http://groups.google.com/group/jquery-en/browse_thread/thread/8724e64af3333a76
897 data: this.util
.jsonVersAction(dataToSend
),
901 funsReceive
[data
["reply"]](data
)
903 // rappel de la fonction dans 100 ms
904 setTimeout(function(){ thisPageEvent
.waitEvent2(funSend
, funsReceive
) }, 100)
907 function(XMLHttpRequest
, textStatus
, errorThrown
)
909 ;; console
.log("Connexion perdue dans waitEvent")
910 setTimeout(function(){ thisPageEvent
.waitEvent2(funSend
, funsReceive
) }, 1000)
916 * Si un stopAttenteCourante survient un peu n'importe quand il faut imédiatement arreter de boucler.
918 PageEvent
.prototype.waitEvent2 = function(funSend
, funsReceive
)
922 this.waitEvent(funSend
, funsReceive
)
925 ///////////////////////////////////////////////////////////////////////////////////////////////////
932 var formateur
= new Formateur()
933 var util
= new euphorik
.Util(formateur
)
934 var client
= new Client(util
)
935 var pages
= new Pages()
937 // connexion vers le serveur (utilise un cookie qui traine)
938 client
.connexionCookie()
940 $("#menuCss").change(function(){ client
.setCss("styles/" + $("option:selected", this).attr("value") + "/euphorik.css")})
942 // FIXME : ne fonctionne pas sous opera
943 // voir : http://dev.jquery.com/ticket/2892#preview
944 $(window
).unload(function(){client
.flush()})
946 $("#menu .minichat").click(function(){ pages
.afficherPage("minichat") })
947 $("#menu .admin").click(function(){ pages
.afficherPage("admin") })
948 $("#menu .profile").click(function(){ pages
.afficherPage("profile") })
949 $("#menu .logout").click(function(){
950 util
.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", euphorik
.Util
.messageType
.question
,
953 client
.deconnexion();
954 pages
.afficherPage("minichat", true)
960 $("#menu .register").click(function(){ pages
.afficherPage("register") })
961 $("#menu .about").click(function(){ pages
.afficherPage("about") })
963 // TODO : simplifier et pouvoir créer des liens par exemple : <span class="lien" href="conditions">Conditions d'utilisation</span>
964 $("#footer .conditions").click(function(){ pages
.afficherPage("conditions_utilisation") })
966 pages
.ajouterPage(new PageMinichat(client
, formateur
, util
))
967 pages
.ajouterPage(new PageAdmin(client
, formateur
, util
))
968 pages
.ajouterPage(new PageProfile(client
, formateur
, util
))
969 pages
.ajouterPage(new PageRegister(client
, formateur
, util
))
970 pages
.ajouterPage(new PageAbout(client
, formateur
, util
))
971 pages
.ajouterPage("conditions_utilisation")
973 pages
.afficherPage("minichat")