From 65a4c4e621c5cfc52f20097db8ede10714a7c0f6 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Wed, 28 May 2008 20:51:18 +0000 Subject: [PATCH] =?utf8?q?ADD=20possibilit=C3=A9=20de=20cacher=20les=20inf?= =?utf8?q?os=20bulles=20ADD=20possibilit=C3=A9=20de=20cacher=20les=20dates?= =?utf8?q?=20des=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- doc/protocole3.txt | 8 +++-- js/euphorik.js | 47 ++++++++++++++++++++++++------ js/pageMinichat.js | 24 ++++++++++----- js/pageProfile.js | 20 +++++++++---- modules/erl/euphorik_bd.erl | 8 +++-- modules/erl/euphorik_protocole.erl | 18 +++++++++++- modules/include/euphorik_bd.hrl | 2 ++ 7 files changed, 98 insertions(+), 29 deletions(-) diff --git a/doc/protocole3.txt b/doc/protocole3.txt index 4b18f9e..66f688d 100644 --- a/doc/protocole3.txt +++ b/doc/protocole3.txt @@ -82,7 +82,9 @@ ou "login" : "paul49", "email" : "paul@pierre.com", "css" : "css/3/euphorik.css", - "nick_format" : "nick" | "login" | "nick_login", + "nick_format" : "nick" | "login" | "nick_login", + "view_times" : true | false, + "view_tooltips" : true | false, "main_page" : 1, "conversations" : [ { @@ -112,7 +114,9 @@ c -> s "nick" : "Paul", "email" : "paul@pierre.com", "css" : "css/3/euphorik.css", - "nick_format" : "nick" | "login" | "nick_login", + "nick_format" : "nick" | "login" | "nick_login", + "view_times" : true | false, + "view_tooltips" : true | false, "main_page" : 1, "conversations" : [ { diff --git a/js/euphorik.js b/js/euphorik.js index 1b78ba8..ca84a02 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -90,7 +90,10 @@ function Util(formateur) $("#info").slideUp(50) }) + $("body").append('
').append('

') + this.formateur = formateur + this.bulleActive = true } var messageType = {informatif: 0, question: 1, erreur: 2} @@ -140,19 +143,25 @@ Util.prototype.messageDialogue = function(message, type, boutons, formate) */ Util.prototype.infoBulle = function(message, element) { - var virerMess = function() + var thisUtil = this + + var cacherBulle = function() { - $("#flecheBulle").remove() - $("#messageBulle").remove() + $("#flecheBulle").hide() + $("#messageBulle").hide() } - element.click(virerMess) - element.hover( function(e) { - f = $('
').appendTo("body") - m = $('

' + message + '

').appendTo("body") + if (!thisUtil.bulleActive) + return + + var m = $("#messageBulle") + var f = $("#flecheBulle") + + $("p", m).html(message) + var positionFleche = { left : element.offset().left + element.width() / 2 - f.width() / 2, top : element.offset().top - f.height() @@ -173,8 +182,8 @@ Util.prototype.infoBulle = function(message, element) m.css("top", positionMessage.top).css("left", positionMessage.left).show() f.css("top", positionFleche.top).css("left", positionFleche.left).show() }, - virerMess - ) + cacherBulle + ).click(cacherBulle) } /** @@ -522,6 +531,8 @@ Client.prototype.resetDonneesPersonnelles = function() this.email = "" this.css = $("link#cssPrincipale").attr("href") this.nickFormat = "nick" + this.viewTimes = true + this.viewTooltips = true this.cookie = undefined this.pagePrincipale = 1 @@ -667,6 +678,8 @@ Client.prototype.getJSONProfile = function() "email" : this.email, "css" : this.css, "nick_format" : this.nickFormat, + "view_times" : this.viewTimes, + "view_tooltips" : this.viewTooltips, "main_page" : this.pagePrincipale < 1 ? 1 : this.pagePrincipale, "conversations" : this.getJSONConversations() } @@ -808,12 +821,16 @@ Client.prototype.chargerDonnees = function(data) this.email = data["email"] this.setCss(data["css"]) this.nickFormat = data["nick_format"] + this.viewTimes = data["view_times"] + this.viewTooltips = data["view_tooltips"] // la page de la conversation principale this.pagePrincipale = data["main_page"] == undefined ? 1 : data["main_page"] // les conversations this.conversations = data["conversations"] + + this.majBulle() } } @@ -850,6 +867,10 @@ Client.prototype.flush = function(async) thisClient.util.messageDialogue(data["error_message"]) ok = false } + else + { + thisClient.majBulle() + } } } ) @@ -886,6 +907,14 @@ Client.prototype.majMenu = function() } } +/** + * 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 diff --git a/js/pageMinichat.js b/js/pageMinichat.js index 19fadb0..461c924 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -60,24 +60,27 @@ PageMinichat.prototype.charger = function() // les outils de bannissement (uniquement pour les ekMaster) if (this.client.ekMaster) { - $("body").append( + $( '
' + '

' + 'Ban de 3 jours' + 'Ban de 15min' + 'Avertissement' + '
' - ) - $("#outilsBan").hover( + ).hover( function(){}, function() { $("#outilsBan").hide() } - ) + ).appendTo("body") + + this.util.infoBulle("Slap", $("#outilsBan #slap")) + this.util.infoBulle("Kick", $("#outilsBan #kick")) + this.util.infoBulle("Ban", $("#outilsBan #ban")) } - this.util.infoBulle("Ouvrir la conversation liée au troll de la semaine", $("#trollCourant")) + this.util.infoBulle("Ouvrir la conversation liée au troll de la semaine", $("#trollCourant .troll")) // $("body").append("
") @@ -538,7 +541,7 @@ Conversation.prototype.flush = function(funClickOuvrirConv) (this.messages[i].ekMaster ? " ekMaster" : "") + "\">" + "
" + - "[" + message.date + "]" + + "[" + message.date + "]" + "" + message.auteurId + "" + identifiant + "" + XHTMLrepondA + "" + this.formateur.traitementComplet(message.contenu, message.pseudo) + "" + @@ -567,6 +570,11 @@ Conversation.prototype.flush = function(funClickOuvrirConv) } ) + if (thisConversation.client.viewTimes) + $(".dateComplete", this).show() + else + $(".dateComplete", this).hide() + $("a[@rel*=lightbox]", this).lightBox() // les outils de bannissement (uniquement pour les ekMaster) @@ -579,7 +587,7 @@ Conversation.prototype.flush = function(funClickOuvrirConv) var h = element.height() var offset = element.offset() var outils = $("#outilsBan").css("top", offset.top - 2).css("left", offset.left - 2).height(h < 16 ? 16 : h).width(element.width() + 16 * 3 + 4 + 64).show() - $("img", outils).unbind() + $("img", outils).unbind("click") $("#slap", outils).click( function(e) { @@ -943,7 +951,7 @@ Messages.prototype.rafraichirMessages = function(vider) { case "new_troll" : thisMessages.trollIdCourant = data["troll_id"] - $("#trollCourant .troll").html(thisMessages.formateur.traitementComplet(data["content"])).unbind().click( + $("#trollCourant .troll").html(thisMessages.formateur.traitementComplet(data["content"])).unbind("click").click( function() { thisMessages.ouvrirConversation(data["message_id"]) diff --git a/js/pageProfile.js b/js/pageProfile.js index b6920d2..5c78846 100755 --- a/js/pageProfile.js +++ b/js/pageProfile.js @@ -51,6 +51,8 @@ PageProfile.prototype.chargerProfile = function() $("form#profile input.login").val(this.client.login) $("form#profile input.pseudo").val(this.client.pseudo) $("form#profile input.email").val(this.client.email) + $("form#profile input#viewTooltips").attr("checked", this.client.viewTooltips) + $("form#profile input#viewTimes").attr("checked", this.client.viewTimes) $("form#profile select#affichagePseudo option").removeAttr("selected") $("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected") @@ -62,6 +64,8 @@ PageProfile.prototype.chargerProfile = function() thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo($("form#profile input.pseudo").val()) thisPage.client.email = $("form#profile input.email").val() thisPage.client.nickFormat = $("form#profile select#affichagePseudo option:selected").attr("value") + thisPage.client.viewTooltips = $("form#profile input#viewTooltips").attr("checked") + thisPage.client.viewTimes = $("form#profile input#viewTimes").attr("checked") var password = $("form#profile input.password").val() var passwordRe = $("form#profile input.passwordRe").val() @@ -78,10 +82,7 @@ PageProfile.prototype.chargerProfile = function() if(!thisPage.client.flush()) thisPage.util.messageDialogue("Impossible de mettre à jour votre profile, causes inconnues", messageType.erreur) else - { thisPage.util.messageDialogue("Votre profile a été mis à jour") - //thisPage.pages.afficherPage("minichat") - } } ) } @@ -138,10 +139,17 @@ return '\ \ \ \ - ' : '') + '\ \ - \ - \ + Afficher les infos bulles\ + \ + \ + \ + Afficher les dates\ + \ + ' : '') + '\ + \ + \ + \ \ \ ' diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 91d6f67..13acf96 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -33,7 +33,7 @@ % users : nouveau_user/2, nouveau_user/3, - set_profile/9, + set_profile/11, update_date_derniere_connexion/1, update_ip/2, update_pseudo_user/2, @@ -184,12 +184,12 @@ nouveau_user(Login, Password, Cookie) -> % Mise à par Cookie les autres peuvent être undefined ce qui veut dire qu'ils ne seront pas modifié. -set_profile(Cookie, Login, Password, Pseudo, Email, Css, Nick_format, Page_principale, Conversations) -> +set_profile(Cookie, Login, Password, Pseudo, Email, Css, Nick_format, View_times, View_tooltips, Page_principale, Conversations) -> if Nick_format =:= nick; Nick_format =:= login; Nick_format =:= nick_login -> resultat_transaction(mnesia:transaction( fun() -> case user_by_cookie(Cookie) of - {ok, User} -> + {ok, User} -> case user_by_login(Login) of {ok, U} when Login =/= [], U#user.id =/= User#user.id -> login_deja_pris; @@ -203,6 +203,8 @@ set_profile(Cookie, Login, Password, Pseudo, Email, Css, Nick_format, Page_princ email = if is_list(Email) -> Email; true -> User#user.email end, css = if is_list(Css) -> Css; true -> User#user.css end, nick_format = Nick_format, + view_times = View_times, + view_tooltips = View_tooltips, page_principale = if is_integer(Page_principale), Page_principale > 0 -> Page_principale; true -> User#user.page_principale end, conversations = if is_list(Conversations) -> Conversations; true -> User#user.conversations end }, diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index 58a8df9..faf877d 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -111,6 +111,8 @@ profile( {email, Email}, {css, Css}, {nick_format, Nick_format_str}, + {view_times, View_times}, + {view_tooltips, View_tooltips}, {main_page, Main_page}, {conversations, {array, Conversations_json}} ] @@ -128,7 +130,19 @@ profile( [], Conversations_json ), - case euphorik_bd:set_profile(Cookie, Login, Password, Pseudo, Email, Css, list_to_atom(Nick_format_str), Main_page, Conversations) of + % TODO : pas très beau, mieux vaut construire un #user + case euphorik_bd:set_profile( + Cookie, + Login, + Password, + Pseudo, + Email, + Css, + list_to_atom(Nick_format_str), + View_times, + View_tooltips, + Main_page, + Conversations) of ok -> json_reponse_ok(); login_deja_pris -> @@ -662,6 +676,8 @@ json_reponse_login_ok(User) -> {email, User#user.email}, {css, User#user.css}, {nick_format, atom_to_list(User#user.nick_format)}, + {view_times, User#user.view_times}, + {view_tooltips, User#user.view_tooltips}, {main_page, User#user.page_principale}, {conversations, {array, diff --git a/modules/include/euphorik_bd.hrl b/modules/include/euphorik_bd.hrl index ff1ca40..4ef15a4 100755 --- a/modules/include/euphorik_bd.hrl +++ b/modules/include/euphorik_bd.hrl @@ -59,6 +59,8 @@ date_derniere_connexion, % erlang:now(), est mis à jour lors de n'importe quelle activitée (envoie de message par exemple) css = [], % string() nick_format = nick, %atom(), peut valoir 'nick', 'login' ou 'nick_login' + view_times = true, + view_tooltips = true, indice_flood = 0, % integer() est incrémenté lorsque l'utilisateur envoie trop rapidement des messages. page_principale = 1, % la page de la conversation principale conversations = [], % [{integer(), integer()}], la liste des messages correspondant au conversation ainsi que la page affichée -- 2.43.0