From: Greg Burri Date: Mon, 12 May 2008 21:53:05 +0000 (+0000) Subject: ADD Avancement sur la page d'administration (trolls) X-Git-Tag: 1.0.0^2~82 X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=6f1e9a972293544a6c92a99c9a04a509b2c7648a;p=euphorik.git ADD Avancement sur la page d'administration (trolls) --- diff --git a/doc/protocole3.txt b/doc/protocole3.txt index e553133..1a91d33 100644 --- a/doc/protocole3.txt +++ b/doc/protocole3.txt @@ -204,7 +204,6 @@ c -> s "action" : "wait_event", "page" : "admin", "last_troll" : 5 - ] } s -> c diff --git a/js/pageAdmin.js b/js/pageAdmin.js index 1611ecc..75f55a8 100644 --- a/js/pageAdmin.js +++ b/js/pageAdmin.js @@ -24,17 +24,47 @@ PageAdmin.prototype.charger = function() var thisPage = this + this.trolls = new Trolls(this.util) + this.trolls.rafraichirTrolls() + $("#page form#nouveauTroll button.return").click( function() { - } ) } /////////////////////////////////////////////////////////////////////////////////////////////////// -function Trolls() +function Trolls(util) { + this.util = util + this.dernierTroll = 0 + this.pageEvent = new PageEvent("admin", this.util) +} +Trolls.prototype.rafraichirTrolls = function() +{ + var thisTrolls = this + + this.pageEvent.waitEvent( + function() { return { "last_troll" : thisTrolls.dernierTroll }}, + function(data) + { + switch (data["reply"]) { + case "troll_added" : + var XHTML = "" + for (var i = 0; i < data["trolls"].length; i++) + { + thisTrolls.dernierTroll = data["trolls"][i]["troll_id"] + XHTML += '

' + data["trolls"][i]["content"] + '

' + } + $("#trolls").append(XHTML) + break + case "troll_modified" : + $("#trolls #troll"+data["troll_id"]).html(data["content"]) + break + } + } + ) } \ No newline at end of file diff --git a/modules/Makefile b/modules/Makefile index bd7d763..642c5ab 100755 --- a/modules/Makefile +++ b/modules/Makefile @@ -17,7 +17,7 @@ $(rep_ebin)/euphorik_requests.beam \ $(rep_ebin)/euphorik_protocole.beam \ # Module pour la gestion des données persistante la BD -$(rep_ebin)/euphorik_bd.beam: $(rep_erl)/euphorik_bd.erl $(rep_include)/euphorik_bd.hrl +$(rep_ebin)/euphorik_bd.beam: $(rep_erl)/euphorik_bd.erl $(rep_include)/euphorik_bd.hrl $(rep_include)/euphorik_defines.hrl erlc $(erlc_params) # Module permettant l'extraction des conversations du minichat @@ -29,7 +29,7 @@ $(rep_ebin)/euphorik_requests.beam: $(rep_erl)/euphorik_requests.erl erlc $(erlc_params) # Module interpretant les messages XML du client -$(rep_ebin)/euphorik_protocole.beam: $(rep_erl)/euphorik_protocole.erl +$(rep_ebin)/euphorik_protocole.beam: $(rep_erl)/euphorik_protocole.erl $(rep_include)/euphorik_defines.hrl erlc $(erlc_params) # Module pour la génération du captcha diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 7a9b582..8875973 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -587,7 +587,7 @@ can_register(IP) -> trolls() -> resultat_transaction(mnesia:transaction( fun() -> - qlc:e(qlc:q([T || T <- mnesia:table(troll)])) + qlc:e(qlc:q([T || T <- qlc:keysort(2, mnesia:table(troll))])) end )). @@ -605,7 +605,7 @@ trolls(Last_id) -> _ -> case resultat_transaction(mnesia:transaction( fun() -> - qlc:e(qlc:q([T || T <- mnesia:table(troll), T#troll.id > Last_id, T#troll.date_post =:= undefined])) + qlc:e(qlc:q([T || T <- qlc:keysort(2, mnesia:table(troll)), T#troll.id > Last_id, T#troll.date_post =:= undefined])) end )) of [] -> % pas de trolls diff --git a/modules/include/euphorik_defines.hrl b/modules/include/euphorik_defines.hrl index 779a175..9be2226 100755 --- a/modules/include/euphorik_defines.hrl +++ b/modules/include/euphorik_defines.hrl @@ -19,4 +19,4 @@ % le nombre max de troll qui peuvent être en attente d'être posté (tous les utilisateurs réunis) -define(NB_MAX_TROLL_WAITING, 10). % chaque admin peut proposer 1 seul troll à la fois --define(NB_MAX_TROLL_WAITING_BY_USER, 1). +-define(NB_MAX_TROLL_WAITING_BY_USER, 2).