Make links unaffected by chat filters

This commit is contained in:
calzoneman 2013-05-13 19:54:52 -04:00
parent 4fe8ab164d
commit d0b3f9014a
2 changed files with 12 additions and 6 deletions

View File

@ -1269,14 +1269,21 @@ Channel.prototype.chainMessage = function(user, msg, data) {
} }
Channel.prototype.filterMessage = function(msg) { Channel.prototype.filterMessage = function(msg) {
msg = msg.replace(/(((https?)|(ftp))(:\/\/[0-9a-zA-Z\.]+(:[0-9]+)?[^\s$]+))/g, "<a href=\"$1\" target=\"_blank\">$1</a>"); const link = /((?:(?:https?)|(?:ftp))(?::\/\/[0-9a-zA-Z\.]+(?::[0-9]+)?[^\s$]+))/g;
var subs = msg.split(link);
// Apply other filters // Apply other filters
for(var i = 0; i < this.filters.length; i++) { for(var j = 0; j < subs.length; j++) {
if(!this.filters[i].active) if(subs[j].match(link)) {
subs[j] = subs[j].replace(link, "<a href=\"$1\" target=\"blank\">$1</a>");
continue; continue;
msg = this.filters[i].filter(msg); }
for(var i = 0; i < this.filters.length; i++) {
if(!this.filters[i].active)
continue;
subs[j] = this.filters[i].filter(subs[j]);
}
} }
return msg; return subs.join("");
} }
Channel.prototype.sendMessage = function(username, msg, msgclass, data) { Channel.prototype.sendMessage = function(username, msg, msgclass, data) {

View File

@ -379,7 +379,6 @@ Media.prototype.update = function(data) {
this.getTime(function(seconds) { this.getTime(function(seconds) {
var time = data.currentTime; var time = data.currentTime;
var diff = time - seconds || time; var diff = time - seconds || time;
console.log(this);
if(diff > USEROPTS.sync_accuracy) { if(diff > USEROPTS.sync_accuracy) {
this.seek(time); this.seek(time);