+ "troll_added" : function(data){ thisPageAdmin.trolls.ajouterTrollEvent(data); },
+ "troll_modified" : function(data){ thisPageAdmin.trolls.modifierTrollEvent(data); },
+ "troll_deleted" : function(data){ thisPageAdmin.trolls.supprimerTrollEvent(data); },
+ "banned_ips_refresh" : function(data){ thisPageAdmin.majIPs(); },
+ "error" :
+ function(data) {
+ thisTrolls.util.messageDialogue(data.error_message);
+ }
+ }
+ );
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Représente un troll, pas grand chose finalement.
+ */
+euphorik.Troll = function(content, author) {
+ this.content = content;
+ this.author = author;
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+euphorik.Trolls = function(client, util, formateur, communication) {
+ this.client = client;
+ this.util = util;
+ this.formateur = formateur;
+ this.communication = communication;
+ this.dernierTroll = 0;
+
+ this.trolls = {};
+};
+
+euphorik.Trolls.prototype.ajouterTrollEvent = function(data) {
+ var thisTrolls = this;
+
+ var XHTML = "";
+ data.trolls.each(function(i, trollData) {
+ var troll = new euphorik.Troll(trollData.content, trollData.author);
+ var trollId = trollData.troll_id;
+ thisTrolls.trolls[trollId] = troll;
+
+ XHTML +=
+ '<div id="troll' + trollId + '" class="troll">' +
+ '<span class="content">' + thisTrolls.formateur.traitementComplet(troll.content, troll.author) + '</span>' +
+ '<span class="author"> - ' + thisTrolls.formateur.traitementComplet(troll.author) + '</span>' +
+ (trollData.author_id === thisTrolls.client.id ? '<span class="editTroll">éditer</span><span class="delTroll">Supprimer</span>' : '') +
+ '</div>';
+ });
+ $("#trolls").append(XHTML);
+ $("#trolls .troll").filter(function() { return parseInt($(this).attr("id").substr(5), 10) > thisTrolls.dernierTroll; }).each(
+ function() {
+ var troll = this;
+ var id = parseInt($(this).attr("id").substr(5), 10);
+
+ $("a[@rel*=lightbox]", this).lightBox();
+
+ $(this).keypress(
+ function(e) {
+ if (e.which === 13) { // return
+ $(".modifier", this).click();