diff options
author | BlueRaja <BlueRaja.admin@gmail.com> | 2013-03-07 03:00:04 -0600 |
---|---|---|
committer | BlueRaja <BlueRaja.admin@gmail.com> | 2013-03-07 03:00:04 -0600 |
commit | 534566ca37d8da800188b073652003671fc9671a (patch) | |
tree | cd14d9353d19a365a80b519a21feeefe9152efcd /pages/chat.php | |
parent | ef912adeeac6be3d623d602ce17f69b15ce65aa8 (diff) | |
parent | ee270d30697914e322dd1256e2e3e0b60df0ced5 (diff) | |
download | pathery-534566ca37d8da800188b073652003671fc9671a.tar.xz |
Merge branch 'master' of git.raylu.net:pathery
Conflicts:
includes/db.inc.php
Diffstat (limited to 'pages/chat.php')
-rw-r--r-- | pages/chat.php | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/pages/chat.php b/pages/chat.php index 27122d8..d2198c7 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,13 @@ 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'>");
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(&)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%26$3' target='_blank'>");
+ //Making the bet that not all browsers do the same:
+ chat = chat.replace(/<a href='redirect\?to=(.*?)(&)(.*?)' target='_blank'>/ig, "<a href='redirect?to=$1%26$3' target='_blank'>");
return chat;
}
@@ -212,6 +223,10 @@ function htmlEncode(value){ }
}
+function setChatMute(value) {
+ savePref('chatMute', value);
+}
+
</script>
<div class='wrapper'>
@@ -223,6 +238,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" >
<? } ?>
|