summaryrefslogtreecommitdiffstats
path: root/webchat/public
diff options
context:
space:
mode:
Diffstat (limited to 'webchat/public')
-rw-r--r--webchat/public/client.js12
-rw-r--r--webchat/public/reset.css11
2 files changed, 17 insertions, 6 deletions
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: ":";
}