mirror of https://github.com/calzoneman/sync.git
Allow custom regex flags
Fixes Issue #29 For example, match "word" without case sensitivity, match globally: word/ig If you want to match a literal slash, escape it with a backslash: \/
This commit is contained in:
parent
6ae16d5671
commit
78ecc042d6
17
channel.js
17
channel.js
|
@ -801,7 +801,7 @@ Channel.prototype.move = function(data) {
|
|||
|
||||
Channel.prototype.tryMove = function(user, data) {
|
||||
if(!Rank.hasPermission(user, "queue") &&
|
||||
this.leader != user &&
|
||||
this.leader != user &&
|
||||
(!this.openqueue ||
|
||||
this.openqueue || !this.opts.qopen_allow_move)) {
|
||||
return;
|
||||
|
@ -863,7 +863,7 @@ Channel.prototype.trySetLock = function(user, data) {
|
|||
if(!Rank.hasPermission(user, "qlock")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(data.locked == undefined) {
|
||||
return;
|
||||
}
|
||||
|
@ -906,8 +906,15 @@ Channel.prototype.tryChangeFilter = function(user, data) {
|
|||
}
|
||||
|
||||
if(data.cmd == "update") {
|
||||
var re = data.filter[0];
|
||||
var flags = "g";
|
||||
var slash = re.lastIndexOf("/");
|
||||
if(slash > 0 && re[slash-1] != "\\") {
|
||||
flags = re.substring(slash+1);
|
||||
re = re.substring(0, slash);
|
||||
}
|
||||
try {
|
||||
data.filter[0] = new RegExp(data.filter[0], "g");
|
||||
data.filter[0] = new RegExp(re, flags);
|
||||
}
|
||||
catch(e) {
|
||||
return;
|
||||
|
@ -929,7 +936,7 @@ Channel.prototype.tryUpdateOptions = function(user, data) {
|
|||
this.opts[key] = data[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.broadcastOpts();
|
||||
}
|
||||
|
||||
|
@ -959,7 +966,7 @@ Channel.prototype.tryChat = function(user, data) {
|
|||
if(user.name == "") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(data.msg == undefined) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -635,8 +635,15 @@ function updateChatFilters(entries) {
|
|||
.appendTo($("<td/>").appendTo(newfilt));
|
||||
var cback = (function(regex, replace) { return function() {
|
||||
if(regex.val() && replace.val()) {
|
||||
var re = regex.val();
|
||||
var flags = "g";
|
||||
var slash = re.lastIndexOf("/");
|
||||
if(slash > 0 && re[slash-1] != "\\") {
|
||||
flags = re.substring(slash+1);
|
||||
re = re.substring(0, slash);
|
||||
}
|
||||
try {
|
||||
var dummy = new RegExp(regex.val(), "g");
|
||||
var dummy = new RegExp(re, flags);
|
||||
}
|
||||
catch(e) {
|
||||
alert("Invalid regex: " + e);
|
||||
|
|
Loading…
Reference in New Issue