Add MOTD and chat filter interface
This commit is contained in:
parent
a0c26ee0e5
commit
fab4039fc1
9 changed files with 192 additions and 30 deletions
|
|
@ -124,3 +124,7 @@
|
|||
.nick-highlight {
|
||||
background-color: #ddffdd;
|
||||
}
|
||||
|
||||
#motdtext {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,19 @@ function initCallbacks() {
|
|||
showAnnouncement(data.title, data.text);
|
||||
});
|
||||
|
||||
socket.on("updateMotd", function(data) {
|
||||
$("#motdtext").val(data.motd);
|
||||
if(data.motd != "")
|
||||
$("#motd").parent().css("display", "");
|
||||
else
|
||||
$("#motd").parent().css("display", "none");
|
||||
$("#motd")[0].innerHTML = data.html;
|
||||
});
|
||||
|
||||
socket.on("chatFilters", function(data) {
|
||||
updateChatFilters(data.filters);
|
||||
});
|
||||
|
||||
socket.on("registerChannel", function(data) {
|
||||
if(data.success) {
|
||||
$("#chregnotice").remove();
|
||||
|
|
|
|||
|
|
@ -278,18 +278,47 @@ $("#opt_submit").click(function() {
|
|||
socket.emit("channelOpts", opts);
|
||||
});
|
||||
|
||||
$("#updatemotd").click(function() {
|
||||
var motd = $("#motdtext").val();
|
||||
socket.emit("updateMotd", {
|
||||
motd: motd
|
||||
});
|
||||
});
|
||||
|
||||
$("#show_chancontrols").click(function() {
|
||||
$("#show_chancontrols").parent().addClass("active");
|
||||
$("#show_banlist").parent().removeClass("active");
|
||||
$("#banlist").hide();
|
||||
$("#show_motdeditor").parent().removeClass("active");
|
||||
$("#show_filtereditor").parent().removeClass("active");
|
||||
$("#show_chancontrols").parent().addClass("active");
|
||||
$(".modonly").hide();
|
||||
$("#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");
|
||||
$(".modonly").hide();
|
||||
$("#banlist").show();
|
||||
$("#chancontrols").hide();
|
||||
});
|
||||
|
||||
$("#show_motdeditor").click(function() {
|
||||
$("#show_chancontrols").parent().removeClass("active");
|
||||
$("#show_banlist").parent().removeClass("active");
|
||||
$("#show_filtereditor").parent().removeClass("active");
|
||||
$("#show_motdeditor").parent().addClass("active");
|
||||
$(".modonly").hide();
|
||||
$("#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");
|
||||
$(".modonly").hide();
|
||||
$("#filtereditor").show();
|
||||
});
|
||||
|
||||
function searchLibrary() {
|
||||
|
|
|
|||
|
|
@ -675,6 +675,62 @@ function updateBanlist(entries) {
|
|||
}
|
||||
}
|
||||
|
||||
function updateChatFilters(entries) {
|
||||
var tbl = $("#filtereditor table");
|
||||
if(tbl.children().length > 1) {
|
||||
$(tbl.children()[1]).remove();
|
||||
}
|
||||
for(var i = 0; i < entries.length; i++) {
|
||||
var tr = $("<tr/>").appendTo(tbl);
|
||||
var remove = $("<button/>").addClass("btn btn-mini btn-danger")
|
||||
.appendTo($("<td/>").appendTo(tr));
|
||||
$("<i/>").addClass("icon-remove-circle").appendTo(remove);
|
||||
var regex = $("<code/>").text(entries[i][0])
|
||||
.appendTo($("<td/>").appendTo(tr));
|
||||
var replace = $("<code/>").text(entries[i][1])
|
||||
.appendTo($("<td/>").appendTo(tr));
|
||||
var activetd = $("<td/>").appendTo(tr);
|
||||
var active = $("<input/>").attr("type", "checkbox")
|
||||
.prop("checked", entries[i][2]).appendTo(activetd);
|
||||
|
||||
var remcallback = (function(filter) { return function() {
|
||||
socket.emit("chatFilter", {
|
||||
cmd: "remove",
|
||||
filter: filter
|
||||
});
|
||||
} })(entries[i]);
|
||||
remove.click(remcallback);
|
||||
|
||||
var actcallback = (function(filter) { return function() {
|
||||
filter[2] = active.prop("checked");
|
||||
socket.emit("chatFilter", {
|
||||
cmd: "update",
|
||||
filter: filter
|
||||
});
|
||||
} })(entries[i]);
|
||||
active.click(actcallback);
|
||||
}
|
||||
|
||||
var newfilt = $("<tr/>").appendTo(tbl);
|
||||
$("<td/>").appendTo(newfilt);
|
||||
var regex = $("<input/>").attr("type", "text")
|
||||
.appendTo($("<td/>").appendTo(newfilt));
|
||||
var replace = $("<input/>").attr("type", "text")
|
||||
.appendTo($("<td/>").appendTo(newfilt));
|
||||
var add = $("<button/>").addClass("btn btn-primary")
|
||||
.text("Add Filter")
|
||||
.appendTo($("<td/>").appendTo(newfilt));
|
||||
var cback = (function(regex, replace) { return function() {
|
||||
if(regex.val() && replace.val()) {
|
||||
socket.emit("chatFilter", {
|
||||
cmd: "update",
|
||||
filter: [regex.val(), replace.val(), true]
|
||||
});
|
||||
}
|
||||
} })(regex, replace);
|
||||
add.click(cback);
|
||||
}
|
||||
|
||||
function handleRankChange() {
|
||||
rebuildPlaylist();
|
||||
if(RANK >= Rank.Moderator || LEADER) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@
|
|||
<h3 id="welcome"></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span10 offset1 well">
|
||||
<p id="motd"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="margin-top: 20px;">
|
||||
<div class="span5" id="chatdiv">
|
||||
<p id="usercount"></p>
|
||||
|
|
@ -97,10 +102,16 @@
|
|||
<li>
|
||||
<a href="javascript:void(0)" id="show_banlist">Ban List</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0)" id="show_motdeditor">MOTD</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:void(0)" id="show_filtereditor">Chat Filters</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="display: none" id="chancontrols">
|
||||
<div class="row modonly" style="display: none" id="chancontrols">
|
||||
<div class="span10 offset1">
|
||||
<form action="javascript:void(0)">
|
||||
<fieldset>
|
||||
|
|
@ -141,7 +152,7 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="banlist" style="display: none;">
|
||||
<div class="row modonly" id="banlist" style="display: none;">
|
||||
<div class="span10 offset1">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
|
@ -153,6 +164,24 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row modonly" id="motdeditor" style="display: none;">
|
||||
<div class="span10 offset1">
|
||||
<textarea rows="10" id="motdtext"></textarea>
|
||||
<button class="btn btn-primary" id="updatemotd">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row modonly" id="filtereditor" style="display: none;">
|
||||
<div class="span10 offset1">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th></th>
|
||||
<th>Regex</th>
|
||||
<th>Replacement</th>
|
||||
<th>Active</th>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span4 offset3">
|
||||
<div class="btn-group" style="width: 100%">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue