summaryrefslogtreecommitdiffstats
path: root/pages/chat.php
diff options
context:
space:
mode:
Diffstat (limited to 'pages/chat.php')
-rw-r--r--pages/chat.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/pages/chat.php b/pages/chat.php
index 27122d8..f2d2231 100644
--- a/pages/chat.php
+++ b/pages/chat.php
@@ -45,6 +45,9 @@ function getChatDone(data) {
var p; //our prep string
var newChats = false;
+ var lastDisplay = '';
+ var lastMessage = '';
+
////console.log('datalength', data.length);
if (data.length < 3 || data == 'false')
@@ -118,6 +121,8 @@ function getChatDone(data) {
items.push('<div class="chatMessage'+strClass+'" id="C_' + chat.ID + '">' + p + '</div>');
newChats = true;
}
+ lastDisplay = chat.displayName
+ lastMessage = chat.message
if (chat.ID > 0) lastID = chat.ID;
});
@@ -130,15 +135,18 @@ function getChatDone(data) {
var atBottom = (elem.scrollTop() >= elem[0].scrollHeight - elem.outerHeight() - 1);
$("#chatContainer").append(items.join(''));
-
+
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');
+ document.title = lastDisplay+': '+lastMessage.substring(0, 10)+'... Pathery Chat';
+ if (!document.getElementById('chatMute').checked) {
+ soundManager.setVolume('charm', 20);
+ soundManager.setPan('charm', -60)
+ soundManager.setPosition('charm',150);
+ soundManager.play('charm');
+ }
}
}
@@ -150,10 +158,10 @@ function chatReplaceAndEncode(chat) {
//Surround all URLs with a <a> link
var URLexp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
- chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='top'>$1</a>");
+ chat = chat.replace(URLexp, "<a href='redirect?to=$1' target='_blank'>$1</a>");
//Replace # in the URL with %23
- chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='top'>/ig, "<a href='redirect?to=$1%23$3' target='top'>");
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(#)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%23$3' target='_blank'>");
return chat;
}
@@ -212,6 +220,10 @@ function htmlEncode(value){
}
}
+function setChatMute(value) {
+ savePref('chatMute', value);
+}
+
</script>
<div class='wrapper'>
@@ -223,6 +235,14 @@ function htmlEncode(value){
<form id='sendChat' onsubmit="return false">
<? if($accepted) { /*Only show the chat button if we're logged in*/ ?>
<input type="hidden" name="stuff" value="1724">
+
+ <?
+ $chatMute = '';
+ if (isset($_COOKIE['pref_chatMute']) && $_COOKIE['pref_chatMute'] == "true") $chatMute = "checked='checked' ";
+ echo "
+ <input title='Mute sound?' onClick='setChatMute(this.checked)' type='checkbox' id='chatMute' class='chatMute' $chatMute/>";
+ ?>
+
<input class='chatButton' type="button" class="send" id='chatSendBtn' value='Send' onClick="sendChat();">
<input class='chatInputMessage' type="text" name="message" id="message" value="" maxlength="255" autocomplete="off" >
<? } ?>