From c7d671712a9d5f90752475960c3a602aeb0da8d0 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 15 Jan 2013 01:40:54 -0800 Subject: Chat cleanup --- ajax_chat.php | 16 ++++++++++------ includes/playerStats.php | 2 +- pages/chat.php | 40 +++++++++++++++++++++++----------------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ajax_chat.php b/ajax_chat.php index 37521de..04a6fd4 100644 --- a/ajax_chat.php +++ b/ajax_chat.php @@ -20,13 +20,14 @@ if ($_REQUEST['messages']) { if ($_REQUEST['getChatFromID']) { + $getChatID = $_REQUEST['getChatFromID']; if ($sent) { //Wait .2 seconds usleep(200000); //echo "yesSent"; for( $i = 1; $i < 3; $i++) { //echo "loop"; - $data = getChat($_REQUEST['getChatFromID']); + $data = getChat($getChatID); if ($data !== false) { //$data['debug'][] = "Count times: $i"; //$data['debug'][] = "Count value:".count($data); @@ -38,17 +39,20 @@ if ($_REQUEST['getChatFromID']) { } } //echo "reachedEnd"; - $json = prepareChatData(getChat($_REQUEST['getChatFromID'])); + $json = prepareChatData(getChat($getChatID)); echo $json; exit; } function prepareChatData($data) { - foreach($data as &$user) { - //$user['message'] = $user['message'].'write-append'; - $user['secondsSince'] = strtotime($user['dateSent']) - strtotime("now"); + if ($data) { + foreach($data as &$user) { + //$user['message'] = $user['message'].'write-append'; + $user['secondsSince'] = strtotime($user['dateSent']) - strtotime("now"); + } + return json_encode($data); } - return json_encode($data); + return $data; } diff --git a/includes/playerStats.php b/includes/playerStats.php index ec9a616..b64fb8d 100644 --- a/includes/playerStats.php +++ b/includes/playerStats.php @@ -1,5 +1,5 @@ ["+timestamp+"]"; p = p+ "
"; @@ -138,7 +143,7 @@ function getChatDone(data) { newChats = true; }); - console.log("BUILD DONE"); + //console.log("BUILD DONE"); if (newChats) { var new_chatDiv = $('
', { @@ -148,11 +153,11 @@ function getChatDone(data) { }); new_chatDiv.prependTo('#chatContainer').slideDown('fast'); } - console.log('(END) lastID', lastID); + //console.log('(END) lastID', lastID); } function getChat(message) { - console.log('LASTID:', lastID); + //console.log('LASTID:', lastID); var dataString = 'getChatFromID='+lastID; if (chatBuffer.length > 0) { dataString += '&send=true&messages='+chatBuffer.join('|:|'); @@ -198,13 +203,14 @@ function htmlEncode(value){ -

this page will overflow...

+

Pathery Chat - BETA

- - + + +
-- cgit v1.2.3