From 2faefc542de20cfcc0220b5c7fd7982dd0fbbfd4 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Fri, 2 May 2008 19:42:27 +0000 Subject: [PATCH] ADD trois mode d'affichage pour les pseudos --- css/1/euphorik.css | 19 +----- doc/graphiques/fond2.xcf | Bin 1883 -> 1892 bytes doc/protocole3.txt | 6 +- doc/uml.zargo | Bin 0 -> 4430 bytes index.html | 12 ++-- js/euphorik.js | 6 +- js/pageMinichat.js | 21 ++++-- js/pageProfile.js | 25 +++++-- modules/erl/euphorik_bd.erl | 13 +++- modules/erl/euphorik_minichat.erl | 61 ++++++++++-------- .../erl/euphorik_minichat_conversation.erl | 4 +- modules/erl/euphorik_protocole.erl | 9 ++- modules/erl/euphorik_requests.erl | 7 +- modules/include/euphorik_bd.hrl | 1 + 14 files changed, 114 insertions(+), 70 deletions(-) create mode 100644 doc/uml.zargo diff --git a/css/1/euphorik.css b/css/1/euphorik.css index fa7be6e..16b6436 100755 --- a/css/1/euphorik.css +++ b/css/1/euphorik.css @@ -54,10 +54,6 @@ body { z-index: 10; left: 600px; top:0px; - border: 1px; - background-color: #164200; - border: #2d8800 1px solid; - color: #EEEEEE; font-size: 9px; } @@ -135,22 +131,11 @@ div#info .boutons div:hover { .captcha { display:none -} - -/* Obsolète -#captcha { - margin-bottom: 5px; -} -#captcha input { - margin-left: 5px; } -#captcha .captchaImg { - background-color: #FFFFFF; - vertical-align: bottom; -}*/ form input, -form button { +form button, +form select { background-color: #164200; border: #2d8800 1px solid; color: #EEEEEE; diff --git a/doc/graphiques/fond2.xcf b/doc/graphiques/fond2.xcf index 676ced8d3574eeb134090febeb09c251401784bb..902ba65d7e96109b1f8609487ba6c762c740bc09 100644 GIT binary patch delta 308 zcmcc3_k?eP9i!q#`zl7p-p#uhcQDuUu`{sa#J?mN7$hYb7#aRaGO*%N2R1_tNaDo5 zlo=S5l|d#cgG_>}i^HlZ04RzR|0-c%C@BFMRRS^!r#g@sll|DlCMU450P!(X69xzn c08${#%)r3zfhxux0piy)GH?O0AP~C&06sM#C;$Ke delta 291 zcmaFDcbjj59i!An`zl7pmd(2ucQDsWvNN#bz#Ni{42+UY4F4n4D9x( SV(k7Pemx@t7Z3{qu^RxW^d5l# diff --git a/doc/protocole3.txt b/doc/protocole3.txt index 3f154a3..02051e9 100644 --- a/doc/protocole3.txt +++ b/doc/protocole3.txt @@ -81,7 +81,8 @@ ou "nick" : "Paul", "login" : "paul49", "email" : "paul@pierre.com", - "css" : "css/3/euphorik.css", + "css" : "css/3/euphorik.css", + "nick_format" : "nick" | "login" | "nick_login", "main_page" : 1, "conversations" : [ { @@ -109,7 +110,8 @@ c -> s "password" : "IJKJDHHSAD9081238", "nick" : "Paul", "email" : "paul@pierre.com", - "css" : "css/3/euphorik.css", + "css" : "css/3/euphorik.css", + "nick_format" : "nick" | "login" | "nick_login", "main_page" : 1, "conversations" : [ { diff --git a/doc/uml.zargo b/doc/uml.zargo new file mode 100644 index 0000000000000000000000000000000000000000..14e23be1fbeddc4bc12a203162108ec576de248c GIT binary patch literal 4430 zcmaKw2Q*w;7sn^Tj23OQD2Woim#9&~L@%QgEd*mQx@bYPAQHU`QKC!qPSiovL~lca z5QNF--N$?HTQBc@?|b{KyVkwyuD#bi|8v*=pWlJ1Vqud5a4$zl&1*5hFM)e`?}2dO zwQz+w<>|INzUC)sS>@uE20SU*2bzdTRojhmB8Ip?HWqhinSGmQ&rW8hj0qWE%rGzt zpj%SCy?`q3C6Pl}H;S|Sq^D5bcF`*5{e61*#VIGvR4d-ciIP6KQ>U z9Ojc8aA-(b$L`FNqOc@(V98B_eBshIV+enS8#dJSFc|;!7kQXBXm7Mrw078Zm`Y8l z94HYf_e|Gn9ZUu6v%~{tuZ@3u34Ei)VCvLIA)%T_5t7?x!(#TOiVk#Vd2t{#RQE$0 z?5J=YH;qJ%Q{$77%H(I{TLgKi*UF7RAjPM*`uJ>?o@4sX8O=Dn#jQ;BH;%jL9ew7D z`*DodH(G9Q6S${&NKEs?->3U8k5!p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FLtKb}sKo$ZMOM0besJzm(92eE(?oBV0sC7NLM)NPx6sF2Z})6=zK25|MLx>3~IygeU4rW}H{#KX^_>g;j~!fPecJjc1RhEi@R_LWP9BT%|>uWQ%I0e_PG zuZ(x)Uw@7Na{b@4er2L7{`)1a|8^Si4>b7q8ox5d6+QhKK&;

