diff options
-rw-r--r-- | webchat/hello_web.js | 6 | ||||
-rw-r--r-- | webchat/public/client.js | 12 | ||||
-rw-r--r-- | webchat/public/reset.css | 11 |
3 files changed, 20 insertions, 9 deletions
diff --git a/webchat/hello_web.js b/webchat/hello_web.js index 4b7595d7..155a34f3 100644 --- a/webchat/hello_web.js +++ b/webchat/hello_web.js @@ -19,7 +19,7 @@ var irc_client = new irc.Client('irc.freenode.net', 'kweb', { secure: true, userName: 'kweb', realName: 'kweb', - password: fs.readFileSync(__dirname+'/irc.key').toString(), + password: fs.readFileSync(__dirname+'/local_config/irc.key').toString(), debug: true, showErrors: true, port: 6697, @@ -73,8 +73,8 @@ conn.on('close', function() { }); var options = { - key: fs.readFileSync(__dirname+'/server_npw.key'), - cert: fs.readFileSync(__dirname+'/server.crt'), + key: fs.readFileSync(__dirname+'/local_config/server_npw.key'), + cert: fs.readFileSync(__dirname+'/local_config/server.crt'), }; var app = connect() diff --git a/webchat/public/client.js b/webchat/public/client.js index 119913ae..6bcb24cd 100644 --- a/webchat/public/client.js +++ b/webchat/public/client.js @@ -1,3 +1,8 @@ +function replaceURLWithHTMLLinks(text) { + var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + return text.replace(exp,"<a href='$1'>$1</a>"); +} + $(function connect() { sock = new SockJS('/echo'); @@ -10,9 +15,10 @@ $(function connect() { try { var object = JSON.parse(e.data); console.log(object.message); - var safe_message = $('<div/>').text(object.message).html() - var safe_from = $('<div/>').text(object.from).html() - $('#chatbox').append('<tr><td class="from">'+safe_from+'</td><td>'+safe_message+'</td></tr>'); + var safe_message = $('<div/>').text(object.message).html(); + safe_message = replaceURLWithHTMLLinks(safe_message); + var safe_from = $('<div/>').text(object.from).html(); + $('#chatbox').append('<tr><td class="chat_from">'+safe_from+'</td><td class="chat_msg">'+safe_message+'</td></tr>'); } catch (error) { console.log(error); diff --git a/webchat/public/reset.css b/webchat/public/reset.css index 91b9a438..746b81c4 100644 --- a/webchat/public/reset.css +++ b/webchat/public/reset.css @@ -30,6 +30,8 @@ footer, header, hgroup, menu, nav, section { } body { line-height: 1; + background-color: black; + color: white; } ol, ul { list-style: none; @@ -42,14 +44,17 @@ q:before, q:after { content: ''; content: none; } -x-table { +#chatbox { border-collapse: collapse; border-spacing: 0; + border: solid 2px black; + background-color: white; + color: black; } -.from { +.chat_from { font-weight: bold; text-align: right; } -.from:after { +.chat_from:after { content: ":"; } |