X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=js%2Feuphorik.js;h=5a15c00e3fd1952af5833e6e35da8ef984a9eb07;hb=bfb430d094eb0021777302c1191642eab4077e78;hp=8aaf875f088c5b6a6cf8f7bb315002ef9a0639ac;hpb=7e76d6bc2ccd165730addd3337656b479f9d95d4;p=euphorik.git diff --git a/js/euphorik.js b/js/euphorik.js index 8aaf875..5a15c00 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -13,7 +13,7 @@ * Normalement 'const' à la place de 'var' mais non supporté par IE7. */ var conf = { - nbMessageAffiche : 10, // (par page) + nbMessageAffiche : 40, // (par page) pseudoDefaut : "", tempsAffichageMessageDialogue : 4000, // en ms smiles : { @@ -74,6 +74,8 @@ function Util() }) } +var messageType = {informatif: 0, question: 1, erreur: 2} + /** * Affiche une boite de dialogue avec un message à l'intérieur. * @param message le message (string) @@ -105,9 +107,7 @@ Util.prototype.messageDialogue = function(message, type, boutons) $("#info").slideDown(200) this.timeoutMessageDialogue = setTimeout(fermer, conf.tempsAffichageMessageDialogue) -} - -var messageType = {informatif: 0, question: 1, erreur: 2} +} /** * Utilisé pour l'envoie de donnée avec la méthode ajax de jQuery. @@ -282,6 +282,11 @@ Formateur.prototype.getSmilesHTML = function() return XHTML } +/** + * Formatage complet d'un texte. + * @M le message + * @pseudo facultatif, permet de contruire le label des images sous la forme : " : " + */ Formateur.prototype.traitementComplet = function(M, pseudo) { return this.traiterLiensConv(this.traiterSmiles(this.traiterURL(this.remplacerBalisesHTML(M), pseudo))) @@ -327,9 +332,6 @@ Formateur.prototype.remplacerBalisesHTML = function(M) Formateur.prototype.traiterURL = function(M, pseudo) { thisFormateur = this - - if (pseudo == undefined) - pseudo = "" var traitementUrl = function(url) { @@ -337,7 +339,7 @@ Formateur.prototype.traiterURL = function(M, pseudo) if (!thisFormateur.regexTestProtocoleExiste.test(url)) url = "http://" + url var extension = thisFormateur.getShort(url) - return "[" + extension[0] + "]" + return "[" + extension[0] + "]" } return M.replace(this.regexUrl, traitementUrl) } @@ -382,7 +384,7 @@ Formateur.prototype.traiterPourFenetreLightBox = function(M, urlCourante) thisFormateur = this var traitementUrl = function(url) { - return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? ": image courante" : "") + "]" + return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? "*" : "") + "]" } return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl) @@ -411,20 +413,19 @@ function Client(util) // données personnels this.resetDonneesPersonnelles() - this.setStatut(statutType.deconnected) - - // le dernier message d'erreur recut du serveur (par exemple une connexion foireuse : "login impossible") - this.dernierMessageErreur = "" + this.setStatut(statutType.deconnected) } Client.prototype.resetDonneesPersonnelles = function() -{ +{ + this.id = 0 this.pseudo = conf.pseudoDefaut this.login = "" this.password = "" this.email = "" this.css = $("link#cssPrincipale").attr("href") this.nickFormat = "nick" + this.cookie = undefined this.pagePrincipale = 1 this.ekMaster = false @@ -608,7 +609,7 @@ Client.prototype.setStatut = function(statut) (statut == "auth_not_registered" ? statutType.auth_not_registered : statutType.deconnected) } - if (statut == this.statut) return + if (statut == this.statut) return this.statut = statut this.majMenu() @@ -639,8 +640,11 @@ Client.prototype.enregistrement = function(login, password) this.login = login this.password = password if(this.flush()) + { this.setStatut(statutType.auth_registered) - return true + return true + } + return false } else { @@ -663,7 +667,10 @@ Client.prototype.connexion = function(messageJson) function(data) { ;;; dumpObj(data) - thisClient.chargerDonnees(data) + if (data["reply"] == "error") + thisClient.util.messageDialogue(data["error_message"]) + else + thisClient.chargerDonnees(data) } } ) @@ -672,10 +679,10 @@ Client.prototype.connexion = function(messageJson) Client.prototype.deconnexion = function() { - this.flush() - this.delCookie() - this.setStatut(statutType.deconnected) // deconnexion + this.flush(true) + this.delCookie() this.resetDonneesPersonnelles() + this.setStatut(statutType.deconnected) // deconnexion } Client.prototype.chargerDonnees = function(data) @@ -690,7 +697,8 @@ Client.prototype.chargerDonnees = function(data) { this.cookie = data["cookie"] this.setCookie() - + + this.id = data["id"] this.login = data["login"] this.pseudo = data["nick"] this.email = data["email"] @@ -703,7 +711,6 @@ Client.prototype.chargerDonnees = function(data) // les conversations this.conversations = data["conversations"] } - this.dernierMessageErreur = data["error_message"] } /** @@ -714,12 +721,14 @@ Client.prototype.chargerDonnees = function(data) Client.prototype.flush = function(async) { if (async == undefined) - async = true + async = false if (!this.authentifie()) return false - thisClient = this + var thisClient = this + var ok = true + ;;; dumpObj(this.getJSONProfile()) jQuery.ajax( { @@ -731,12 +740,17 @@ Client.prototype.flush = function(async) success: function(data) { - //thisClient.util.log(thisClient.util.serializer.serializeToString(data)) + ;;; dumpObj(data) + if (data["reply"] == "error") + { + thisClient.util.messageDialogue(data["error_message"]) + ok = false + } } } ) - // TODO : retourner false si un problème est survenu lors de l'update du profile - return true + + return ok } Client.prototype.majMenu = function() @@ -926,7 +940,7 @@ $(document).ready( initialiserListeStyles(client) // TODO : pourquoi $(document).unload ne fonctionne pas ? - $(window).unload(function(){client.flush(false)}) + $(window).unload(function(){client.flush()}) $("#menu .minichat").click(function(){ pages.afficherPage("minichat") }) $("#menu .admin").click(function(){ pages.afficherPage("admin") })