chat
register
logout
about
- +
+ +
diff --git a/js/euphorik.js b/js/euphorik.js index d7ef712..27ec5bb 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -415,6 +415,7 @@ Client.prototype.resetDonneesPersonnelles = function() this.password = "" this.email = "" this.css = jQuery("link#cssPrincipale").attr("href") + this.nickFormat = "nick" this.pagePrincipale = 1 @@ -550,6 +551,7 @@ Client.prototype.getJSONProfile = function() "nick" : this.pseudo, "email" : this.email, "css" : this.css, + "nick_format" : this.nickFormat, "main_page" : this.pagePrincipale < 1 ? 1 : this.pagePrincipale, "conversations" : this.getJSONConversations() } @@ -660,7 +662,8 @@ Client.prototype.connexion = function(messageJson) } Client.prototype.deconnexion = function() -{ +{ + this.flush() this.setStatut(statutType.deconnected) // deconnexion this.resetDonneesPersonnelles() this.delCookie () @@ -681,6 +684,7 @@ Client.prototype.chargerDonnees = function(data) this.pseudo = data["nick"] this.email = data["email"] this.css = data["css"] + this.nickFormat = data["nick_format"] // la page de la conversation principale this.pagePrincipale = data["main_page"] == undefined ? 1 : data["main_page"] diff --git a/js/pageMinichat.js b/js/pageMinichat.js index d82648e..e8d607a 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -210,11 +210,12 @@ function Reponse(id, pseudo, login) * @param pseudo * @param contenu */ -function Message(id, date, pseudo, contenu) +function Message(id, date, pseudo, login, contenu) { this.id = id this.date = date this.pseudo = pseudo + this.login = login this.contenu = contenu this.appartientAuClient = false @@ -285,7 +286,7 @@ Message.prototype.getConversation = function(messages) * @param numConv le numéro (appelé id) de la conversation * @param formateur outil permettant la mise en forme du texte des messages */ -function Conversation(num, util, formateur) +function Conversation(num, util, formateur, client) { var thisConversation = this @@ -294,6 +295,8 @@ function Conversation(num, util, formateur) this.messageOver = null // le message sur lequel se trouve le curseur this.util = util this.formateur = formateur + this.client = client + this.messages = new Array() this.messagesParId = new Object() @@ -424,9 +427,14 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) var XHTML = "" for (var i = this.messages.length - 1; i >= 0; i--) if (this.messages[i].id > idDernierMessageAffiche) - { + { var message = this.messages[i] + // construit l'identifiant de la personne + var identifiant = + this.client.nickFormat == "nick" ? message.pseudo : + (this.client.nickFormat == "login" ? message.login : message.pseudo + "(" + message.login +")" ) + var XHTMLrepondA = "" for (var id in message.repondA) XHTMLrepondA += this.formateur.traitementComplet(message.repondA[id].pseudo) + "> " @@ -441,7 +449,7 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) "\">" + "
>
" + "[" + message.date + "]" + - "" + this.formateur.traitementComplet(message.pseudo) + ":" + + "" + this.formateur.traitementComplet(identifiant) + ":" + XHTMLrepondA + "" + (message.systeme ? this.formateur.remplacerBalisesHTML(message.contenu) : this.formateur.traitementComplet(message.contenu, message.pseudo)) + "" + "" @@ -623,6 +631,7 @@ Messages.prototype.ajouterMessage = function(element, numConversation) id, element["date"], element["nick"], + element["login"], element["content"] ) @@ -657,7 +666,7 @@ Messages.prototype.nouvelleConversation = function(num, funFermer, funLien) { var thisMessages = this - this.conversations[num] = new Conversation(num, this.util, this.formateur) + this.conversations[num] = new Conversation(num, this.util, this.formateur, this.client) if (funFermer != undefined) this.conversations[num].eventFermer(funFermer) if (funLien != undefined) @@ -796,6 +805,8 @@ Messages.prototype.rafraichirMessages = function(vider) // ajoute les messages reçu à leur conversation respective for (var numConv = 0; numConv < data["conversations"].length; numConv++) { + //PLOP if (data["conversations"][numConv]["messages"].length == 0) continue + thisMessages.ajouterMessages(data["conversations"][numConv], numConv) // définit les événements liés à la conversation diff --git a/js/pageProfile.js b/js/pageProfile.js index 4a86aee..f3ef3a8 100755 --- a/js/pageProfile.js +++ b/js/pageProfile.js @@ -11,6 +11,7 @@ function PageProfile(client, formateur, util) PageProfile.prototype.contenu = function() { + // pourquoi ? return "" } @@ -33,13 +34,18 @@ PageProfile.prototype.chargerProfile = function() jQuery("form#profile input.login").val(this.client.login) jQuery("form#profile input.pseudo").val(this.client.pseudo) - jQuery("form#profile input.email").val(this.client.email) + jQuery("form#profile input.email").val(this.client.email) + + jQuery("form#profile select#affichagePseudo option").removeAttr("selected") + jQuery("form#profile select#affichagePseudo option[value=" + this.client.nickFormat + "]").attr("selected", "selected") + - jQuery("#page form#profile button").click( + jQuery("form#profile button").click( function() { thisPage.client.pseudo = thisPage.formateur.filtrerInputPseudo(jQuery("form#profile input.pseudo").val()) - thisPage.client.email = jQuery("form#profile input.email").val() + thisPage.client.email = jQuery("form#profile input.email").val() + thisPage.client.nickFormat = jQuery("form#profile select#affichagePseudo option:selected").attr("value") var password = jQuery("form#profile input.password").val() var passwordRe = jQuery("form#profile input.passwordRe").val() @@ -108,6 +114,16 @@ return '\ e-mail\ \ \ + \ + Affichage des identifiants\ + \ + \ + \ + \ ' : '') + '\ \ \ @@ -115,4 +131,5 @@ return '\ \ \ ' -} \ No newline at end of file +} + diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 298db8d..c836776 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -14,6 +14,7 @@ % Instructions pour créer une nouvelle base : % $erl -sname yaws -mnesia dir '"/projets/euphorik/BD"' +% voir doc/installation.txt % >l(euphorik_bd). % >euphorik_bd:create(). create() -> @@ -83,7 +84,17 @@ vers_version(5) -> end, record_info(fields, user), user - ). + ); +% Ajout le format d'affichage des pseudos +vers_version(6) -> + mnesia:transform_table( + user, + fun({user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, Indice_flood, Page_Principale, Conversations}) -> + {user, Id, Cookie, Pseudo, Login, Password, Email, Date_creation, Date_derniere_connexion, Css, nick, Indice_flood, Page_Principale, Conversations} + end, + record_info(fields, user), + user + ). % exemple de peuplage de la BD, utilisé pour les tests diff --git a/modules/erl/euphorik_minichat.erl b/modules/erl/euphorik_minichat.erl index 2e2f406..519870c 100755 --- a/modules/erl/euphorik_minichat.erl +++ b/modules/erl/euphorik_minichat.erl @@ -28,7 +28,7 @@ est_une_reponse_a_user/2, % set : update_pseudo_user/2, - set_profile/8, + set_profile/9, update_date_derniere_connexion/1, nouveau_user/2, nouveau_user/3, @@ -196,33 +196,38 @@ update_pseudo_user(UserId, Pseudo) -> % 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, Page_principale, Conversations) -> - resultat_transaction(mnesia:transaction( - fun() -> - case user_by_cookie(Cookie) of - {ok, User} -> - case user_by_login(Login) of - {ok, U} when U#user.id =/= User#user.id -> - login_deja_pris; - _ -> - User_modifie = User#user{ - % TODO : pourquoi ne pas tester avec la valeur "undefined" plutôt qu'avec "is_list" ? - % TODO : validation plus strict des données (pas de page négative dans les conv par exemple) - login = if is_list(Login) -> Login; true -> User#user.login end, - password = if is_list(Password) -> Password; true -> User#user.password end, - pseudo = if is_list(Pseudo) -> Pseudo; true -> User#user.pseudo end, - email = if is_list(Email) -> Email; true -> User#user.email end, - css = if is_list(Css) -> Css; true -> User#user.css end, - 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 - }, - mnesia:write(User_modifie), - ok - end; - _ -> erreur - end - end - )). +set_profile(Cookie, Login, Password, Pseudo, Email, Css, Page_principale, Nick_format, 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} -> + case user_by_login(Login) of + {ok, U} when U#user.id =/= User#user.id -> + login_deja_pris; + _ -> + User_modifie = User#user{ + % TODO : pourquoi ne pas tester avec la valeur "undefined" plutôt qu'avec "is_list" ? + % TODO : validation plus strict des données (pas de page négative dans les conv par exemple) + login = if is_list(Login) -> Login; true -> User#user.login end, + password = if is_list(Password) -> Password; true -> User#user.password end, + pseudo = if is_list(Pseudo) -> Pseudo; true -> User#user.pseudo end, + 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, + 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 + }, + mnesia:write(User_modifie), + ok + end; + _ -> erreur + end + end + )); + true -> + erreur + end. % Met à jour la date de la dernière connexion d'un utilisateur à maintenant diff --git a/modules/erl/euphorik_minichat_conversation.erl b/modules/erl/euphorik_minichat_conversation.erl index d264bcc..eb154ee 100755 --- a/modules/erl/euphorik_minichat_conversation.erl +++ b/modules/erl/euphorik_minichat_conversation.erl @@ -13,6 +13,8 @@ conversations/4 ]). +-compile(export_all). + -include("euphorik_bd.hrl"). -include_lib("stdlib/include/qlc.hrl"). @@ -222,7 +224,7 @@ conversation(Messages, [M | Reste], X) -> true -> Enfants = enfants(M), Parents = parents(M), - % un message est dit exiterne si un de ses parent ne fait pas partie de la conversation ou si un de ses parents fait partie de X + % un message est dit externe si un de ses parent ne fait pas partie de la conversation ou si un de ses parents fait partie de X Est_message_externe = Parents -- Messages =/= [] orelse intersection(Parents, X) =/= [], conversation([M | Messages], Reste ++ Enfants, if Est_message_externe -> [M | X]; true -> X end) end; diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index 154c7d4..c2cb984 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -45,7 +45,10 @@ loginUser({ok, User}) -> euphorik_minichat:update_date_derniere_connexion(User#user.id), json_reponse_login_ok(User); loginUser(_) -> - erreur("Erreur login"). + % ajoute un délais d'attente (TODO : un autre moyen plus élégant ?) + receive after 1000 -> + erreur("Erreur login") + end. % Renvoie un string() représentant un cookie en base 36. Il y a 10^32 possibillités. @@ -69,6 +72,7 @@ profile( {nick, Pseudo}, {email, Email}, {css, Css}, + {nick_format, Nick_format_str}, {main_page, Main_page}, {conversations, {array, Conversations_json}} ] @@ -86,7 +90,7 @@ profile( [], Conversations_json ), - case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css, Main_page, Conversations) of + case euphorik_minichat:set_profile(Cookie, Login, Password, Pseudo, Email, Css, list_to_atom(Nick_format_str), Main_page, Conversations) of ok -> json_reponse_ok(); login_deja_pris -> @@ -245,6 +249,7 @@ json_reponse_login_ok(User) -> {login, User#user.login}, {email, User#user.email}, {css, User#user.css}, + {nick_format, atom_to_list(User#user.nick_format)}, {main_page, User#user.page_principale}, {conversations, {array, diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl index 13a86cb..7ee5c7d 100755 --- a/modules/erl/euphorik_requests.erl +++ b/modules/erl/euphorik_requests.erl @@ -12,8 +12,9 @@ -include_lib("xmerl/include/xmerl.hrl"). -include_lib("yaws/include/yaws_api.hrl"). + -% Test du module +% Test du module (TODO) tester() -> que_dal. @@ -22,15 +23,13 @@ tester() -> out(A) -> %inet:setopts(A#arg.clisock, inet:getopts(A#arg.clisock, [active])), {value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)), - Ret = traiter_donnees(Contenu), - %{content, "text/xml", Ret}. + Ret = traiter_donnees(Contenu), {content, "application/json", Ret}. traiter_donnees(Contenu) -> case json:decode_string(Contenu) of {ok, {struct, [{action, Action}| Reste]}} -> - %io:format("~p~n", [euphorik_protocole:login(JSON)]), json:encode(traiter_action(Action, Reste)); _ -> error diff --git a/modules/include/euphorik_bd.hrl b/modules/include/euphorik_bd.hrl index 841d7a4..173ab09 100755 --- a/modules/include/euphorik_bd.hrl +++ b/modules/include/euphorik_bd.hrl @@ -40,6 +40,7 @@ date_creation, % erlang:now() 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' 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