mirror of https://github.com/calzoneman/sync.git
Add channel ranks editor
This commit is contained in:
parent
6f43a7efdc
commit
09e9fb2eab
30
channel.js
30
channel.js
|
@ -367,8 +367,11 @@ Channel.prototype.tryNameBan = function(actor, name) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//this.broadcastBanlist();
|
|
||||||
this.logger.log(name + " was banned by " + actor.name);
|
this.logger.log(name + " was banned by " + actor.name);
|
||||||
|
var chan = this;
|
||||||
|
this.users.forEach(function(u) {
|
||||||
|
chan.sendBanlist(u);
|
||||||
|
});
|
||||||
if(!this.registered) {
|
if(!this.registered) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -383,9 +386,12 @@ Channel.prototype.unbanName = function(actor, name) {
|
||||||
|
|
||||||
this.namebans[name] = null;
|
this.namebans[name] = null;
|
||||||
delete this.namebans[name];
|
delete this.namebans[name];
|
||||||
//this.broadcastBanlist();
|
|
||||||
this.logger.log(name + " was unbanned by " + actor.name);
|
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);
|
return Database.channelUnbanName(this.name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +436,11 @@ Channel.prototype.tryIPBan = function(actor, name, range) {
|
||||||
// Update database ban table
|
// Update database ban table
|
||||||
return Database.channelBan(chan.name, ip, name, actor.name);
|
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) {
|
Channel.prototype.banIP = function(actor, receiver) {
|
||||||
|
@ -458,6 +469,10 @@ Channel.prototype.unbanIP = function(actor, ip) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.ipbans[ip] = null;
|
this.ipbans[ip] = null;
|
||||||
|
var chan = this;
|
||||||
|
this.users.forEach(function(u) {
|
||||||
|
chan.sendBanlist(u);
|
||||||
|
});
|
||||||
|
|
||||||
if(!this.registered)
|
if(!this.registered)
|
||||||
return false;
|
return false;
|
||||||
|
@ -681,15 +696,12 @@ Channel.prototype.sendRankStuff = function(user) {
|
||||||
}
|
}
|
||||||
user.socket.emit("chatFilters", {filters: filts});
|
user.socket.emit("chatFilters", {filters: filts});
|
||||||
}
|
}
|
||||||
this.sendACL(user);
|
this.sendChannelRanks(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.sendSeenLogins = function(user) {
|
Channel.prototype.sendChannelRanks = function(user) {
|
||||||
}
|
|
||||||
|
|
||||||
Channel.prototype.sendACL = function(user) {
|
|
||||||
if(Rank.hasPermission(user, "acl")) {
|
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) {
|
this.users.forEach(function(u) {
|
||||||
if(u.rank >= 2) {
|
if(u.rank >= 2) {
|
||||||
u.socket.emit("chatMsg", pkt);
|
u.socket.emit("joinMessage", pkt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
7
user.js
7
user.js
|
@ -391,10 +391,11 @@ User.prototype.initCallbacks = function() {
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
this.socket.on("requestAcl", function() {
|
this.socket.on("requestChannelRanks", function() {
|
||||||
if(this.channel != null) {
|
if(this.channel != null) {
|
||||||
this.channel.sendACL(this);
|
if(this.noflood("requestChannelRanks", 0.25))
|
||||||
this.noflood("requestAcl", 0.25);
|
return;
|
||||||
|
this.channel.sendChannelRanks(this);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
|
|
@ -308,21 +308,27 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
channelRanks: function(entries) {
|
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) {
|
entries.sort(function(a, b) {
|
||||||
var x = a.name.toLowerCase();
|
var x = a.name.toLowerCase();
|
||||||
var y = b.name.toLowerCase();
|
var y = b.name.toLowerCase();
|
||||||
return y == x ? 0 : (x < y ? -1 : 1);
|
return y == x ? 0 : (x < y ? -1 : 1);
|
||||||
});
|
});
|
||||||
$("#channelranks").data("entries", entries);
|
$("#channelranks").data("entries", entries);
|
||||||
var tbl = $("#channelranks table");
|
|
||||||
if(tbl.children().length > 1) {
|
if(tbl.children().length > 1) {
|
||||||
$(tbl.children()[1]).remove();
|
$(tbl.children()[1]).remove();
|
||||||
}
|
}
|
||||||
$("#acl_pagination").remove();
|
$("#channelranks_pagination").remove();
|
||||||
if(entries.length > 20) {
|
if(entries.length > 20) {
|
||||||
var pag = $("<div/>").addClass("pagination span12")
|
var pag = $("<div/>").addClass("pagination span12")
|
||||||
.attr("id", "acl_pagination")
|
.attr("id", "channelranks_pagination")
|
||||||
.prependTo($("#channelranks"));
|
.prependTo($("#channelranks"));
|
||||||
var btns = $("<ul/>").appendTo(pag);
|
var btns = $("<ul/>").appendTo(pag);
|
||||||
for(var i = 0; i < entries.length / 20; i++) {
|
for(var i = 0; i < entries.length / 20; i++) {
|
||||||
|
@ -331,13 +337,13 @@ Callbacks = {
|
||||||
$("<a/>").attr("href", "javascript:void(0)")
|
$("<a/>").attr("href", "javascript:void(0)")
|
||||||
.text(i+1)
|
.text(i+1)
|
||||||
.click(function() {
|
.click(function() {
|
||||||
loadACLPage(i);
|
loadChannelRanksPage(i);
|
||||||
})
|
})
|
||||||
.appendTo(li);
|
.appendTo(li);
|
||||||
})(i);
|
})(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadACLPage(0);
|
loadChannelRanksPage(0);
|
||||||
},
|
},
|
||||||
|
|
||||||
setChannelRank: function(data) {
|
setChannelRank: function(data) {
|
||||||
|
@ -349,7 +355,7 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#channelranks").data("entries", ents);
|
$("#channelranks").data("entries", ents);
|
||||||
loadACLPage($("#channelranks").data("page"));
|
loadChannelRanksPage($("#channelranks").data("page"));
|
||||||
},
|
},
|
||||||
|
|
||||||
voteskip: function(data) {
|
voteskip: function(data) {
|
||||||
|
@ -409,6 +415,11 @@ Callbacks = {
|
||||||
addChatMessage(data);
|
addChatMessage(data);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
joinMessage: function(data) {
|
||||||
|
if(USEROPTS.joinmessage)
|
||||||
|
addChatMessage(data);
|
||||||
|
},
|
||||||
|
|
||||||
clearchat: function() {
|
clearchat: function() {
|
||||||
$("#messagebuffer").html("");
|
$("#messagebuffer").html("");
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,6 +28,10 @@
|
||||||
$("#show_loginhistory").click(function() {
|
$("#show_loginhistory").click(function() {
|
||||||
socket.emit("requestLoginHistory");
|
socket.emit("requestLoginHistory");
|
||||||
});
|
});
|
||||||
|
clickHandler("#show_channelranks", "#channelranks");
|
||||||
|
$("#show_channelranks").click(function() {
|
||||||
|
socket.emit("requestChannelRanks");
|
||||||
|
});
|
||||||
|
|
||||||
genPermissionsEditor();
|
genPermissionsEditor();
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ var USEROPTS = {
|
||||||
blink_title : getOrDefault("blink_title", false),
|
blink_title : getOrDefault("blink_title", false),
|
||||||
sync_accuracy : getOrDefault("sync_accuracy", 2),
|
sync_accuracy : getOrDefault("sync_accuracy", 2),
|
||||||
chatbtn : getOrDefault("chatbtn", false),
|
chatbtn : getOrDefault("chatbtn", false),
|
||||||
altsocket : getOrDefault("altsocket", false)
|
altsocket : getOrDefault("altsocket", false),
|
||||||
|
joinmessage : getOrDefault("joinmessage", true)
|
||||||
};
|
};
|
||||||
|
|
||||||
var Rank = {
|
var Rank = {
|
||||||
|
|
|
@ -93,7 +93,7 @@ function formatUserlistItem(div, data) {
|
||||||
function getNameColor(rank) {
|
function getNameColor(rank) {
|
||||||
if(rank >= Rank.Siteadmin)
|
if(rank >= Rank.Siteadmin)
|
||||||
return "userlist_siteadmin";
|
return "userlist_siteadmin";
|
||||||
else if(rank >= Rank.Owner)
|
else if(rank >= Rank.Admin)
|
||||||
return "userlist_owner";
|
return "userlist_owner";
|
||||||
else if(rank >= Rank.Moderator)
|
else if(rank >= Rank.Moderator)
|
||||||
return "userlist_op";
|
return "userlist_op";
|
||||||
|
@ -379,6 +379,12 @@ function showOptionsMenu() {
|
||||||
var modhat = $("<input/>").attr("type", "checkbox").appendTo(modhatcontainer);
|
var modhat = $("<input/>").attr("type", "checkbox").appendTo(modhatcontainer);
|
||||||
modhat.prop("checked", USEROPTS.modhat);
|
modhat.prop("checked", USEROPTS.modhat);
|
||||||
addOption("Modflair", modhatcontainer);
|
addOption("Modflair", modhatcontainer);
|
||||||
|
|
||||||
|
var joincontainer = $("<label/>").addClass("checkbox")
|
||||||
|
.text("Show join messages");
|
||||||
|
var join = $("<input/>").attr("type", "checkbox").appendTo(joincontainer);
|
||||||
|
join.prop("checked", USEROPTS.joinmessage);
|
||||||
|
addOption("Join Messages", joincontainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var footer = $("<div/>").addClass("modal-footer").appendTo(modal);
|
var footer = $("<div/>").addClass("modal-footer").appendTo(modal);
|
||||||
|
@ -399,6 +405,7 @@ function showOptionsMenu() {
|
||||||
USEROPTS.altsocket = altsocket.prop("checked");
|
USEROPTS.altsocket = altsocket.prop("checked");
|
||||||
if(CLIENT.rank >= Rank.Moderator) {
|
if(CLIENT.rank >= Rank.Moderator) {
|
||||||
USEROPTS.modhat = modhat.prop("checked");
|
USEROPTS.modhat = modhat.prop("checked");
|
||||||
|
USEROPTS.joinmessage = join.prop("checked");
|
||||||
}
|
}
|
||||||
saveOpts();
|
saveOpts();
|
||||||
modal.modal("hide");
|
modal.modal("hide");
|
||||||
|
@ -642,6 +649,12 @@ function hasPermission(key) {
|
||||||
|
|
||||||
function handlePermissionChange() {
|
function handlePermissionChange() {
|
||||||
function setVisible(selector, bool) {
|
function setVisible(selector, bool) {
|
||||||
|
if($(selector) && $(selector).attr("id") != selector.substring(1)) {
|
||||||
|
setTimeout(function() {
|
||||||
|
setVisible(selector, bool);
|
||||||
|
}, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var disp = bool ? "" : "none";
|
var disp = bool ? "" : "none";
|
||||||
$(selector).css("display", disp);
|
$(selector).css("display", disp);
|
||||||
}
|
}
|
||||||
|
@ -659,6 +672,13 @@ function handlePermissionChange() {
|
||||||
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
|
$("#opt_enable_link_regex").prop("checked", CHANNEL.opts.enable_link_regex);
|
||||||
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
|
$("#opt_allow_voteskip").prop("checked", CHANNEL.opts.allow_voteskip);
|
||||||
$("#opt_voteskip_ratio").val(CHANNEL.opts.voteskip_ratio);
|
$("#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 {
|
else {
|
||||||
$("#channelsettingswrap").html("");
|
$("#channelsettingswrap").html("");
|
||||||
|
@ -684,14 +704,6 @@ function handlePermissionChange() {
|
||||||
setVisible("#clearplaylist", hasPermission("playlistclear"));
|
setVisible("#clearplaylist", hasPermission("playlistclear"));
|
||||||
setVisible("#shuffleplaylist", hasPermission("playlistshuffle"));
|
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"));
|
setVisible("#newpollbtn", hasPermission("pollctl"));
|
||||||
|
|
||||||
|
@ -1113,7 +1125,7 @@ function genPermissionsEditor() {
|
||||||
["Channel Admin", "3"]
|
["Channel Admin", "3"]
|
||||||
];
|
];
|
||||||
|
|
||||||
addDivider("Open playlist permissions");
|
$("<h3/>").text("Open playlist permissions").appendTo(fs);
|
||||||
makeOption("Add to playlist", "oplaylistadd", standard, CHANNEL.perms.oplaylistadd+"");
|
makeOption("Add to playlist", "oplaylistadd", standard, CHANNEL.perms.oplaylistadd+"");
|
||||||
makeOption("Add/move to next", "oplaylistnext", standard, CHANNEL.perms.oplaylistnext+"");
|
makeOption("Add/move to next", "oplaylistnext", standard, CHANNEL.perms.oplaylistnext+"");
|
||||||
makeOption("Move playlist items", "oplaylistmove", standard, CHANNEL.perms.oplaylistmove+"");
|
makeOption("Move playlist items", "oplaylistmove", standard, CHANNEL.perms.oplaylistmove+"");
|
||||||
|
@ -1158,3 +1170,60 @@ function genPermissionsEditor() {
|
||||||
socket.emit("setPermissions", perms);
|
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 = $("<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)
|
||||||
|
.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 = $("<input/>").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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<li id="cssedit_tab"><a href="javascript:void(0);" id="show_cssedit">CSS Editor</a></li>
|
<li id="cssedit_tab"><a href="javascript:void(0);" id="show_cssedit">CSS Editor</a></li>
|
||||||
<li id="jsedit_tab"><a href="javascript:void(0);" id="show_jsedit">JS Editor</a></li>
|
<li id="jsedit_tab"><a href="javascript:void(0);" id="show_jsedit">JS Editor</a></li>
|
||||||
<li id="banlist_tab"><a href="javascript:void(0);" id="show_banlist">Ban List</a></li>
|
<li id="banlist_tab"><a href="javascript:void(0);" id="show_banlist">Ban List</a></li>
|
||||||
|
<li id="channelranks_tab"><a href="javascript:void(0);" id="show_channelranks">Channel Ranks</a></li>
|
||||||
<li id="loginhistory_tab"><a href="javascript:void(0);" id="show_loginhistory">Recent Connections</a></li>
|
<li id="loginhistory_tab"><a href="javascript:void(0);" id="show_loginhistory">Recent Connections</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -126,3 +127,13 @@ Filters Here
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="channelranks" class="span12">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Rank (click to edit)</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue