Work on chat filters

This commit is contained in:
calzoneman 2013-06-18 10:57:53 -04:00
parent 09e9fb2eab
commit 25862acd72
6 changed files with 43 additions and 18 deletions

View File

@ -687,15 +687,19 @@ Channel.prototype.sendBanlist = function(user) {
}
}
Channel.prototype.sendRankStuff = function(user) {
this.sendBanlist(user);
Channel.prototype.sendChatFilters = function(user) {
if(this.hasPermission(user, "filteredit")) {
var filts = new Array(this.filters.length);
for(var i = 0; i < this.filters.length; i++) {
filts[i] = this.filters[i].pack();
}
user.socket.emit("chatFilters", {filters: filts});
user.socket.emit("chatFilters", filts);
}
}
Channel.prototype.sendRankStuff = function(user) {
this.sendBanlist(user);
this.sendChatFilters(user);
this.sendChannelRanks(user);
}
@ -916,7 +920,7 @@ Channel.prototype.broadcastChatFilters = function() {
}
for(var i = 0; i < this.users.length; i++) {
if(this.hasPermission(this.users[i], "filteredit")) {
this.users[i].socket.emit("chatFilters", {filters: filts});
this.users[i].socket.emit("chatFilters", filts);
}
}
}

16
user.js
View File

@ -391,6 +391,12 @@ User.prototype.initCallbacks = function() {
}
}.bind(this));
this.socket.on("requestChatFilters", function() {
if(this.channel != null) {
this.channel.sendChatFilters(this);
}
}.bind(this));
this.socket.on("requestChannelRanks", function() {
if(this.channel != null) {
if(this.noflood("requestChannelRanks", 0.25))
@ -399,16 +405,6 @@ User.prototype.initCallbacks = function() {
}
}.bind(this));
this.socket.on("requestSeenlogins", function() {
if(this.channel != null) {
if(this.noflood("requestSeenLogins", 0.25)) {
return;
}
// does nothing
this.channel.sendSeenLogins(this);
}
}.bind(this));
this.socket.on("voteskip", function(data) {
if(this.channel != null) {
this.channel.tryVoteskip(this);

View File

@ -107,7 +107,13 @@ Callbacks = {
},
chatFilters: function(entries) {
var tbl = $("#filtereditor table");
var tbl = $("#filteredit table");
if(!tbl.hasClass("table")) {
setTimeout(function() {
Callbacks.chatFilters(entries);
}, 100);
return;
}
if(tbl.children().length > 1) {
$(tbl.children()[1]).remove();
}
@ -116,7 +122,7 @@ Callbacks = {
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);
$("<i/>").addClass("icon-trash").appendTo(remove);
var name = $("<code/>").text(f.name)
.appendTo($("<td/>").appendTo(tr));
var regex = $("<code/>").text(f.source)
@ -125,6 +131,9 @@ Callbacks = {
.appendTo($("<td/>").appendTo(tr));
var replace = $("<code/>").text(f.replace)
.appendTo($("<td/>").appendTo(tr));
var linktd = $("<td/>").appendTo(tr);
var link = $("<input/>").attr("type", "checkbox")
.prop("checked", false).appendTo(linktd);
var activetd = $("<td/>").appendTo(tr);
var active = $("<input/>").attr("type", "checkbox")
.prop("checked", f.active).appendTo(activetd);
@ -152,7 +161,7 @@ Callbacks = {
active.click(actcallback);
}
var newfilt = $("<tr/>").appendTo(tbl);
var newfilt = $("<tr/>");//.appendTo(tbl);
$("<td/>").appendTo(newfilt);
var name = $("<input/>").attr("type", "text")
.appendTo($("<td/>").appendTo(newfilt));

View File

@ -18,6 +18,9 @@
clickHandler("#show_permedit", "#permedit");
clickHandler("#show_motdedit", "#motdedit");
clickHandler("#show_filteredit", "#filteredit");
$("#show_filteredit").click(function() {
socket.emit("requestChatFilters");
});
clickHandler("#show_cssedit", "#cssedit");
clickHandler("#show_jsedit", "#jsedit");
clickHandler("#show_banlist", "#banlist");

View File

@ -1057,6 +1057,7 @@ function fluidLayout() {
$("#ytapiplayer").attr("width", VWIDTH);
$("#ytapiplayer").attr("height", VHEIGHT);
$("#chatline").removeClass().addClass("span12");
$("#channelsettingswrap3").css("margin-left", "0");
}
function synchtubeLayout() {

View File

@ -91,7 +91,19 @@
<button class="btn btn-primary" id="save_motd">Save</button>
</div>
<div id="filteredit" class="span12">
Filters Here
<table class="table table-striped">
<thead>
<tr>
<th>Delete</th>
<th>Name</th>
<th>Regex</th>
<th>Flags</th>
<th>Replacement</th>
<th>Affects Links</th>
<th>Active</th>
</tr>
</thead>
</table>
</div>
<div id="cssedit" class="span12">
<p>Max 20KB. If you need more space, host the file externally and use the External CSS option</p>