{\r
var estUneImage = false
var versionShort = null
- var rechercheImg = this.regexImg.exec(url)\r
- //alert(url)
+ var rechercheImg = this.regexImg.exec(url)
+
if (rechercheImg != null)\r
{
versionShort = rechercheImg[1].toLowerCase()\r
Client.prototype.setCss = function(css)
{
- if (this.css == css)
+ if (this.css == css || css == "")
return
this.css = css
Client.prototype.setStatut = function(statut)
{
- //alert(statut)
// conversation en "enum" si en "string"\r
if (typeof(statut) == "string")\r
{
Client.prototype.chargerDonnees = function(data)
{
- var thisClient = this
-
+ // la modification du statut qui suit met à jour le menu, le menu dépend (page admin)
+ // de l'état ekMaster
+ this.ekMaster = data["ek_master"] != undefined ? data["ek_master"] : false
+
this.setStatut(data["status"])
if (this.authentifie())
this.login = data["login"]
this.pseudo = data["nick"]\r
this.email = data["email"]\r
- this.css = data["css"]
+ this.setCss(data["css"])
this.nickFormat = data["nick_format"]
// la page de la conversation principale
this.pagePrincipale = data["main_page"] == undefined ? 1 : data["main_page"]
- // met à jour la css
- if (this.css != "")
- {
- $("link#cssPrincipale").attr("href", this.css)
- this.majMenu()
- }
// les conversations
- thisClient.conversations = data["conversations"]
-
- thisClient.ekMaster = data["ek_master"]
+ this.conversations = data["conversations"]
}
this.dernierMessageErreur = data["error_message"]
}
Client.prototype.majMenu = function()
{
+ // TODO : à virer : ne plus changer de style de display ... spa beau .. ou trouver une autre méthode
var displayType = this.css == "css/3/euphorik.css" ? "block" : "inline" //this.client
+ $("#menu .admin").css("display", this.ekMaster ? "inline" : "none")
+
// met à jour le menu
if (this.statut == statutType.auth_registered)
{
}
}
-
-Client.prototype.slap = function(userId)
+Client.prototype.slap = function(userId, raison)
{
var thisClient = this
{
"action" : "slap",
"cookie" : thisClient.cookie,
- "user_id" : userId
+ "user_id" : userId,
+ "reason" : raison
}),
success:
function(data)
})
}
-
-Client.prototype.ban = function(userId, minutes)
+Client.prototype.ban = function(userId, raison, minutes)
{
var thisClient = this
"action" : "ban",
"cookie" : thisClient.cookie,
"duration" : minutes,
- "user_id" : userId
+ "user_id" : userId,
+ "reason" : raison
}),
success:
function(data)
})
}
-Client.prototype.kick = function(userId)
+Client.prototype.kick = function(userId, raison)
+{
+ this.ban(userId, raison, 15)
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * classe permettant de gérer les événements (push serveur).
+ * @page la page
+ */
+function PageEvent(page, util)
{
- this.ban(userId, 15)
+ this.page = page
+ this.util = util
+
+ // l'objet JSONHttpRequest représentant la connexion d'attente
+ this.attenteCourante = null
+}
+
+/**
+ * Arrête l'attente courante s'il y en a une.
+ */
+PageEvent.prototype.stopAttenteCourante = function()
+{
+ 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)
+{
+ var thisPageEvent = this
+
+ this.stopAttenteCourante()
+
+ // on doit conserver l'ordre des valeurs de l'objet JSON (le serveur les veux 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.waitEvent(funSend, funReceive) }, 100);
+ },
+ error:
+ function(XMLHttpRequest, textStatus, errorThrown)
+ {
+ setTimeout(function(){ thisPageEvent.rafraichirMessages(funSend, funReceive) }, 1000);
+ }
+ })
+
}
///////////////////////////////////////////////////////////////////////////////////////////////////
$(window).unload(function(){client.flush(false)})
$("#menu .minichat").click(function(){ pages.afficherPage("minichat") })
+ $("#menu .admin").click(function(){ pages.afficherPage("admin") })
$("#menu .profile").click(function(){ pages.afficherPage("profile") })\r
$("#menu .logout").click(function(){
util.messageDialogue("Êtes-vous sur de vouloir vous délogger ?", messageType.question,
$("#menu .about").click(function(){ pages.afficherPage("about") })
pages.ajouterPage(new PageMinichat(client, formateur, util))
+ pages.ajouterPage(new PageAdmin(client, formateur, util))
pages.ajouterPage(new PageProfile(client, formateur, util))
pages.ajouterPage(new PageRegister(client, formateur, util))
pages.ajouterPage(new PageAbout(client, formateur, util))