X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=js%2FpageAdmin.js;h=9091d6dc238090f8513e55637c15c01de1f3208b;hb=696cf94315883382f4057fda2bff8b9deca70287;hp=6dc96defe198404b826239b837fd2e3139ca2080;hpb=934ab32cd6fac44f6b3ebedef69ce1ccd0b8701b;p=euphorik.git diff --git a/js/pageAdmin.js b/js/pageAdmin.js index 6dc96de..9091d6d 100644 --- a/js/pageAdmin.js +++ b/js/pageAdmin.js @@ -7,16 +7,24 @@ function PageAdmin(client, formateur, util) this.client = client this.formateur = formateur this.util = util + + this.timeoutIDmajIPs = null } PageAdmin.prototype.contenu = function() { return '
Un troll est un sujet à débat, en général une question.
\Chaque semaine un troll est choisit au hasard parmis les trolls proposés et devient le troll de la semaine.
\ - ' + \ + \ +Aucune IP bannie
' + + $("#ips").html(XHTML) + + $(".ban").each( + function() + { + var ip = $(".ip").html() + $(".deban", this).click( + function() + { + thisPageAdmin.util.messageDialogue("Ãtes-vous sur de vouloir débannir l'IP " + ip + " ?", messageType.question, + {"Oui" : function() + { + thisPageAdmin.deban(ip) + }, + "Non" : function(){} + } + ) + } + ) + } + ) + } + else if (data["reply"] == "error") + { + thisPageAdmin.util.messageDialogue(data["error_message"]) + } + + // rafraichissement toutes les minutes (je sais c'est mal) + // le problème est le rafraichissement des temps restant de bannissement qui doit êtrew fait du coté client + thisPageAdmin.timeoutIDmajIPs = setTimeout(function(){ thisPageAdmin.majIPs() }, 60 * 1000) + } + } + ) +} + +PageAdmin.prototype.deban = function(ip) +{ + var thisPageAdmin = this + + var dataToSend = + { + "action" : "unban", + "cookie" : this.client.cookie, + "ip" : ip + } + + ;;; dumpObj(dataToSend) + jQuery.ajax( + { + type: "POST", + url: "request", + dataType: "json", + data: this.util.jsonVersAction(dataToSend), + success: + function(data) + { + ;;; dumpObj(data) + switch(data["reply"]) + { + case "error" : + thisPageAdmin.util.messageDialogue(data["error_message"]) + break + case "ok" : + thisPageAdmin.majIPs() + break + } + } + } + ) +} + /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -279,6 +411,10 @@ Trolls.prototype.rafraichirTrolls = function() case "troll_deleted" : $("#trolls #troll"+data["troll_id"]).remove() break + case "majIPs" : + // TODO : mettre l'attente au niveau de la page et pas au niveau des trolls + // thisPageAdmin.majIPs() + break case "error" : thisTrolls.util.messageDialogue(data["error_message"]) break