diff --git a/channel.js b/channel.js
index a2c6fe16..9aeb9d4a 100644
--- a/channel.js
+++ b/channel.js
@@ -367,8 +367,11 @@ Channel.prototype.tryNameBan = function(actor, name) {
break;
}
}
- //this.broadcastBanlist();
this.logger.log(name + " was banned by " + actor.name);
+ var chan = this;
+ this.users.forEach(function(u) {
+ chan.sendBanlist(u);
+ });
if(!this.registered) {
return false;
}
@@ -383,9 +386,12 @@ Channel.prototype.unbanName = function(actor, name) {
this.namebans[name] = null;
delete this.namebans[name];
- //this.broadcastBanlist();
this.logger.log(name + " was unbanned by " + actor.name);
+ var chan = this;
+ this.users.forEach(function(u) {
+ chan.sendBanlist(u);
+ });
return Database.channelUnbanName(this.name, name);
}
@@ -430,6 +436,11 @@ Channel.prototype.tryIPBan = function(actor, name, range) {
// Update database ban table
return Database.channelBan(chan.name, ip, name, actor.name);
});
+
+ var chan = this;
+ this.users.forEach(function(u) {
+ chan.sendBanlist(u);
+ });
}
Channel.prototype.banIP = function(actor, receiver) {
@@ -458,6 +469,10 @@ Channel.prototype.unbanIP = function(actor, ip) {
return false;
this.ipbans[ip] = null;
+ var chan = this;
+ this.users.forEach(function(u) {
+ chan.sendBanlist(u);
+ });
if(!this.registered)
return false;
@@ -681,15 +696,12 @@ Channel.prototype.sendRankStuff = function(user) {
}
user.socket.emit("chatFilters", {filters: filts});
}
- this.sendACL(user);
+ this.sendChannelRanks(user);
}
-Channel.prototype.sendSeenLogins = function(user) {
-}
-
-Channel.prototype.sendACL = function(user) {
+Channel.prototype.sendChannelRanks = function(user) {
if(Rank.hasPermission(user, "acl")) {
- user.socket.emit("acl", Database.listChannelRanks(this.name));
+ user.socket.emit("channelRanks", Database.listChannelRanks(this.name));
}
}
@@ -805,7 +817,7 @@ Channel.prototype.broadcastNewUser = function(user) {
};
this.users.forEach(function(u) {
if(u.rank >= 2) {
- u.socket.emit("chatMsg", pkt);
+ u.socket.emit("joinMessage", pkt);
}
});
}
diff --git a/user.js b/user.js
index 3eeda81c..ca03bb32 100644
--- a/user.js
+++ b/user.js
@@ -391,10 +391,11 @@ User.prototype.initCallbacks = function() {
}
}.bind(this));
- this.socket.on("requestAcl", function() {
+ this.socket.on("requestChannelRanks", function() {
if(this.channel != null) {
- this.channel.sendACL(this);
- this.noflood("requestAcl", 0.25);
+ if(this.noflood("requestChannelRanks", 0.25))
+ return;
+ this.channel.sendChannelRanks(this);
}
}.bind(this));
diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js
index aeec406e..ff3c7311 100644
--- a/www/assets/js/callbacks.js
+++ b/www/assets/js/callbacks.js
@@ -308,21 +308,27 @@ Callbacks = {
},
channelRanks: function(entries) {
- // TODO Edit if necessary
+ var tbl = $("#channelranks table");
+ // Dammit jQuery UI
+ if(!tbl.hasClass("table")) {
+ setTimeout(function() {
+ Callbacks.channelRanks(entries);
+ }, 100);
+ return;
+ }
entries.sort(function(a, b) {
var x = a.name.toLowerCase();
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();
+ $("#channelranks_pagination").remove();
if(entries.length > 20) {
var pag = $("
").addClass("pagination span12")
- .attr("id", "acl_pagination")
+ .attr("id", "channelranks_pagination")
.prependTo($("#channelranks"));
var btns = $("").appendTo(pag);
for(var i = 0; i < entries.length / 20; i++) {
@@ -331,13 +337,13 @@ Callbacks = {
$("").attr("href", "javascript:void(0)")
.text(i+1)
.click(function() {
- loadACLPage(i);
+ loadChannelRanksPage(i);
})
.appendTo(li);
})(i);
}
}
- loadACLPage(0);
+ loadChannelRanksPage(0);
},
setChannelRank: function(data) {
@@ -349,7 +355,7 @@ Callbacks = {
}
}
$("#channelranks").data("entries", ents);
- loadACLPage($("#channelranks").data("page"));
+ loadChannelRanksPage($("#channelranks").data("page"));
},
voteskip: function(data) {
@@ -409,6 +415,11 @@ Callbacks = {
addChatMessage(data);
},
+ joinMessage: function(data) {
+ if(USEROPTS.joinmessage)
+ addChatMessage(data);
+ },
+
clearchat: function() {
$("#messagebuffer").html("");
},
diff --git a/www/assets/js/channelsettings.js b/www/assets/js/channelsettings.js
index 77927d05..88087faa 100644
--- a/www/assets/js/channelsettings.js
+++ b/www/assets/js/channelsettings.js
@@ -28,6 +28,10 @@
$("#show_loginhistory").click(function() {
socket.emit("requestLoginHistory");
});
+ clickHandler("#show_channelranks", "#channelranks");
+ $("#show_channelranks").click(function() {
+ socket.emit("requestChannelRanks");
+ });
genPermissionsEditor();
diff --git a/www/assets/js/data.js b/www/assets/js/data.js
index 9140247f..7a4c32b0 100644
--- a/www/assets/js/data.js
+++ b/www/assets/js/data.js
@@ -69,7 +69,8 @@ var USEROPTS = {
blink_title : getOrDefault("blink_title", false),
sync_accuracy : getOrDefault("sync_accuracy", 2),
chatbtn : getOrDefault("chatbtn", false),
- altsocket : getOrDefault("altsocket", false)
+ altsocket : getOrDefault("altsocket", false),
+ joinmessage : getOrDefault("joinmessage", true)
};
var Rank = {
diff --git a/www/assets/js/util.js b/www/assets/js/util.js
index 3192b993..370a1396 100644
--- a/www/assets/js/util.js
+++ b/www/assets/js/util.js
@@ -93,7 +93,7 @@ function formatUserlistItem(div, data) {
function getNameColor(rank) {
if(rank >= Rank.Siteadmin)
return "userlist_siteadmin";
- else if(rank >= Rank.Owner)
+ else if(rank >= Rank.Admin)
return "userlist_owner";
else if(rank >= Rank.Moderator)
return "userlist_op";
@@ -379,6 +379,12 @@ function showOptionsMenu() {
var modhat = $("").attr("type", "checkbox").appendTo(modhatcontainer);
modhat.prop("checked", USEROPTS.modhat);
addOption("Modflair", modhatcontainer);
+
+ var joincontainer = $("").addClass("checkbox")
+ .text("Show join messages");
+ var join = $("").attr("type", "checkbox").appendTo(joincontainer);
+ join.prop("checked", USEROPTS.joinmessage);
+ addOption("Join Messages", joincontainer);
}
var footer = $("").addClass("modal-footer").appendTo(modal);
@@ -399,6 +405,7 @@ function showOptionsMenu() {
USEROPTS.altsocket = altsocket.prop("checked");
if(CLIENT.rank >= Rank.Moderator) {
USEROPTS.modhat = modhat.prop("checked");
+ USEROPTS.joinmessage = join.prop("checked");
}
saveOpts();
modal.modal("hide");
@@ -642,6 +649,12 @@ function hasPermission(key) {
function handlePermissionChange() {
function setVisible(selector, bool) {
+ if($(selector) && $(selector).attr("id") != selector.substring(1)) {
+ setTimeout(function() {
+ setVisible(selector, bool);
+ }, 100);
+ return;
+ }
var disp = bool ? "" : "none";
$(selector).css("display", disp);
}
@@ -659,6 +672,13 @@ function handlePermissionChange() {
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
+ setVisible("#permedit_tab", CLIENT.rank >= 3);
+ setVisible("#banlist_tab", hasPermission("ban"));
+ setVisible("#motdedit_tab", hasPermission("motdedit"));
+ setVisible("#cssedit_tab", CLIENT.rank >= 3);
+ setVisible("#jsedit_tab", CLIENT.rank >= 3);
+ setVisible("#filteredit_tab", hasPermission("filteredit"));
+ setVisible("#channelranks_tab", CLIENT.rank >= 3);
}
else {
$("#channelsettingswrap").html("");
@@ -684,14 +704,6 @@ function handlePermissionChange() {
setVisible("#clearplaylist", hasPermission("playlistclear"));
setVisible("#shuffleplaylist", hasPermission("playlistshuffle"));
- setVisible("#permedit_tab", CLIENT.rank >= 3);
- setVisible("#banlist_tab", hasPermission("ban"));
- setVisible("#motdedit_tab", hasPermission("motdedit"));
- setVisible("#cssedit_tab", CLIENT.rank >= 3);
- setVisible("#jsedit_tab", CLIENT.rank >= 3);
- setVisible("#filteredit_tab", hasPermission("filteredit"));
- // TODO add acl back?
- setVisible("#recentconn_tab", CLIENT.rank >= 3);
setVisible("#newpollbtn", hasPermission("pollctl"));
@@ -1113,7 +1125,7 @@ function genPermissionsEditor() {
["Channel Admin", "3"]
];
- addDivider("Open playlist permissions");
+ $("").text("Open playlist permissions").appendTo(fs);
makeOption("Add to playlist", "oplaylistadd", standard, CHANNEL.perms.oplaylistadd+"");
makeOption("Add/move to next", "oplaylistnext", standard, CHANNEL.perms.oplaylistnext+"");
makeOption("Move playlist items", "oplaylistmove", standard, CHANNEL.perms.oplaylistmove+"");
@@ -1158,3 +1170,60 @@ function genPermissionsEditor() {
socket.emit("setPermissions", perms);
});
}
+
+function loadChannelRanksPage(page) {
+ var entries = $("#channelranks").data("entries");
+ $("#channelranks").data("page", page);
+ 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)
+ .css("min-width", "220px")
+ .appendTo(tr);
+ (function(name) {
+ rank.click(function() {
+ if(this.find(".rank-edit").length > 0)
+ return;
+ var r = this.text();
+ this.text("");
+ var edit = $("").attr("type", "text")
+ .attr("placeholder", r)
+ .addClass("rank-edit")
+ .appendTo(this)
+ .focus();
+ if(parseInt(r) >= CLIENT.rank) {
+ edit.attr("disabled", true);
+ }
+ function save() {
+ var r = this.val();
+ var r2 = r;
+ if(r.trim() == "" || parseInt(r) >= CLIENT.rank || parseInt(r) < 1)
+ r = this.attr("placeholder");
+ r = parseInt(r) + "";
+ this.parent().text(r);
+ socket.emit("setChannelRank", {
+ user: name,
+ rank: parseInt(r)
+ });
+ }
+ edit.blur(save.bind(edit));
+ edit.keydown(function(ev) {
+ if(ev.keyCode == 13)
+ save.bind(edit)();
+ });
+ }.bind(rank));
+ })(entries[i].name);
+ }
+ if($("#channelranks_pagination").length > 0) {
+ $("#channelranks_pagination").find("li").each(function() {
+ $(this).removeClass("active");
+ });
+ $($("#channelranks_pagination").find("li")[page]).addClass("active");
+ }
+}
diff --git a/www/channeloptions.html b/www/channeloptions.html
index 3ed3d382..6af32f00 100644
--- a/www/channeloptions.html
+++ b/www/channeloptions.html
@@ -12,6 +12,7 @@
CSS Editor
JS Editor
Ban List
+ Channel Ranks
Recent Connections
@@ -126,3 +127,13 @@ Filters Here
+
+
+
+
+ Name |
+ Rank (click to edit) |
+
+
+
+