diff --git a/channel.js b/channel.js
index b4f79408..28f9fcdd 100644
--- a/channel.js
+++ b/channel.js
@@ -42,6 +42,11 @@ var Channel = function(name) {
pagetitle: "Sync",
customcss: ""
};
+ this.filters = [
+ [new RegExp("`([^`]+)`", "g"), "$1
", true],
+ [new RegExp("\\*([^\\*]+)\\*", "g"), "$1", true],
+ [new RegExp("_([^_]+)_", "g"), "$1", true]
+ ];
this.ipbans = {};
this.logger = new Logger.Logger("chanlogs/" + this.name + ".log");
@@ -771,7 +776,21 @@ Channel.prototype.sendMessage = function(username, msg, msgclass) {
// I don"t want HTML from strangers
msg = msg.replace(//g, ">");
// Match URLs
- msg = msg.replace(/(((https?)|(ftp))(:\/\/[0-9a-zA-Z\.]+(:[0-9]+)?[^\s$]+))/, "$1");
+ msg = msg.replace(/(((https?)|(ftp))(:\/\/[0-9a-zA-Z\.]+(:[0-9]+)?[^\s$]+))/g, "$1");
+ // Apply other filters
+ for(var i = 0; i < this.filters.length; i++) {
+ if(!this.filters[i][2])
+ continue;
+ var regex = this.filters[i][0];
+ var replace = this.filters[i][1];
+ msg = msg.replace(regex, replace);
+ }
+ // Chat modifier - monospace
+ //msg = msg.replace(/`([^`]+)`/g, "$1");
+ // Bold
+ //msg = msg.replace(/\*\*([^\*]+)\*\*/g, "$1");
+ // Italic
+ //msg = msg.replace(/\*([^\*]+)\*/g, "$1");
this.sendAll("chatMsg", {
username: username,
msg: msg,
diff --git a/user.js b/user.js
index 1e13d007..3852bc6d 100644
--- a/user.js
+++ b/user.js
@@ -106,7 +106,9 @@ User.prototype.initCallbacks = function() {
}.bind(this));
this.socket.on("chatMsg", function(data) {
- if(this.name != "" && this.channel != null) {
+ if(this.name != "" && this.channel != null && data.msg != undefined) {
+ if(data.msg.length > 500)
+ data.msg = data.msg.substring(0, 500);
this.channel.chatMessage(this, data.msg);
}
}.bind(this));
diff --git a/www/assets/css/ytsync.css b/www/assets/css/ytsync.css
index 153f2d8e..56a8c89d 100644
--- a/www/assets/css/ytsync.css
+++ b/www/assets/css/ytsync.css
@@ -56,7 +56,7 @@
border-left: 0;
}
-#messagebuffer div {
+#messagebuffer div, #messagebuffer code {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
@@ -106,6 +106,10 @@
font-size: 18pt;
}
+.mono {
+ font-family: Monospace;
+}
+
.poll-notify {
color: #0000aa;
font-weight: bold;
diff --git a/www/assets/js/client.js b/www/assets/js/client.js
index 35f4bc63..df7d13a5 100644
--- a/www/assets/js/client.js
+++ b/www/assets/js/client.js
@@ -19,6 +19,8 @@ var OPENQUEUE = false;
var CHANNELOPTS = {};
var GRABBEDLI = null;
var OLDINDEX = -1;
+var CHATHIST = [];
+var CHATHISTIDX = 0;
var uname = readCookie("sync_uname");
var pw = readCookie("sync_pw");
@@ -186,6 +188,10 @@ $("#chatline").keydown(function(ev) {
socket.emit("chatMsg", {
msg: $("#chatline").val()
});
+ CHATHIST.push($("#chatline").val());
+ if(CHATHIST.length > 10)
+ CHATHIST.shift();
+ CHATHISTIDX = CHATHIST.length;
$("#chatline").val("");
}
else if(ev.keyCode == 9) { // Tab completion
@@ -214,6 +220,27 @@ $("#chatline").keydown(function(ev) {
ev.preventDefault();
return false;
}
+ else if(ev.keyCode == 38) {
+ if(CHATHISTIDX == CHATHIST.length) {
+ CHATHIST.push($("#chatline").val());
+ }
+ if(CHATHISTIDX > 0) {
+ CHATHISTIDX--;
+ $("#chatline").val(CHATHIST[CHATHISTIDX]);
+ }
+
+ ev.preventDefault();
+ return false;
+ }
+ else if(ev.keyCode == 40) {
+ if(CHATHISTIDX < CHATHIST.length - 1) {
+ CHATHISTIDX++;
+ $("#chatline").val(CHATHIST[CHATHISTIDX]);
+ }
+
+ ev.preventDefault();
+ return false;
+ }
});
$("#opt_submit").click(function() {