diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js
index 549a81c9..4175e5df 100644
--- a/www/assets/js/callbacks.js
+++ b/www/assets/js/callbacks.js
@@ -288,6 +288,7 @@ Callbacks = {
if(tbl.children().length > 1) {
$(tbl.children()[1]).remove();
}
+ $("#loginlog_pagination").remove();
entries.sort(function(a, b) {
var x = a.names.join(",").toLowerCase();
var y = b.names.join(",").toLowerCase();
@@ -300,73 +301,25 @@ Callbacks = {
}
return x == y ? 0 : (x < y ? -1 : 1);
});
- for(var i = 0; i < entries.length; i++) {
- var tr = $("
").appendTo(tbl);
- var bantd = $(" | ").appendTo(tr);
- if(entries[i].banned) {
- bantd.text("Banned");
- tr.addClass("alert alert-error");
+ $("#loginlog").data("entries", entries);
+ if(entries.length > 20) {
+ var pag = $("").addClass("pagination span12")
+ .attr("id", "loginlog_pagination")
+ .prependTo($("#loginlog"));
+ var btns = $("").appendTo(pag);
+ for(var i = 0; i < entries.length / 20; i++) {
+ var li = $("").appendTo(btns);
+ (function(i) {
+ $("").attr("href", "javascript:void(0)")
+ .text(i+1)
+ .click(function() {
+ loadLoginlogPage(i);
+ })
+ .appendTo(li);
+ })(i);
}
- else {
- var ban = $("").addClass("btn btn-mini btn-danger")
- .text("Ban IP")
- .appendTo(bantd);
- var banrange = $("").addClass("btn btn-mini btn-danger")
- .text("Ban IP Range")
- .appendTo(bantd);
- var callback = (function(id, name) { return function() {
- console.log(id, name);
- socket.emit("banIP", {
- id: id,
- name: name,
- range: false
- });
- return false;
- } })(entries[i].id, entries[i].names[0]);
- ban.click(callback);
- var callback2 = (function(id, name) { return function() {
- console.log(id, name);
- socket.emit("banIP", {
- id: id,
- name: name,
- range: true
- });
- return false;
- } })(entries[i].id, entries[i].names[0]);
- banrange.click(callback2);
- }
- var ip = $(" | ").text(entries[i].ip).appendTo(tr);
- var name = $(" | ").text(entries[i].names).appendTo(tr);
- tr.data("names", entries[i].names);
- tr.data("banned", entries[i].banned);
- tr.click(function(ev) {
- tbl.find(".name-detail").remove();
- if(this.data("namesopen")) {
- this.data("namesopen", false);
- return;
- }
- var names = this.data("names") || [];
- for(var i = names.length-1; i >= 0; i--) {
- var detail = $("
").insertAfter(this);
- detail.addClass("name-detail");
- if(this.data("banned")) {
- detail.addClass("alert alert-error");
- }
- var buttontd = $(" | ").appendTo(detail);
- $("").addClass("btn btn-mini btn-danger")
- .text("Ban Name")
- .appendTo(buttontd)
- .click(function() {
- socket.emit("banName", {
- name: this
- });
- }.bind(names[i]));
- $(" | ").text("\"").appendTo(detail);
- $(" | ").text(names[i]).appendTo(detail);
- }
- this.data("namesopen", true);
- }.bind(tr));
}
+ loadLoginlogPage(0);
},
acl: function(entries) {
@@ -375,10 +328,31 @@ Callbacks = {
var y = b.name.toLowerCase();
return y == x ? 0 : (x < y ? -1 : 1);
});
+ $("#channelranks").data("entries", entries);
var tbl = $("#channelranks table");
if(tbl.children().length > 1) {
$(tbl.children()[1]).remove();
}
+ $("#acl_pagination").remove();
+ if(entries.length > 20) {
+ var pag = $("").addClass("pagination span12")
+ .attr("id", "acl_pagination")
+ .prependTo($("#channelranks"));
+ var btns = $("").appendTo(pag);
+ for(var i = 0; i < entries.length / 20; i++) {
+ var li = $("").appendTo(btns);
+ (function(i) {
+ $("").attr("href", "javascript:void(0)")
+ .text(i+1)
+ .click(function() {
+ loadACLPage(i);
+ })
+ .appendTo(li);
+ })(i);
+ }
+ }
+ loadACLPage(0);
+ return;
for(var i = 0; i < entries.length; i++) {
var tr = $("
").appendTo(tbl);
var name = $(" | ").text(entries[i].name).appendTo(tr);
diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js
index ee071209..220d713c 100644
--- a/www/assets/js/functions.js
+++ b/www/assets/js/functions.js
@@ -464,6 +464,12 @@ function loadSearchPage(page) {
}
$(li).appendTo($("#library"));
}
+ if($("#search_pagination").length > 0) {
+ $("#search_pagination").find("li").each(function() {
+ $(this).removeClass("active");
+ });
+ $($("#search_pagination").find("li")[page]).addClass("active");
+ }
}
function clearSearchResults() {
@@ -471,6 +477,136 @@ function clearSearchResults() {
$("#search_pagination").remove();
}
+function loadLoginlogPage(page) {
+ var entries = $("#loginlog").data("entries");
+ var start = page * 20;
+ var tbl = $("#loginlog table");
+ if(tbl.children().length > 1) {
+ $(tbl.children()[1]).remove();
+ }
+ for(var i = start; i < start + 20 && i < entries.length; i++) {
+ var tr = $("
").appendTo(tbl);
+ var bantd = $(" | ").appendTo(tr);
+ if(entries[i].banned) {
+ bantd.text("Banned");
+ tr.addClass("alert alert-error");
+ }
+ else {
+ var ban = $("").addClass("btn btn-mini btn-danger")
+ .text("Ban IP")
+ .appendTo(bantd);
+ var banrange = $("").addClass("btn btn-mini btn-danger")
+ .text("Ban IP Range")
+ .appendTo(bantd);
+ var callback = (function(id, name) { return function() {
+ console.log(id, name);
+ socket.emit("banIP", {
+ id: id,
+ name: name,
+ range: false
+ });
+ return false;
+ } })(entries[i].id, entries[i].names[0]);
+ ban.click(callback);
+ var callback2 = (function(id, name) { return function() {
+ console.log(id, name);
+ socket.emit("banIP", {
+ id: id,
+ name: name,
+ range: true
+ });
+ return false;
+ } })(entries[i].id, entries[i].names[0]);
+ banrange.click(callback2);
+ }
+ var ip = $(" | ").text(entries[i].ip).appendTo(tr);
+ var name = $(" | ").text(entries[i].names).appendTo(tr);
+ tr.data("names", entries[i].names);
+ tr.data("banned", entries[i].banned);
+ tr.click(function(ev) {
+ tbl.find(".name-detail").remove();
+ if(this.data("namesopen")) {
+ this.data("namesopen", false);
+ return;
+ }
+ var names = this.data("names") || [];
+ for(var i = names.length-1; i >= 0; i--) {
+ var detail = $("
").insertAfter(this);
+ detail.addClass("name-detail");
+ if(this.data("banned")) {
+ detail.addClass("alert alert-error");
+ }
+ var buttontd = $(" | ").appendTo(detail);
+ $("").addClass("btn btn-mini btn-danger")
+ .text("Ban Name")
+ .appendTo(buttontd)
+ .click(function() {
+ socket.emit("banName", {
+ name: this
+ });
+ }.bind(names[i]));
+ $(" | ").text("\"").appendTo(detail);
+ $(" | ").text(names[i]).appendTo(detail);
+ }
+ this.data("namesopen", true);
+ }.bind(tr));
+ }
+ if($("#loginlog_pagination").length > 0) {
+ $("#loginlog_pagination").find("li").each(function() {
+ $(this).removeClass("active");
+ });
+ $($("#loginlog_pagination").find("li")[page]).addClass("active");
+ }
+}
+
+function loadACLPage(page) {
+ var entries = $("#channelranks").data("entries");
+ var start = page * 20;
+ var tbl = $("#channelranks table");
+ if(tbl.children().length > 1) {
+ $(tbl.children()[1]).remove();
+ }
+ for(var i = start; i < start + 20 && i < entries.length; i++) {
+ var tr = $("
").appendTo(tbl);
+ var name = $(" | ").text(entries[i].name).appendTo(tr);
+ name.addClass(getNameColor(entries[i].rank));
+ var rank = $(" | ").text(entries[i].rank).appendTo(tr);
+ var control = $(" | ").appendTo(tr);
+ var up = $("").addClass("btn btn-mini btn-success")
+ .appendTo(control);
+ $("").addClass("icon-plus").appendTo(up);
+ var down = $("").addClass("btn btn-mini btn-danger")
+ .appendTo(control);
+ $("").addClass("icon-minus").appendTo(down);
+ if(entries[i].rank + 1 >= RANK) {
+ up.attr("disabled", true);
+ }
+ else {
+ up.click(function(name) { return function() {
+ socket.emit("promote", {
+ name: name
+ });
+ }}(entries[i].name));
+ }
+ if(entries[i].rank >= RANK) {
+ down.attr("disabled", true);
+ }
+ else {
+ down.click(function(name) { return function() {
+ socket.emit("demote", {
+ name: name
+ });
+ }}(entries[i].name));
+ }
+ }
+ if($("#acl_pagination").length > 0) {
+ $("#acl_pagination").find("li").each(function() {
+ $(this).removeClass("active");
+ });
+ $($("#acl_pagination").find("li")[page]).addClass("active");
+ }
+}
+
// Rearranges the queue
function moveVideo(src, dest, noanim) {
var li = $($("#queue").children()[src]);