X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2FpageAdmin.js;h=9091d6dc238090f8513e55637c15c01de1f3208b;hp=d7d735a5de5fc3a719b292ec6103e3b24b02d252;hb=ed684a234959a278a115d4f1dc7b877e9ae9f650;hpb=cd30bb86848bd5b52c46b8a0ff40cea6398de60e diff --git a/js/pageAdmin.js b/js/pageAdmin.js index d7d735a..9091d6d 100644 --- a/js/pageAdmin.js +++ b/js/pageAdmin.js @@ -7,6 +7,8 @@ function PageAdmin(client, formateur, util) this.client = client this.formateur = formateur this.util = util + + this.timeoutIDmajIPs = null } PageAdmin.prototype.contenu = function() @@ -102,6 +104,9 @@ PageAdmin.prototype.posterTroll = function() */ PageAdmin.prototype.majIPs = function() { + if (this.timeoutIDmajIPs) + clearTimeout(this.timeoutIDmajIPs) + var thisPageAdmin = this var dataToSend = @@ -128,10 +133,10 @@ PageAdmin.prototype.majIPs = function() for(var i = 0; i < data["list"].length; i++) { var ip = data["list"][i] - XHTML += '' + ip["ip"] + '' + + XHTML += '
' + ip["ip"] + '|' + '' + ip["remaining_time"] + - '[' + '|' for(var j = 0; j < ip["users"].length; j++) { var user = ip["users"][j] @@ -139,14 +144,78 @@ PageAdmin.prototype.majIPs = function() '' + thisPageAdmin.formateur.traitementComplet(user["nick"]) + '' + (user["login"] == "" ? "" : '(' + thisPageAdmin.formateur.traitementComplet(user["login"]) + ')') } - XHTML += ']' + XHTML += 'débannir
' } + + if (data["list"].length == 0) + XHTML += '

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 + } } } ) @@ -342,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