+/**
+ * Met à jour l'affichage des infos bulles en fonction du profile.
+ */
+Client.prototype.majBulle = function()
+{
+ this.util.bulleActive = this.viewTooltips
+}
+
+Client.prototype.slap = function(userId, raison)
+{
+ var thisClient = this
+
+ jQuery.ajax({
+ type: "POST",
+ url: "request",
+ dataType: "json",
+ data: this.util.jsonVersAction(
+ {
+ "action" : "slap",
+ "cookie" : thisClient.cookie,
+ "user_id" : userId,
+ "reason" : raison
+ }),
+ success:
+ function(data)
+ {
+ if (data["reply"] == "error")
+ thisClient.util.messageDialogue(data["error_message"])
+ }
+ })
+}
+
+Client.prototype.ban = function(userId, raison, minutes)
+{
+ var thisClient = this
+
+ // par défaut un ban correspond à 3 jours
+ if (typeof(minutes) == "undefined")
+ minutes = conf.tempsBan;
+
+ jQuery.ajax({
+ type: "POST",
+ url: "request",
+ dataType: "json",
+ data: this.util.jsonVersAction(
+ {
+ "action" : "ban",
+ "cookie" : thisClient.cookie,
+ "duration" : minutes,
+ "user_id" : userId,
+ "reason" : raison
+ }),
+ success:
+ function(data)
+ {
+ if (data["reply"] == "error")
+ thisClient.util.messageDialogue(data["error_message"])
+ }
+ })
+}
+
+Client.prototype.kick = function(userId, raison)
+{
+ this.ban(userId, raison, conf.tempsKick)
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * classe permettant de gérer les événements (push serveur).
+ * @page la page
+ */
+function PageEvent(page, util)
+{
+ this.page = page
+ this.util = util
+
+ // l'objet JSONHttpRequest représentant la connexion d'attente
+ this.attenteCourante = null
+
+ // le multhreading du pauvre, merci javascript de m'offrire autant de primitives pour la gestion de la concurrence...
+ this.stop = false
+}
+
+/**
+ * Arrête l'attente courante s'il y en a une.
+ */
+PageEvent.prototype.stopAttenteCourante = function()
+{
+ this.stop = true
+
+ if (this.attenteCourante != null)
+ {
+ this.attenteCourante.abort()
+ }
+}
+
+/**
+ * Attend un événement lié à la page.
+ * @funSend une fonction renvoyant les données json à envoyer
+ * @funReceive une fonction qui accepte un paramètre correspondant au données reçues
+ */
+PageEvent.prototype.waitEvent = function(funSend, funReceive)
+{
+ this.stopAttenteCourante()
+
+ this.stop = false
+
+ var thisPageEvent = this
+
+ // on doit conserver l'ordre des valeurs de l'objet JSON (le serveur les veut dans l'ordre définit dans le protocole)
+ // TODO : ya pas mieux ?
+ var dataToSend =
+ {
+ "action" : "wait_event",
+ "page" : this.page
+ }
+ var poulpe = funSend()
+ for (v in poulpe)
+ dataToSend[v] = poulpe[v]
+
+ ;; dumpObj(dataToSend)
+
+ this.attenteCourante = jQuery.ajax({
+ type: "POST",
+ url: "request",
+ dataType: "json",
+ data: this.util.jsonVersAction(dataToSend),
+ success:
+ function(data)
+ {
+ ;; dumpObj(data)
+
+ funReceive(data)
+
+ // rappel de la fonction dans 100 ms
+ setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funReceive) }, 100)
+ },
+ error:
+ function(XMLHttpRequest, textStatus, errorThrown)
+ {
+ setTimeout(function(){ thisPageEvent.waitEvent2(funSend, funReceive) }, 1000)
+ }
+ })
+}
+
+/**
+ * Si un stopAttenteCourante survient un peu n'importe quand il faut imédiatement arreter de boucler.
+ */
+PageEvent.prototype.waitEvent2 = function(funSend, funReceive)
+{
+ if (this.stop)
+ return
+ this.waitEvent(funSend, funReceive)
+}
+