summaryrefslogtreecommitdiffstats
path: root/webchat/public
diff options
context:
space:
mode:
authorlassulus <lassulus@googlemail.com>2013-11-11 17:46:27 +0100
committerlassulus <lassulus@googlemail.com>2013-11-11 17:46:27 +0100
commit24efdc59cb58c5bbfa49516088fe124bc9f431c1 (patch)
tree43a226b15fa5ec542d931f982cc3d40f740e87ed /webchat/public
parent2d823c8f8557f0a49e4307717e99a90b24052e9c (diff)
webchat: still refactoring
Diffstat (limited to 'webchat/public')
-rw-r--r--webchat/public/client.js2
-rw-r--r--webchat/public/commands.js2
-rw-r--r--webchat/public/functions.js63
-rw-r--r--webchat/public/reset.css1
4 files changed, 17 insertions, 51 deletions
diff --git a/webchat/public/client.js b/webchat/public/client.js
index 4842d9c2..5e0202a1 100644
--- a/webchat/public/client.js
+++ b/webchat/public/client.js
@@ -17,7 +17,7 @@ $(function connect() {
console.log('message', e.data);
try {
var object = JSON.parse(e.data);
- console.log(object.message);
+ console.log(object);
clientParser(object);
} catch (error) {
diff --git a/webchat/public/commands.js b/webchat/public/commands.js
index 8cd3bba1..20197fbb 100644
--- a/webchat/public/commands.js
+++ b/webchat/public/commands.js
@@ -3,7 +3,7 @@ var commands = {}
commands.say = function (settings, params) {
var sendObj = {
method: 'say',
- params: { message: params },
+ params: { msg: params },
};
sock.send(JSON.stringify(sendObj))
}
diff --git a/webchat/public/functions.js b/webchat/public/functions.js
index ddd3aad6..adcf3169 100644
--- a/webchat/public/functions.js
+++ b/webchat/public/functions.js
@@ -9,50 +9,22 @@ function inputParser (str) {
function clientParser(object) {
- console.log(object)
- switch (object.type) {
- case 'message':
- return printMessage(object);
- case 'join':
- return handleJoin(object);
- case 'quit':
- return handleQuit(object);
- case 'nicklist':
- return handleNicklist(object);
- case 'nickchange':
- return handleNickchange(object);
- }
-};
-
-function handleJoin(object) {
- var safe_from = $('<div/>').text(object.from).html();
- $('<tr><td class="chat_date">'+getCurTime()+'</td><td class="chat_from">'+safe_from+'</td><td class="chat_msg" style="color:#00FF00">joined</td></tr>').insertBefore('#foot');
- $('#nicklist').append('<div class="name">' + safe_from + '</div>') ;
+ console.log('parser: ',object)
+ return (handler[object.method] || console.log)(object.params)
+//switch (object.method) {
+// case 'message':
+// return handler.message(object.params);
+// case 'join':
+// return handler.join(object.params);
+// case 'quit':
+// return handler.quit(object.params);
+// case 'nicklist':
+// return handler.nicklist(object.params);
+// case 'nickchange':
+// return handler.nickchange(object.params);
+//}
};
-function handleQuit(object) {
- var safe_from = $('<div/>').text(object.from).html();
- $('<tr><td class="chat_date">'+getCurTime()+'</td><td class="chat_from">'+safe_from+'</td><td class="chat_msg" style="color:#FF0000">quit</td></tr>').insertBefore('#foot');
- console.log('removing', safe_from);
- $(getNicklistElement(safe_from)).remove();
-};
-
-function handleNicklist(object) {
- Object.keys(object.message).forEach(function (nick) {
-// console.log('nick',nick);
- var hash_from = btoa(nick).replace(/=/g,'_');
-// $('.name').each(function (i,e) { console.log(i,e); if (e.innerHTML === 'kweb') { $(e).attr("style", "color:green") } })
- $('#nicklist').append('<div class="name">' + nick + '</div>') ;
- });
-};
-
-function handleNickchange(object) {
- var safe_from = $('<div/>').text(object.nick).html();
- var safe_newnick = $('<div/>').text(object.newnick).html();
- $('<tr><td class="chat_date">'+getCurTime()+'</td><td class="chat_from">'+safe_from+'</td><td class="chat_msg">is now known as '+object.newnick+'</td></tr>').insertBefore('#foot');
- $(getNicklistElement(safe_from)).remove();
- $('#nicklist').append('<div class="name">' + safe_from + '</div>') ;
-};
function replaceURLWithHTMLLinks (text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
@@ -89,13 +61,6 @@ function chatboxAppend (chat_from, chat_msg, type) {
elem.scrollTop = elem.scrollHeight;
};
-function printMessage(object) {
- var safe_message = $('<div/>').text(object.message).html();
- safe_message = replaceURLWithHTMLLinks(safe_message);
- var safe_from = $('<div/>').text(object.nick).html();
- return chatboxAppend(safe_from, safe_message)
-};
-
function getCurTime () {
date = new Date;
h = date.getHours();
diff --git a/webchat/public/reset.css b/webchat/public/reset.css
index 4139aca5..64ba963e 100644
--- a/webchat/public/reset.css
+++ b/webchat/public/reset.css
@@ -63,6 +63,7 @@ q:before, q:after {
font-weight: bold;
text-align: right;
font-size:12px;
+ white-space: nowrap;
}
.chat_from:after {
content: ":";