Implement ACL for channel owners (Issue #42)
This commit is contained in:
parent
d7de1fc69e
commit
bb019deeb7
10 changed files with 173 additions and 26 deletions
|
|
@ -101,6 +101,8 @@ function initCallbacks() {
|
|||
updateBanlist(data.entries);
|
||||
});
|
||||
|
||||
socket.on("acl", updateACL);
|
||||
|
||||
socket.on("voteskip", function(data) {
|
||||
if(data.count > 0) {
|
||||
$("#voteskip").text("Voteskip ("+data.count+"/"+data.need+")");
|
||||
|
|
|
|||
|
|
@ -382,41 +382,50 @@ $("#updatemotd").click(function() {
|
|||
});
|
||||
|
||||
$("#show_chancontrols").click(function() {
|
||||
$("#show_banlist").parent().removeClass("active");
|
||||
$("#show_motdeditor").parent().removeClass("active");
|
||||
$("#show_filtereditor").parent().removeClass("active");
|
||||
$("#show_chancontrols").parent().addClass("active");
|
||||
$("#modnav li").each(function() {
|
||||
$(this).removeClass("active");
|
||||
});
|
||||
$(".modonly").hide();
|
||||
$("#show_chancontrols").parent().addClass("active");
|
||||
$("#chancontrols").show();
|
||||
});
|
||||
|
||||
$("#show_banlist").click(function() {
|
||||
$("#show_chancontrols").parent().removeClass("active");
|
||||
$("#show_motdeditor").parent().removeClass("active");
|
||||
$("#show_filtereditor").parent().removeClass("active");
|
||||
$("#show_banlist").parent().addClass("active");
|
||||
$("#modnav li").each(function() {
|
||||
$(this).removeClass("active");
|
||||
});
|
||||
$(".modonly").hide();
|
||||
$("#show_banlist").parent().addClass("active");
|
||||
$("#banlist").show();
|
||||
});
|
||||
|
||||
$("#show_motdeditor").click(function() {
|
||||
$("#show_chancontrols").parent().removeClass("active");
|
||||
$("#show_banlist").parent().removeClass("active");
|
||||
$("#show_filtereditor").parent().removeClass("active");
|
||||
$("#show_motdeditor").parent().addClass("active");
|
||||
$("#modnav li").each(function() {
|
||||
$(this).removeClass("active");
|
||||
});
|
||||
$(".modonly").hide();
|
||||
$("#show_motdeditor").parent().addClass("active");
|
||||
$("#motdeditor").show();
|
||||
});
|
||||
|
||||
$("#show_filtereditor").click(function() {
|
||||
$("#show_chancontrols").parent().removeClass("active");
|
||||
$("#show_banlist").parent().removeClass("active");
|
||||
$("#show_motdeditor").parent().removeClass("active");
|
||||
$("#show_filtereditor").parent().addClass("active");
|
||||
$("#modnav li").each(function() {
|
||||
$(this).removeClass("active");
|
||||
});
|
||||
$(".modonly").hide();
|
||||
$("#show_filtereditor").parent().addClass("active");
|
||||
$("#filtereditor").show();
|
||||
});
|
||||
|
||||
$("#show_acl").click(function() {
|
||||
$("#modnav li").each(function() {
|
||||
$(this).removeClass("active");
|
||||
});
|
||||
$(".modonly").hide();
|
||||
$("#show_acl").parent().addClass("active");
|
||||
$("#channelranks").show();
|
||||
});
|
||||
|
||||
function searchLibrary() {
|
||||
socket.emit("searchLibrary", {
|
||||
query: $("#library_query").val()
|
||||
|
|
|
|||
|
|
@ -672,6 +672,50 @@ function updateChatFilters(entries) {
|
|||
add.click(cback);
|
||||
}
|
||||
|
||||
function updateACL(entries) {
|
||||
entries.sort(function(a, b) {
|
||||
var x = a.name.toLowerCase();
|
||||
var y = b.name.toLowerCase();
|
||||
return y == x ? 0 : (x < y ? -1 : 1);
|
||||
});
|
||||
var tbl = $("#channelranks table");
|
||||
if(tbl.children().length > 1) {
|
||||
$(tbl.children()[1]).remove();
|
||||
}
|
||||
for(var i = 0; i < entries.length; i++) {
|
||||
var tr = $("<tr/>").appendTo(tbl);
|
||||
var name = $("<td/>").text(entries[i].name).appendTo(tr);
|
||||
name.addClass(getNameColor(entries[i].rank));
|
||||
var rank = $("<td/>").text(entries[i].rank).appendTo(tr);
|
||||
var control = $("<td/>").appendTo(tr);
|
||||
var up = $("<button/>").addClass("btn btn-mini btn-success")
|
||||
.appendTo(control);
|
||||
$("<i/>").addClass("icon-plus").appendTo(up);
|
||||
var down = $("<button/>").addClass("btn btn-mini btn-danger")
|
||||
.appendTo(control);
|
||||
$("<i/>").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));
|
||||
}
|
||||
}
|
||||
}
|
||||
function handleRankChange() {
|
||||
rebuildPlaylist();
|
||||
if(RANK >= Rank.Moderator || LEADER) {
|
||||
|
|
|
|||
|
|
@ -113,6 +113,9 @@
|
|||
<li>
|
||||
<a href="javascript:void(0)" id="show_filtereditor">Chat Filters</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0)" id="show_acl">Channel Ranks</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -199,6 +202,17 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row modonly" id="channelranks" style="display: none;">
|
||||
<div class="span10 offset1">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Rank</th>
|
||||
<th>Control</th>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="layout_buttons">
|
||||
<div class="span4 offset3">
|
||||
<div class="btn-group" style="width: 100%">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue