corrade-http-templates – Diff between revs 3 and 4

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 3 Rev 4
Line 6... Line 6...
6   6  
Line 7... Line 7...
7 <title>Corrade Group Chat</title> 7 <title>Corrade Group Chat</title>
8 8
9 <meta name="description" content="Group Chat Relay using Corrade"> 9 <meta name="description" content="Group Chat Relay using Corrade">
10 <meta name="author" content="Wizardry and Steamworks"> -  
11 10 <meta name="author" content="Wizardry and Steamworks">
Line 12... Line 11...
12 <link rel="stylesheet" href="css/fonts.css?v=1.0"> 11  
13 <link rel="stylesheet" href="css/style.css?v=1.0"> 12 <link rel="stylesheet" href="css/style.css?v=1.0">
14 13
15 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> 14 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
-   15 <script type="text/javascript">
-   16 $(document).ready(function () {
-   17 function sendGroupMessage() {
-   18 // Do not send the message if either the name or the message is empty.
-   19 // This check is performed in the PHP script as well.
16 <script type="text/javascript"> 20 if($.trim($("#name").val()) == '' || $.trim($('#message').val()) == '')
-   21 return;
17 $(document).ready(function () { 22 // Hide the controls.
18 function sendGroupMessage() { 23 $("#controls").animate({ opacity: 'hide' }, 'slow');
19 $("#controls").animate({ opacity: 'hide' }, 'slow'); 24 // Make the POST request to the PHP script and pass the values of the fields.
20 $.ajax({ 25 $.ajax({
21 type: 'post', 26 type: 'post',
22 url: "sendGroupMessage.php", 27 url: "sendGroupMessage.php",
23 data: { 28 data: {
24 name: $("#name").val(), 29 name: $("#name").val(),
-   30 message: $("#message").val()
-   31 }
-   32 }).done(function(data) {
-   33 // If any error occurred, display it.
25 message: $("#message").val() 34 if(data)
26 } 35 alert(data);
27 }).done(function(data) { 36 // When the data returns, clear the message box and show the controls.
28 $('#message').val(""); 37 $('#message').val("");
-   38 $("#controls").animate({ opacity: 'show' }, 'slow');
29 $("#controls").animate({ opacity: 'show' }, 'slow'); 39 });
30 }); 40 }
31 } 41 // Polls the chatlog every second for changes.
32 setInterval(function () { 42 setInterval(function () {
33 $.get("chat.log?t=" + Math.random(), function(data) { 43 $.get("chat.log?t=" + Math.random(), function(data) {
34 $("#chat").html(data); 44 $("#chat").html(data);
35 }); 45 });
36 $("#chat").animate({ 46 $("#chat").animate({
-   47 scrollTop:$("#chat")[0].scrollHeight - $("#chat").height()
-   48 },1000);
37 scrollTop:$("#chat")[0].scrollHeight - $("#chat").height() 49 }, 1000);
38 },1000); 50 // When the send button is pressed, then call the sendGroupMessage function to
39 }, 1000); 51 // send the message to the PHP script, which then send the message to Corrade.
40 $("#send").click(function(e){ 52 $("#send").click(function(e){
41 sendGroupMessage(); 53 sendGroupMessage();