From aecf8ced62fd1e8594239566d62f5cc71e8fd27c Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sun, 17 Feb 2013 03:01:46 -0800 Subject: Reversed order of chat, added sounds. --- css/chat.css | 11 +++++++++-- pages/chat.php | 37 +++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/css/chat.css b/css/chat.css index 6dcf629..0b38d70 100644 --- a/css/chat.css +++ b/css/chat.css @@ -1,6 +1,6 @@ .chatInputMessage { - font-family:Comic Sans MS, Comic Sans MS5, cursive; + font-family: 'Trebuchet MS1', 'Trebuchet MS', sans-serif; border: 1px solid gray; background-color:#999; width: 700px; @@ -45,7 +45,12 @@ font-size: 16px; display: inline-block; width: 525px; - padding: 5px 5px 5px 5px; + padding: 5px 5px 5px 5px; + white-space: pre-wrap; /* CSS3 */ + white-space: -moz-pre-wrap; /* Firefox */ + white-space: -pre-wrap; /* Opera <7 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* IE */ } .chatTimestamp { font-family:"Times New Roman", Times, serif; @@ -92,6 +97,8 @@ .chatContainer2 { background-color: #222; + padding:10px; + padding-bottom:0px; border-radius: 12px; width:810px; margin:0 auto 5px; diff --git a/pages/chat.php b/pages/chat.php index cdf9b01..e165457 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -7,14 +7,12 @@ htmlHeader( ?> Please login to chat!"; } - - - ?> @@ -41,6 +39,7 @@ function getChatTimer() { getChat(); } +var firstGetChat = true; function getChatDone(data) { var items = []; var p; //our prep string @@ -97,7 +96,7 @@ function getChatDone(data) { strClass += ' server'; } - items.unshift('
' + p + '
'); + items.push('
' + p + '
'); newChats = true; }); @@ -108,22 +107,38 @@ function getChatDone(data) { var new_chatDiv = $('
', { 'class': 'my-new-list', - 'style': 'display: none', + //'style': 'display: none', html: items.join('') }); - new_chatDiv.prependTo('#chatContainer').slideDown('fast'); + var elem = $("#chatContainer"); + //var atBottom = (elem[0].scrollHeight - elem.scrollTop() == elem.outerHeight()); + var atBottom = (elem.scrollTop() >= elem[0].scrollHeight - elem.outerHeight() - 1); + + + //var elem = $("#chatContainer"); console.log ("Ret", elem[0].scrollHeight, elem.scrollTop(), elem.outerHeight(), elem[0].scrollHeight - elem.scrollTop()); + + //new_chatDiv.appendTo('#chatContainer').slideDown('fast'); + new_chatDiv.appendTo('#chatContainer'); + + if (atBottom || firstGetChat) { + $("#chatContainer").scrollTop($("#chatContainer")[0].scrollHeight); + firstGetChat = false; + } + soundManager.setVolume('charm', 20); + soundManager.setPan('charm', -60) + soundManager.setPosition('charm',150); + soundManager.play('charm'); } - //console.log('(END) lastID', lastID); } function prepChat(chat) { chat = chat.join('|:|'); chat = chat.replace(/\&/g,'%26') + chat = chat.replace(/\+/g,'%2B') return chat; } function getChat(message) { - //console.log('LASTID:', lastID); var dataString = 'getChatFromID='+lastID; if (chatBuffer.length > 0) { dataString += '&send=true&messages='+prepChat(chatBuffer); @@ -172,6 +187,8 @@ function htmlEncode(value){

Pathery Chat - BETA

+
+
@@ -179,10 +196,6 @@ function htmlEncode(value){
-
- -
-
-- cgit v1.2.3