X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;ds=sidebyside;f=js%2FpageAdmin.js;h=fe464b857ba547f0f1c9609075d121504b67cb28;hb=81393a74d648e4830dc8c7c562fa203f50a105f6;hp=75f55a8220af47e85823ebe1fe576a86981a4cbf;hpb=6f1e9a972293544a6c92a99c9a04a509b2c7648a;p=euphorik.git
diff --git a/js/pageAdmin.js b/js/pageAdmin.js
index 75f55a8..fe464b8 100644
--- a/js/pageAdmin.js
+++ b/js/pageAdmin.js
@@ -1,70 +1,151 @@
// coding: utf-8
+// Copyright 2008 Grégory Burri
+//
+// This file is part of Euphorik.
+//
+// Euphorik is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Euphorik is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Euphorik. If not, see
Aucune IP bannie
'; + } + + $("#ips").html(XHTML); + + $(".ban").each(function() { + var ip = $(".ip", this).html(); + $(".deban", this).click( + function() { + thisPageAdmin.util.messageDialog("Ãtes-vous sur de vouloir débannir l'IP ''" + ip + "'' ?", euphorik.Util.messageType.question, + {"Oui" : function() { + thisPageAdmin.deban(ip); + }, + "Non" : function(){} + } + ); + } + ); + }); + + // rafraichissement toutes les minutes (je sais c'est mal) + // le problème est le rafraichissement des temps restant de bannissement qui doit être fait du coté client + thisPageAdmin.timeoutIDmajIPs = setTimeout(function(){ thisPageAdmin.majIPs(); }, 60 * 1000); } - ) -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - -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) + ); +}; + +/** + * Débannie une ip donnée. + */ +euphorik.PageAdmin.prototype.deban = function(ip) { + var thisPageAdmin = this; + + this.communication.requete( + "unban", + {"cookie" : this.client.cookie, "ip" : ip} + ); +}; + +/** + * Attente d'événement de la part du serveur. + */ +euphorik.PageAdmin.prototype.waitEvent = function() { + var thisPageAdmin = this; + + this.comet.waitEvent( { - 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 - } + "banned_ips_refresh" : function(data){ thisPageAdmin.majIPs(); }, + "error" : + function(data) { + thisPage.util.messageDialog(data.error_message); + } } - ) -} \ No newline at end of file + ); +}; \ No newline at end of file