Continue working on filters
This commit is contained in:
parent
25862acd72
commit
6eaa9a45d0
7 changed files with 201 additions and 61 deletions
|
|
@ -154,7 +154,7 @@ html, body {
|
|||
border-left: 0;
|
||||
}
|
||||
|
||||
#messagebuffer div, #messagebuffer code {
|
||||
#messagebuffer div, #messagebuffer code, #filteredit code {
|
||||
white-space: pre-wrap; /* css-3 */
|
||||
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
|
|
@ -162,6 +162,10 @@ html, body {
|
|||
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
||||
}
|
||||
|
||||
#filteredit td {
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
.userlist_siteadmin {
|
||||
color: #cc0000;
|
||||
font-weight: bold;
|
||||
|
|
|
|||
|
|
@ -133,34 +133,133 @@ Callbacks = {
|
|||
.appendTo($("<td/>").appendTo(tr));
|
||||
var linktd = $("<td/>").appendTo(tr);
|
||||
var link = $("<input/>").attr("type", "checkbox")
|
||||
.prop("checked", false).appendTo(linktd);
|
||||
.prop("checked", f.filterlinks).appendTo(linktd);
|
||||
var activetd = $("<td/>").appendTo(tr);
|
||||
var active = $("<input/>").attr("type", "checkbox")
|
||||
.prop("checked", f.active).appendTo(activetd);
|
||||
(function(f) {
|
||||
regex.click(function() {
|
||||
if(this.find(".filter-regex-edit").length > 0)
|
||||
return;
|
||||
var r = this.text();
|
||||
this.text("");
|
||||
var edit = $("<input/>").attr("type", "text")
|
||||
.css("font-family", "Monospace")
|
||||
.attr("placeholder", r)
|
||||
.val(r)
|
||||
.addClass("filter-regex-edit")
|
||||
.appendTo(this)
|
||||
.focus();
|
||||
|
||||
var remcallback = (function(filter) { return function() {
|
||||
socket.emit("chatFilter", {
|
||||
cmd: "remove",
|
||||
filter: filter
|
||||
});
|
||||
} })(f);
|
||||
remove.click(remcallback);
|
||||
function save() {
|
||||
var r = this.val();
|
||||
var r2 = r;
|
||||
if(r.trim() == "")
|
||||
r = this.attr("placeholder");
|
||||
this.parent().text(r);
|
||||
f.source = r;
|
||||
socket.emit("updateFilter", f);
|
||||
}
|
||||
edit.blur(save.bind(edit));
|
||||
edit.keydown(function(ev) {
|
||||
if(ev.keyCode == 13)
|
||||
save.bind(edit)();
|
||||
});
|
||||
}.bind(regex));
|
||||
flags.click(function() {
|
||||
if(this.find(".filter-flags-edit").length > 0)
|
||||
return;
|
||||
var r = this.text();
|
||||
this.text("");
|
||||
var edit = $("<input/>").attr("type", "text")
|
||||
.css("font-family", "Monospace")
|
||||
.attr("placeholder", r)
|
||||
.val(r)
|
||||
.addClass("filter-flags-edit")
|
||||
.appendTo(this)
|
||||
.focus();
|
||||
|
||||
var actcallback = (function(filter) { return function() {
|
||||
// Apparently when you check a checkbox, its value is changed
|
||||
// before this callback. When you uncheck it, its value is not
|
||||
// changed before this callback
|
||||
// [](/amgic)
|
||||
var enabled = active.prop("checked");
|
||||
filter.active = (filter.active == enabled) ? !enabled : enabled;
|
||||
socket.emit("chatFilter", {
|
||||
cmd: "update",
|
||||
filter: filter
|
||||
function save() {
|
||||
var r = this.val();
|
||||
var r2 = r;
|
||||
if(r.trim() == "")
|
||||
r = this.attr("placeholder");
|
||||
this.parent().text(r);
|
||||
f.flags = r;
|
||||
socket.emit("updateFilter", f);
|
||||
}
|
||||
edit.blur(save.bind(edit));
|
||||
edit.keydown(function(ev) {
|
||||
if(ev.keyCode == 13)
|
||||
save.bind(edit)();
|
||||
});
|
||||
}.bind(flags));
|
||||
replace.click(function() {
|
||||
if(this.find(".filter-replace-edit").length > 0)
|
||||
return;
|
||||
var r = this.text();
|
||||
this.text("");
|
||||
var edit = $("<input/>").attr("type", "text")
|
||||
.css("font-family", "Monospace")
|
||||
.attr("placeholder", r)
|
||||
.val(r)
|
||||
.addClass("filter-replace-edit")
|
||||
.appendTo(this)
|
||||
.focus();
|
||||
|
||||
function save() {
|
||||
var r = this.val();
|
||||
var r2 = r;
|
||||
if(r.trim() == "")
|
||||
r = this.attr("placeholder");
|
||||
this.parent().text(r);
|
||||
f.replace = r;
|
||||
socket.emit("updateFilter", f);
|
||||
}
|
||||
edit.blur(save.bind(edit));
|
||||
edit.keydown(function(ev) {
|
||||
if(ev.keyCode == 13)
|
||||
save.bind(edit)();
|
||||
});
|
||||
}.bind(replace));
|
||||
|
||||
remove.click(function() {
|
||||
socket.emit("removeFilter", f);
|
||||
});
|
||||
} })(f);
|
||||
active.click(actcallback);
|
||||
|
||||
active.click(function() {
|
||||
// Apparently when you check a checkbox, its value is changed
|
||||
// before this callback. When you uncheck it, its value is not
|
||||
// changed before this callback
|
||||
// [](/amgic)
|
||||
var enabled = active.prop("checked");
|
||||
f.active = (f.active == enabled) ? !enabled : enabled;
|
||||
socket.emit("updateFilter", f);
|
||||
});
|
||||
link.click(function() {
|
||||
var enabled = link.prop("checked");
|
||||
f.filterlinks = (f.filterlinks == enabled) ? !enabled : enabled;
|
||||
socket.emit("updateFilter", f);
|
||||
});
|
||||
})(f);
|
||||
}
|
||||
|
||||
$(tbl.children()[1]).sortable({
|
||||
start: function(ev, ui) {
|
||||
FILTER_FROM = ui.item.prevAll().length;
|
||||
},
|
||||
update: function(ev, ui) {
|
||||
FILTER_TO = ui.item.prevAll().length;
|
||||
if(FILTER_TO != FILTER_FROM) {
|
||||
socket.emit("moveFilter", {
|
||||
from: FILTER_FROM,
|
||||
to: FILTER_TO
|
||||
});
|
||||
console.log("moveFilter", FILTER_FROM, FILTER_TO);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var newfilt = $("<tr/>");//.appendTo(tbl);
|
||||
$("<td/>").appendTo(newfilt);
|
||||
var name = $("<input/>").attr("type", "text")
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ var SESSION = readCookie("cytube_session");
|
|||
var LEADTMR = false;
|
||||
var PL_FROM = 0;
|
||||
var PL_TO = 0;
|
||||
var FILTER_FROM = 0;
|
||||
var FILTER_TO = 0;
|
||||
|
||||
function getOrDefault(k, def) {
|
||||
var v = localStorage.getItem(k);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
<button class="btn btn-primary" id="save_motd">Save</button>
|
||||
</div>
|
||||
<div id="filteredit" class="span12">
|
||||
<p>Filters will be processed in the order that they are listed here. Click and drag a row to rearrange the order. Click a regex, flags, or replacement field to edit a filter. Changes are automatically saved when you finish editing.</p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue