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) { Channel.prototype.sendChatFilters = function(user) {
this.sendBanlist(user);
if(this.hasPermission(user, "filteredit")) { if(this.hasPermission(user, "filteredit")) {
var filts = new Array(this.filters.length); var filts = new Array(this.filters.length);
for(var i = 0; i < this.filters.length; i++) { for(var i = 0; i < this.filters.length; i++) {
filts[i] = this.filters[i].pack(); 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); this.sendChannelRanks(user);
} }
@ -916,7 +920,7 @@ Channel.prototype.broadcastChatFilters = function() {
} }
for(var i = 0; i < this.users.length; i++) { for(var i = 0; i < this.users.length; i++) {
if(this.hasPermission(this.users[i], "filteredit")) { 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)); }.bind(this));
this.socket.on("requestChatFilters", function() {
if(this.channel != null) {
this.channel.sendChatFilters(this);
}
}.bind(this));
this.socket.on("requestChannelRanks", function() { this.socket.on("requestChannelRanks", function() {
if(this.channel != null) { if(this.channel != null) {
if(this.noflood("requestChannelRanks", 0.25)) if(this.noflood("requestChannelRanks", 0.25))
@ -399,16 +405,6 @@ User.prototype.initCallbacks = function() {
} }
}.bind(this)); }.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) { this.socket.on("voteskip", function(data) {
if(this.channel != null) { if(this.channel != null) {
this.channel.tryVoteskip(this); this.channel.tryVoteskip(this);

View File

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

View File

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

View File

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

View File

@ -91,7 +91,19 @@
<button class="btn btn-primary" id="save_motd">Save</button> <button class="btn btn-primary" id="save_motd">Save</button>
</div> </div>
<div id="filteredit" class="span12"> <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>
<div id="cssedit" class="span12"> <div id="cssedit" class="span12">
<p>Max 20KB. If you need more space, host the file externally and use the External CSS option</p> <p>Max 20KB. If you need more space, host the file externally and use the External CSS option</p>