From c39e55c505a27e30209fcfb6d837d6ec8a82b990 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sat, 19 Apr 2008 10:33:52 +0000 Subject: [PATCH] =?utf8?q?FIX=20il=20manquait=20le=20dernier=20message=20?= =?utf8?q?=C3=A0=20l'affichage=20(probl=C3=A8me=20dans=20euphorik=5Fminich?= =?utf8?q?at=5Fconversatio.erl)=20FIX=20le=20nombre=20de=20message=20max?= =?utf8?q?=20n'=C3=A9tait=20pas=20connu=20par=20la=20classe=20Conversation?= =?utf8?q?=20dans=20pageMinichat.js=20MOD=20maj=20de=20la=20css=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- css/1/pageMinichat.css | 223 ++++++------ css/2/euphorik.css | 7 +- css/2/pageMinichat.css | 320 +++++++++++------- doc/TODO.txt | 10 +- doc/protocole3.txt | 31 +- js/euphorik.js | 6 +- js/pageMinichat.js | 57 ++-- .../erl/euphorik_minichat_conversation.erl | 11 +- modules/erl/euphorik_protocole.erl | 21 +- modules/erl/euphorik_requests.erl | 6 +- 10 files changed, 385 insertions(+), 307 deletions(-) diff --git a/css/1/pageMinichat.css b/css/1/pageMinichat.css index 3a02bf9..862feee 100755 --- a/css/1/pageMinichat.css +++ b/css/1/pageMinichat.css @@ -13,37 +13,37 @@ height: 100%; background-color: #0c2003; } - -#page.minichat #smiles img { - cursor: pointer; - opacity: 0.5; -} + +#page.minichat #smiles img { + cursor: pointer; + opacity: 0.5; +} #page.minichat .titreSmiles:hover { background-color: #2d8800; -} - -#page.minichat form { - text-align: left; - margin-bottom: 15px; - padding-left: 10px; -} - -#page.minichat form .pseudo { - margin-right: 5px; -} - -#page.minichat form .message { - margin-right: 5px; -} - -#page.minichat form .return { - height: 15px; - width: 32px; - background-image: url(../../img/css1/return.png); - background-repeat: no-repeat; - background-position: 5px 2px; - vertical-align: top; +} + +#page.minichat form { + text-align: left; + margin-bottom: 15px; + padding-left: 10px; +} + +#page.minichat form .pseudo { + margin-right: 5px; +} + +#page.minichat form .message { + margin-right: 5px; +} + +#page.minichat form .return { + height: 15px; + width: 32px; + background-image: url(../../img/css1/return.png); + background-repeat: no-repeat; + background-position: 5px 2px; + vertical-align: top; } /* voir pour l'astuce css "float left" des conversations : http://www.quirksmode.org/css/clearing.html */ @@ -58,60 +58,49 @@ border-color: white; float: left; width: 100%; -} +} -#page.minichat #conversations div.message { - border-left-width: 5px; - border-left-style: solid; +#page.minichat #conversations div.message { + border-left-width: 5px; + border-left-style: solid; border-color: transparent; text-align: left; padding-right: 5px; - padding-left: 4px; + padding-left: 4px; cursor: pointer; } - -#page.minichat #conversations div.messageImpair { - background-color: #05002c; -} - -#page.minichat #conversations div.messagePair { - background-color: #080047; -} - -/* Il n'y a plus de mise en evidence -#page.minichat #conversations div.miseEnEvidenceReponse { - background-color: #bd7a11; -} -#page.minichat #conversations div.miseEnEvidenceCourant { - background-color: #bd1129; -} -#page.minichat #conversations div.miseEnEvidenceConversation { - background-color: #b711bd; -}*/ - + +#page.minichat #conversations div.messageImpair { + background-color: #05002c; +} + +#page.minichat #conversations div.messagePair { + background-color: #080047; +} + #page.minichat #conversations div.cache { - opacity: 0.3; - - /* Hack IE 7 */ - filter: alpha(opacity = 30); + opacity: 0.3; + + /* Hack IE 7 */ + filter: alpha(opacity = 30); zoom: 1 } - -#page.minichat #conversations div.reponse { - border-color: #bd7a11 -} -#page.minichat #conversations div.repondu { - border-color: #b711bd -} -#page.minichat #conversations div.proprietaire { - border-color: #bd1129 + +#page.minichat #conversations div.reponse { + border-color: #bd7a11 +} +#page.minichat #conversations div.repondu { + border-color: #b711bd +} +#page.minichat #conversations div.proprietaire { + border-color: #bd1129 } #page.minichat #conversations div.systeme { background-color: #555555 -} - -#page.minichat div.message a { - font-weight: bold; +} + +#page.minichat div.message a { + font-weight: bold; } #page.minichat div.message .lienConv { @@ -122,39 +111,39 @@ #page.minichat div.message .lienConv:hover { color: #f1c060 -} - -#page.minichat .date { - color: #fd913b; - margin-right: 3px; - margin-left: 3px; -} - -#page.minichat div.message .pseudo, -#page.minichat form .pseudo { - margin-left: 4px; - margin-right: 2px; - font-weight: bold; - color: #76ff33; +} + +#page.minichat .date { + color: #fd913b; + margin-right: 3px; + margin-left: 3px; +} + +#page.minichat div.message .pseudo, +#page.minichat form .pseudo { + margin-left: 4px; + margin-right: 2px; + font-weight: bold; + color: #76ff33; } #page.minichat div.systeme .pseudo { color: #CCCCCC -} - -/* Ca marche pas :( -#page.minichat div.message .pseudo { - min-width: 50px; - height:100px; -}*/ +} + +/* Ca marche pas :( +#page.minichat div.message .pseudo { + min-width: 50px; + height:100px; +}*/ #page.minichat #conversations .repondA { margin-left: 4px; color: #bd7a11 } - -/*#page.minichat #conversations .contenu { - display: inline; + +/*#page.minichat #conversations .contenu { + display: inline; }*/ #page.minichat #conversations .extraire { @@ -179,7 +168,7 @@ padding-left: 5px; background-color: #c90000; cursor: pointer; -} +} #page.minichat #conversations .titre .fermer:hover { background-color: #c95656 @@ -210,25 +199,25 @@ #page.minichat #conversations .titre .numPage:hover { background-color: #7c6e2e } - -#page.minichat #pages { - margin-top: 10px; -} - -#page.minichat #pages span { - padding-right : 4px; - padding-left: 4px; - color: #7664ff; - cursor:pointer; -} - -#page.minichat #pages span.pageCourante { - font-weight: bold; - font-size: 150%; -} - -#page.minichat #pages span:hover { - font-size: 150%; - color: #ffad0f; -} - + +#page.minichat #pages { + margin-top: 10px; +} + +#page.minichat #pages span { + padding-right : 4px; + padding-left: 4px; + color: #7664ff; + cursor:pointer; +} + +#page.minichat #pages span.pageCourante { + font-weight: bold; + font-size: 150%; +} + +#page.minichat #pages span:hover { + font-size: 150%; + color: #ffad0f; +} + diff --git a/css/2/euphorik.css b/css/2/euphorik.css index a0d3743..3213b74 100755 --- a/css/2/euphorik.css +++ b/css/2/euphorik.css @@ -19,11 +19,10 @@ body { #container { position: relative; - width: 700px; height: auto; - margin-left: auto; - margin-right: auto; - margin-top: 20px; + margin-left: 10px; + margin-right: 10px; + margin-top: 40px; } #menu { diff --git a/css/2/pageMinichat.css b/css/2/pageMinichat.css index 2bbfbeb..d9ae80a 100755 --- a/css/2/pageMinichat.css +++ b/css/2/pageMinichat.css @@ -16,149 +16,217 @@ height: 100%; background-color: #FFFFFF; } - -#page.minichat #smiles img { - cursor: pointer; + +#page.minichat #smiles img { + cursor: pointer; opacity: 0.5; - margin-right:1px; -} + margin-right:1px; +} #page.minichat .titreSmiles:hover { background-color: #2d8800; -} - -#page.minichat form { - text-align: left; - margin-bottom: 15px; - padding-left: 10px; -} - -#page.minichat form .pseudo { - margin-right: 5px; -} - -#page.minichat form .message { - margin-right: 5px; -} - -#page.minichat form .return { - height: 15px; +} + +#page.minichat form { + text-align: left; + margin-bottom: 15px; + padding-left: 10px; +} + +#page.minichat form .pseudo { + margin-right: 5px; +} + +#page.minichat form .message { + margin-right: 5px; +} + +#page.minichat form .return { + height: 15px; width: 32px; - background-color: #BBBBBB; - background-image: url(../../img/css1/return.png); - background-repeat: no-repeat; - background-position: 5px 2px; - vertical-align: top; -} - -#page.minichat #messages div.message { - border-left-width: 5px; - border-left-style: solid; + background-color: #BBBBBB; + background-image: url(../../img/css1/return.png); + background-repeat: no-repeat; + background-position: 5px 2px; + vertical-align: top; +} + +/* voir pour l'astuce css "float left" des conversations : http://www.quirksmode.org/css/clearing.html */ +#page.minichat #conversations { + overflow: hidden; + width: 100% +} + +#page.minichat #conversations .conversation { + border-width: 0px; + border-style: solid; + border-color: white; + float: left; + width: 100%; +} + +#page.minichat #conversations div.message { + border-left-width: 5px; + border-left-style: solid; border-color: transparent; text-align: left; - padding-right: 8px; - padding-left: 4px; + padding-right: 5px; + padding-left: 4px; cursor: pointer; } - -#page.minichat #messages div.messageImpair { - background-color: #e4e1ff; -} - -#page.minichat #messages div.messagePair { - background-color: #eceaf7; -} - -/* Il n'y a plus de mise en evidence -#page.minichat #messages div.miseEnEvidenceReponse { - background-color: #bd7a11; -} -#page.minichat #messages div.miseEnEvidenceCourant { - background-color: #bd1129; -} -#page.minichat #messages div.miseEnEvidenceConversation { - background-color: #b711bd; -}*/ + +#page.minichat #conversations div.messageImpair { + background-color: #e4e1ff; +} + +#page.minichat #conversations div.messagePair { + background-color: #eceaf7; +} + +#page.minichat #conversations div.cache { + opacity: 0.3; -#page.minichat #messages div.cache { - opacity: 0.3; - - /* Hack IE 7 */ - filter: alpha(opacity = 30); + /* Hack IE 7 */ + filter: alpha(opacity = 30); zoom: 1 } - -#page.minichat #messages div.reponse { - border-color: #d2ad73 -} -#page.minichat #messages div.repondu { - border-color: #d066d4 -} -#page.minichat #messages div.proprietaire { - border-color: #d74a5e -} -#page.minichat #messages div.systeme { + +#page.minichat #conversations div.reponse { + border-color: #d2ad73 +} +#page.minichat #conversations div.repondu { + border-color: #d066d4 +} +#page.minichat #conversations div.proprietaire { + border-color: #d74a5e +} +#page.minichat #conversations div.systeme { background-color: #b1b1b1 -} - -#page.minichat div.message a { - font-weight: bold; -} - -#page.minichat .date { - display: inline; - color: #cf6f21; - margin-right: 3px; - margin-left: 3px; -} - -#page.minichat div.message .pseudo, -#page.minichat form .pseudo { - display: inline; - margin-left: 4px; - margin-right: 2px; - font-weight: bold; - color: #2b5715; +} + +#page.minichat div.message a { + font-weight: bold; +} + +#page.minichat div.message .lienConv { + color: #db960f; + font-weight: bold; + cursor: pointer +} + +#page.minichat div.message .lienConv:hover { + color: #f1c060 +} + +#page.minichat .date { + color: #cf6f21; + margin-right: 3px; + margin-left: 3px; +} + +#page.minichat div.message .pseudo, +#page.minichat form .pseudo { + margin-left: 4px; + margin-right: 2px; + font-weight: bold; + color: #2b5715; } #page.minichat div.systeme .pseudo { color: #CCCCCC -} - -/* Ca marche pas :( -#page.minichat div.message .pseudo { - min-width: 50px; - height:100px; -}*/ - -#page.minichat #messages .repondA { - display: inline; +} + +/* Ca marche pas :( +#page.minichat div.message .pseudo { + min-width: 50px; + height:100px; +}*/ + +#page.minichat #conversations .repondA { margin-left: 4px; color: #95600d } - -#page.minichat #messages .contenu { - display: inline; -} - -#page.minichat #pages { - margin-top: 10px; -} - -#page.minichat #pages span { - padding-right : 5px; - padding-left: 5px; - color: #7169ae; - cursor:pointer; -} - -#page.minichat #pages span.pageCourante { - font-weight: bold; - font-size: 150%; -} - -#page.minichat #pages span:hover { - font-size: 150%; - color: #ada9cf; -} - + +/*#page.minichat #conversations .contenu { + display: inline; +}*/ + +#page.minichat #conversations .extraire { + float: right; + padding-right: 2px; + padding-left: 2px; + background-color: #cac5f8; +} + +#page.minichat #conversations .extraire:hover { + background-color: #dfdcfd; + color: #a2a2a2 +} + +#page.minichat #conversations .titre { + padding-right: 8px; + background-color: #dedde8 +} + +#page.minichat #conversations .titre .fermer { + float: right; + padding-right: 5px; + padding-left: 5px; + background-color: #cac5f8; + color: #ff0000; + cursor: pointer; +} + +#page.minichat #conversations .titre .fermer:hover { + background-color: #dddaf8; + color: #ffAAAA; +} + +#page.minichat #conversations .titre .next, +#page.minichat #conversations .titre .prev { + display: none; +} + +#page.minichat #conversations .titre .lien { + float: right +} + +#page.minichat #conversations .titre .lien, +#page.minichat #conversations .titre .next, +#page.minichat #conversations .titre .prev, +#page.minichat #conversations .titre .numPage { + background-color: #cac5f8; + cursor: pointer; + padding-right: 5px; + padding-left: 5px; +} + +#page.minichat #conversations .titre .lien:hover, +#page.minichat #conversations .titre .next:hover, +#page.minichat #conversations .titre .prev:hover, +#page.minichat #conversations .titre .numPage:hover { + background-color: #dddaf8; + color: #a2a2a2; +} + +#page.minichat #pages { + margin-top: 10px; +} + +#page.minichat #pages span { + padding-right : 4px; + padding-left: 4px; + color: #7169ae; + cursor:pointer; +} + +#page.minichat #pages span.pageCourante { + font-weight: bold; + font-size: 150%; +} + +#page.minichat #pages span:hover { + font-size: 150%; + color: #ada9cf; +} + diff --git a/doc/TODO.txt b/doc/TODO.txt index 05a9702..2c7a753 100755 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -6,7 +6,11 @@ [ok] Supprimer l'envoie de la description des conversations lors du refresh ainsi que modifié la manière de créer les conversations (maj des diagrammes de séquence) [ok] Navigation vers les pages précédentes [ok] Lien vers une conversation dans les messages sous cette forme {5F}. Le clic dessus ouvre la conversation. Egalement un bouton sur chaque conversation pour insérer son lien dans le message en cours de rédaction - * Mettre à jour la CSS de chaque skin + * Mettre à jour la CSS de chaque skin +* Flush le profil lors du déchargement de la page +* Envoyer les infos des conversations avec l'attente d'events +* Problème de rafraichissement des couleurs des messages auquels on répond +* Changer les noms des css : Light -> Cold, Old -> Classic * Remplacer l'XML par du JSON. gain en simplicité et en temps d'execution. * Tester sur un prototype : l'authentification * Si concluant passage complet à JSON @@ -34,7 +38,8 @@ * http://forum-images.hardware.fr/icones/ohwell.gif * Un statut "EK" avec plein de privilège à la con. (avoir une petite étoile à coté de son nick ou le nick d'une certaine couleur) * Finir le script de mise en production - * Compatage des js lors de la mise en production (afin d'optimiser la bande passante lors de l'accès au site), regarder comment fait jQuery. + * Compatage des js lors de la mise en production (afin d'optimiser la bande passante lors de l'accès au site), regarder comment fait jQuery. + * modifier le script pour virer les lignes matchant /^\W*;;;.*$/ * Traiter les tags TODO et FIXME dans le code * Cleaner le code (erl, js, xhtml, css) et eventuellement profiler un peu (le refresh est lent sous opera) * Restructurer le code Erlang : déplacer certaines fonctions d'un module à l'autre (ev. créer des modules) @@ -142,6 +147,7 @@ [2] Après un register le pseudo est effacé - le pseudo n'est pas mémorisé dans le profil lors d'un envoie de mess en l'ayant changé [2] cliquer sur les smiles ne marche pas sous IE [2] le return ne marche pas sous IE +[3] Traiter le cas ou le cookie n'existe pas coté serveur (et plus généralement traiter tous les cas d'inputs exeptionnels) [3] "Return" ne marche pas sous safari [3] Amélioration des requêtes MNESIA, voir : http://mail.google.com/mail/#label/Erlang+mailing-list/117f688280569a58 [3] la page est completement rechargé après avoir submité le profile dans opera diff --git a/doc/protocole3.txt b/doc/protocole3.txt index 4cf6255..6126502 100644 --- a/doc/protocole3.txt +++ b/doc/protocole3.txt @@ -2,16 +2,14 @@ Euphorik - Protocole v3 ----------------------- A. Introduction ---------------- - +--------------- Ce document a pour but de décrire la communication client-serveur du site euphorik. Les messages échangés sont basés sur le format JSON. Ce document remplace 'protocole2.txt'. -B. Principe ------------ - +B. Principes +------------ Enregistrement: * Permet de créer un compte, un cookie est donné en retour. Ce cookie doit être stocké par le client pour pouvoir s'authentifier par la suite. @@ -22,14 +20,14 @@ Authentification: Rafraichissement: * Le client envoie une demande au serveur avec l'id du dernier message (via XMLHttpRequest ou un function de JQuery) * Le serveur maintient la connexion bloquée si le client est à jour. - * Dès qu'un nouveau message arrive, le serveur débloque la connexion est envoie le ou les messages manquants. + * Dès qu'un nouveau message arrive, le serveur débloque la connexion et envoie le ou les messages manquants. C. Protocole ------------ c : client s : server -Les messages client vers serveur sont envoyé par HTTP-POST +Les messages client vers serveur sont envoyés par HTTP-POST. C.1. Login @@ -67,7 +65,7 @@ s -> c "main_page" : 1, "conversations" : [ { - "racine" : 123, + "root" : 123, "page" : 1 } ], @@ -97,14 +95,14 @@ c -> s "pseudo" : "Paul", "email" : "paul@pierre.com", "css" : "css/3/euphorik.css", - "mainPage" : "1", + "mainPage" : 1, "conversations" : [ { - "racine" : "4F", + "root" : 123, "page" : 1 } - ], - } + ] + } s -> c { @@ -123,7 +121,14 @@ c -> s "action" : "wait_event", "cookie" : "LKJDLAKSJBFLKASN", "message_count" : 10, - "last_message_id" : 163 + "last_message_id" : 163, + "mainPage" : 1, + "conversations" : [ + { + "root" : 123, + "page" : 1 + } + ] } s -> c diff --git a/js/euphorik.js b/js/euphorik.js index 5ce9357..c880e8f 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -704,7 +704,7 @@ Client.prototype.enregistrement = function(login, password) Client.prototype.connexion = function(action) { - //action.action.dump() + action.action.dump("Connexion client") thisClient = this jQuery.ajax( { @@ -716,7 +716,7 @@ Client.prototype.connexion = function(action) success: function(data) { - //thisClient.util.serializer.serializeToString(data).dump("Charger client") + thisClient.util.serializer.serializeToString(data).dump("Charger client") thisClient.chargerDonnees(data) } } @@ -779,7 +779,7 @@ Client.prototype.flush = function(async) async = true thisClient = this - //this.util.xmlVersAction(this.getXMLProfile()).action.dump("Flush client") + this.util.xmlVersAction(this.getXMLProfile()).action.dump("Flush client") jQuery.ajax( { async: async, diff --git a/js/pageMinichat.js b/js/pageMinichat.js index 454b357..f6b73c0 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -103,8 +103,8 @@ PageMinichat.prototype.charger = function() PageMinichat.prototype.decharger = function() { - if (this.attenteCourante != null) - this.attenteCourante.abort() + //alert(this.attenteCourante) + this.messages.stopAttenteCourante() } PageMinichat.prototype.getXMLMessage = function(pseudo, message, repondA) @@ -140,7 +140,9 @@ PageMinichat.prototype.getXMLMessage = function(pseudo, message, repondA) } PageMinichat.prototype.envoyerMessage = function(pseudo, message) -{ +{ + var thisPageMinichat = this + // (un pseudo vide est autorisé) pseudo = this.formateur.filtrerInputPseudo(pseudo) @@ -152,15 +154,6 @@ PageMinichat.prototype.envoyerMessage = function(pseudo, message) for(var i = 0; i < tags.length; i++) repondA.push(/\{(.*?)\}>/.exec(tags[i])[1]) message = message.replace(this.regexMessageTagReplace, "") - - // met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) - for (var i = 0; i < repondA.length; i++) - { - jQuery("#conversation div#" + repondA[i]).addClass("repondu") - for (var c = 0; c < this.messages.conversations.length; c++) - for (var m = 0; m < this.messages.conversations[c].messages.length; m++) - this.messages.conversations[c].messages[m].clientARepondu = true - } } message = message.trim() @@ -185,8 +178,21 @@ PageMinichat.prototype.envoyerMessage = function(pseudo, message) dataType : "xml", success : function(data, textStatus) { - if(jQuery("statut", data.documentElement).text() == "ok") - jQuery("form input.message").val("") + if(jQuery("statut", data.documentElement).text() == "ok") + { + jQuery("form input.message").val("") + + // met à jour la classe des messages auquel repond celui ci (c'est un peu de la triche) + for (var i = 0; i < repondA.length; i++) + { + jQuery("#conversations div#" + repondA[i]).addClass("repondu") + /* Ca sert à rien, TODO : tester/virer + for (var c = 0; c < thisPageMinichat.messages.conversations.length; c++) + for (var m = 0; m < thisPageMinichat.messages.conversations[c].messages.length; m++) + thisPageMinichat.messages.conversations[c].messages[m].clientARepondu = true + */ + } + } } } ) @@ -302,6 +308,8 @@ function Conversation(num, util, formateur) this.formateur = formateur this.messages = new Array() this.messagesParId = new Object() + + this.nbMessageMax = conf.nbMessageAffiche // Le nombre de message affiché par page jQuery("#conversations").append( '
\ @@ -450,8 +458,9 @@ Conversation.prototype.flush = function(funClickExtract, funClickLienConv) // enlève les messages exedentaires var nbMessagesAffiche = jQuery("#conversations #" + this.getId() + " .message").size() + if (nbMessagesAffiche > this.nbMessageMax) - jQuery("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).empty(); + jQuery("#conversations #" + this.getId() + " .message").slice(this.nbMessageMax, nbMessagesAffiche).empty() // Ajoute les événements liés à chaque message jQuery("#conversations #" + this.getId() + " .message").filter(function(){return parseInt(jQuery(this).attr("id"), 36) > parseInt(idDernierMessageAffiche, 36)}).each( @@ -753,6 +762,15 @@ Messages.prototype.viderMessages = function() this.conversations[i].viderMessages() } +/** + * Arrete l'attente courante s'il y en a une. + */ +Messages.prototype.stopAttenteCourante = function() +{ + if (this.attenteCourante != null) + this.attenteCourante.abort() +} + /** * Met à jour les messages de manière continue. * (AJAX-Comet-style proof) @@ -762,16 +780,15 @@ Messages.prototype.rafraichirMessages = function(vider) { var thisMessages = this // caisupair javacrypte - if (this.attenteCourante != null) - this.attenteCourante.abort() - if (vider == undefined) vider = false + + this.stopAttenteCourante() if (vider) this.idDernierMessage = null - this.util.xmlVersAction(this.getXMLrafraichirMessages()).action.dump("Client") + ;;; this.util.xmlVersAction(this.getXMLrafraichirMessages()).action.dump("Client") this.attenteCourante = jQuery.ajax({ type: "POST", url: "request", @@ -780,7 +797,7 @@ Messages.prototype.rafraichirMessages = function(vider) success: function(data) { - thisMessages.util.serializer.serializeToString(data).dump("Serveur") + ;;; thisMessages.util.serializer.serializeToString(data).dump("Serveur") if (vider) thisMessages.viderMessages() diff --git a/modules/erl/euphorik_minichat_conversation.erl b/modules/erl/euphorik_minichat_conversation.erl index d455d94..982c4a3 100755 --- a/modules/erl/euphorik_minichat_conversation.erl +++ b/modules/erl/euphorik_minichat_conversation.erl @@ -113,7 +113,7 @@ mise_en_forme_conversations([{Principale, Plus_principale} | Conversations]) -> % Ajoute les parents de chaque message. % @spec mise_en_forme_conversation([integer()]) -> [{integer(), [integer()]}] mise_en_forme_conversation(Messages) -> - lists:foldl( + lists:foldr( fun(Id, Acc) -> case euphorik_minichat:message_by_id(Id) of {ok, Message} -> @@ -137,7 +137,7 @@ conversations_detailees(Racines, N, D, P) -> Curseur = qlc:cursor(q([E#minichat.id || E <- qlc:sort(table(minichat), [{order, descending}])])), {CP, Plus} = conversation_principale(Curseur, Conversations, N, P), qlc:delete_cursor(Curseur), - {reverse([M || M <- CP, M > D]), Plus} % filtre en fonction de D + {[M || M <- CP, M > D], Plus} % filtre en fonction de D end)), [Conversation_principale | Conversations]. @@ -146,11 +146,12 @@ conversations_detailees(Racines, N, D, P) -> % et la liste de conversations. % N est le nombre de messages que l'on souhaite. % P est le numéro de la page (1, 2, 3...) -% Renvoie {[Id], Plus} -% @spec conversation_principale(qlc:QueryCursor(), [Conversation_detailee()], integer(), integer()) +% @spec conversation_principale(qlc:QueryCursor(), [Conversation_detailee()], integer(), integer()) -> {[Id], Plus} conversation_principale(C, Conversations, N, P) -> - CP = conversation_principale2(C, lists:flatten(map(fun({C2, _, X, _}) -> C2 -- X end, Conversations)), N + 1, (P - 1) * N), + % on prend en message de plus pour savoir s'il y en a plus que ce que l'on désire + CP = reverse(conversation_principale2(C, lists:flatten(map(fun({C2, _, X, _}) -> C2 -- X end, Conversations)), N + 1, (P - 1) * N)), Plus = length(CP) =:= N + 1, + io:format("~p~n", [CP]), { if Plus -> [_| Suivants] = CP, diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index dba48e2..c0090a5 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -83,7 +83,7 @@ profile(Action) -> Email = case xmerl_xpath:string("email", Action) of [#xmlElement{content = [#xmlText{value = E}]}] -> E; _ -> undefined end, Css = case xmerl_xpath:string("css", Action) of [#xmlElement{content = [#xmlText{value = C}]}] -> C; _ -> undefined end, Page_principale = case xmerl_xpath:string("pagePrincipale", Action) of [#xmlElement{content = [#xmlText{value = P3}]}] -> list_to_integer(P3); _ -> undefined end, - Conversations = lists:foldl( + Conversations = lists:foldr( fun(Conv, Acc) -> [#xmlElement{content = [#xmlText{value = Id_racine_str}]}] = xmerl_xpath:string("racine", Conv), [#xmlElement{content = [#xmlText{value = Page_conv_str}]}] = xmerl_xpath:string("page", Conv), @@ -130,17 +130,7 @@ refreshMessage(Action) -> _ -> inconnu end; _ -> inconnu - end, - % extraction des conversations en [{id, page}, ..] - % Obsolète : obtenu depuis la table 'user' - %~ Conversations = lists:map( - %~ fun(Conv) -> - %~ [#xmlElement{content = [#xmlText{value = Id_racine_str}]}] = xmerl_xpath:string("racine", Conv), - %~ [#xmlElement{content = [#xmlText{value = Page_conv_str}]}] = xmerl_xpath:string("page", Conv), - %~ {erlang:list_to_integer(Id_racine_str, 36), erlang:list_to_integer(Page_conv_str)} - %~ end, - %~ xmerl_xpath:string("conversation", Action) - %~ ), + end, % accrochez-vous ca va siouxer ;) [{reponse, [{name, "refreshMessages"}], lists:map( @@ -178,7 +168,12 @@ refreshMessage(Action) -> ] } end, - euphorik_minichat_conversation:conversations(User#user.conversations, Nb_message, Dernier_id, User#user.page_principale) + euphorik_minichat_conversation:conversations( + if User =/= inconnu -> User#user.conversations; true -> [] end, + Nb_message, + Dernier_id, + if User =/= inconnu -> User#user.page_principale; true -> 1 end + ) ) }]; _ -> diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl index d6d7294..0e4b046 100755 --- a/modules/erl/euphorik_requests.erl +++ b/modules/erl/euphorik_requests.erl @@ -23,10 +23,8 @@ tester() -> %~ io:format("Login : ~p~n", [euphorik_protocole:login(XML2)]). XML = - "" - "2" - "1" - "31" + "3FSDCH0FD4ML8WEPN2B5T" + "10" "", io:format("Messages de la premières page : ~p~n", [traiter_xml(XML)]). -- 2.43.0