corrade-http-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 3  →  ?path2? @ 4
/groupChat/groupChat.html
@@ -8,8 +8,7 @@
<meta name="description" content="Group Chat Relay using Corrade">
<meta name="author" content="Wizardry and Steamworks">
<link rel="stylesheet" href="css/fonts.css?v=1.0">
 
<link rel="stylesheet" href="css/style.css?v=1.0">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
@@ -16,7 +15,13 @@
<script type="text/javascript">
$(document).ready(function () {
function sendGroupMessage() {
// Do not send the message if either the name or the message is empty.
// This check is performed in the PHP script as well.
if($.trim($("#name").val()) == '' || $.trim($('#message').val()) == '')
return;
// Hide the controls.
$("#controls").animate({ opacity: 'hide' }, 'slow');
// Make the POST request to the PHP script and pass the values of the fields.
$.ajax({
type: 'post',
url: "sendGroupMessage.php",
@@ -25,10 +30,15 @@
message: $("#message").val()
}
}).done(function(data) {
// If any error occurred, display it.
if(data)
alert(data);
// When the data returns, clear the message box and show the controls.
$('#message').val("");
$("#controls").animate({ opacity: 'show' }, 'slow');
});
}
// Polls the chatlog every second for changes.
setInterval(function () {
$.get("chat.log?t=" + Math.random(), function(data) {
$("#chat").html(data);
@@ -37,6 +47,8 @@
scrollTop:$("#chat")[0].scrollHeight - $("#chat").height()
},1000);
}, 1000);
// When the send button is pressed, then call the sendGroupMessage function to
// send the message to the PHP script, which then send the message to Corrade.
$("#send").click(function(e){
sendGroupMessage();
});