From: Matteo Nastasi (mop) Date: Wed, 10 Jul 2013 07:00:11 +0000 (+0200) Subject: manage list update (remove too old lines) X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmoder;p=brisk.git manage list update (remove too old lines) --- diff --git a/TODO.txt b/TODO.txt index 24837eb..11edaaf 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,14 +1,17 @@ TODO | ------+ Moderation features: - * Lista righe di chat + * First and incremental list population + * Ban per nick/sessione/IP & calculation + * Richiesta di verifica - * Ban per nick/sessione/IP * Silent cancer behaviour management +DONE * Manage list update (remove too old lines) DONE * Select row DONE * Filtra per tavolo e/o room DONE * BUG: after disable/enable moderation filters stop to work +DONE * Lista righe di chat - moderation . turn off moderation when moder win is closed or if window creation fails diff --git a/web/commons.js b/web/commons.js index a5230b4..73a7539 100644 --- a/web/commons.js +++ b/web/commons.js @@ -460,13 +460,16 @@ function ModerateItem(item_ar) { var tr, td, date; + date = new Date(); + this.time = item_ar[0]; this.usrid = item_ar[1]; this.table = item_ar[2]; this.name = item_ar[3]; this.cont = item_ar[4]; - date = new Date(); + this.loctm = date.getTime(); + date.setTime(this.time * 1000); tr = document.createElement("tr"); @@ -496,7 +499,8 @@ function ModerateItem(item_ar) } ModerateItem.prototype = { - time: 0, + time: 0, // (sec) + loctm: 0, // (msec) usrid: 0, table: -1, name: "", @@ -536,6 +540,9 @@ Moderate.prototype = { room_show: true, table_show: -1, + // max_dt: 1800000, // (msec) maximum delta between current and line time + max_dt: 15000, // (msec) FIXME: DEV VERSION maximum delta between current and line time + cur: -1, disable: function () { @@ -608,6 +615,8 @@ Moderate.prototype = { add: function(item) { var mi; + this.item_gc(); + mi = new ModerateItem(item); mi.tr.className = 'normal'; @@ -619,6 +628,32 @@ Moderate.prototype = { this.table.appendChild(mi.tr_get()); }, + item_remove: function(idx) { + var old; + + old = this.item.splice(idx,1); + + if (!old[0].hide) + this.table.removeChild(old[0].tr_get()); + + delete old; + } + + // moderation items garbage collector: after this.max_dt a line is removed + item_gc: function() { + var date, time; + + date = new Date(); + time = date.getTime(); + + for (i = 0 ; i < this.item.length ; i++) { + if (time - this.item[i].loctm > this.max_dt) { + this.item_remove(i); + i--; + } + } + }, + row_select: function(mi) { for (i = 0 ; i < this.item.length ; i++) { if (this.item[i] == mi) {