From 36e4fae6958796419dcff63f323735dc66aabdcd Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 13 Apr 2017 23:02:43 -0400 Subject: Restyled the chat --- js/chat.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/chat.js b/js/chat.js index a0ccefb..b79fee6 100644 --- a/js/chat.js +++ b/js/chat.js @@ -29,7 +29,7 @@ var bullechat = { $child.data('body', $chbody); $child.append($('', {'type': 'text', 'class': 'chinput', 'placeholder': 'press to send'}).keypress(function (e) { if (e.which == 13) { - var $item = bullechat.gui.addline($child, $(this).val(), 'You'); + var $item = bullechat.gui.addline($child, $(this).val(), 'You', false); if (!bullechat.socket.sendto(user, $(this).val())) $item.addClass('chfailed').click(function (e) { $(this).hide(750); }); @@ -51,10 +51,10 @@ var bullechat = { $('body').append($child); bullechat.gui.updown($child); }, - addline: function ($elem, msg, nick) { + addline: function ($elem, msg, nick, recvd) { var $item; if (nick) { - $item = $('
  • ').append($('',{'class':'chnick'}).text(bullechat.nickfmt(nick))).append(document.createTextNode(msg)); + $item = $('
  • ', {'class': (recvd ? 'recvd' : 'sent')}).text(msg); } else { $item = $('
  • ', {'class': 'chspecial'}).text(msg); } @@ -95,9 +95,9 @@ var bullechat = { message: function (e) { var data = JSON.parse(e.data); if (!data || !data['uname']) return; - if (!bullechat.gui.$windows[data['uname']]) bullechat.gui.create(data['uname']); + if (!bullechat.gui.$windows[data['uname']]) bullechat.gui.create(data['uname'], data['nick']); bullechat.gui.addline(bullechat.gui.$windows[data['uname']], - data['msg'], data['nick']); + data['msg'], data['nick'], true); }, start: function () { if (window.WebSocket) { -- cgit v1.2.3