corrade-http-templates – Blame information for rev 5

Subversion Repositories:
Rev:
Rev Author Line No. Line
2 eva 1 <!doctype html>
2  
3 <html lang="en">
4 <head>
5 <meta charset="utf-8">
6  
7 <title>Corrade Group Chat</title>
8  
9 <meta name="description" content="Group Chat Relay using Corrade">
10 <meta name="author" content="Wizardry and Steamworks">
4 eva 11  
2 eva 12 <link rel="stylesheet" href="css/style.css?v=1.0">
13  
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 () {
3 eva 17 function sendGroupMessage() {
4 eva 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.
20 if($.trim($("#name").val()) == '' || $.trim($('#message').val()) == '')
21 return;
22 // Hide the controls.
2 eva 23 $("#controls").animate({ opacity: 'hide' }, 'slow');
4 eva 24 // Make the POST request to the PHP script and pass the values of the fields.
2 eva 25 $.ajax({
26 type: 'post',
27 url: "sendGroupMessage.php",
28 data: {
29 name: $("#name").val(),
30 message: $("#message").val()
31 }
32 }).done(function(data) {
4 eva 33 // If any error occurred, display it.
34 if(data)
35 alert(data);
36 // When the data returns, clear the message box and show the controls.
2 eva 37 $('#message').val("");
38 $("#controls").animate({ opacity: 'show' }, 'slow');
39 });
3 eva 40 }
4 eva 41 // Polls the chatlog every second for changes.
5 zed 42 (function retrieveMessages() {
3 eva 43 $.get("chat.log?t=" + Math.random(), function(data) {
44 $("#chat").html(data);
5 zed 45 $("#chat").animate({
46 scrollTop:$("#chat")[0].scrollHeight - $("#chat").height()
47 },1000);
48 setTimeout(retrieveMessages, 1000);
3 eva 49 });
5 zed 50 }());
4 eva 51 // When the send button is pressed, then call the sendGroupMessage function to
52 // send the message to the PHP script, which then send the message to Corrade.
3 eva 53 $("#send").click(function(e){
54 sendGroupMessage();
2 eva 55 });
3 eva 56 // Subscribe to pressing enter with the message input box selected.
57 $("#message").keypress(function(e) {
58 if (e.which == 13) {
59 sendGroupMessage();
60 return false;
61 }
62 });
2 eva 63 });
64 </script>
65 </head>
66  
67 <body>
68 <div id="container">
5 zed 69 <textarea readonly='readonly' id="chat" rows="12"></textarea><br/>
2 eva 70 <div id="controls">
71 Name: <input type="text" size="8" value="Someone" id="name"></input>
72 Message: <input type="text" size="35" id="message"></input>
73 <button type="button" id="send">Send</button>
74 </div>
75 </div>
76 </body>
77 </html>