corrade-http-templates – Blame information for rev 30

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  
27 office 7 <title>Corrade Group Chat Template</title>
8  
9 <meta charset="utf-8">
10 <meta http-equiv="X-UA-Compatible" content="IE=edge">
11 <meta name="viewport" content="width=device-width, initial-scale=1">
2 eva 12 <meta name="description" content="Group Chat Relay using Corrade">
13 <meta name="author" content="Wizardry and Steamworks">
27 office 14 <link rel="icon" href="../../favicon.ico">
4 eva 15  
27 office 16 <!-- Bootstrap core CSS -->
17 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
28 office 18 <!-- <link rel="stylesheet" href="css/style.css?v=1.1"> -->
19 </head>
20  
21 <body>
22 <div class="container">
30 office 23 <form role="form" data-toggle="validator">
28 office 24 <div class="form-group">
25 <textarea class="form-control" id="chat" readonly="readonly" rows="12"></textarea>
26 </div>
27 <div class="form-group">
28 <div id="controls">
29 <div class="input-group">
30 office 30 <input class="form-control" id="name" maxlength="8" type="text" value="Someone" required>
28 office 31 <span class="input-group-addon">@</span>
30 office 32 <input class="form-control" id="message" type="text" required>
28 office 33 <span class="input-group-btn">
30 office 34 <button class="btn btn-default" id="send" type="submit">Send</button>
28 office 35 </span>
36 </div>
37 </div>
38 </div>
39 </form>
40 </div>
2 eva 41  
30 office 42 <!-- Include jQuery -->
43 <script src="bower_components//jquery/dist/jquery.min.js"></script>
44 <!-- Include Bootstrap Validator -->
45 <script src="bower_components/bootstrap-validator/js/validator.js"></script>
46 <script>
2 eva 47 $(document).ready(function () {
3 eva 48 function sendGroupMessage() {
4 eva 49 // Hide the controls.
2 eva 50 $("#controls").animate({ opacity: 'hide' }, 'slow');
4 eva 51 // Make the POST request to the PHP script and pass the values of the fields.
2 eva 52 $.ajax({
53 type: 'post',
54 url: "sendGroupMessage.php",
55 data: {
56 name: $("#name").val(),
57 message: $("#message").val()
58 }
59 }).done(function(data) {
4 eva 60 // If any error occurred, display it.
61 if(data)
62 alert(data);
63 // When the data returns, clear the message box and show the controls.
2 eva 64 $('#message').val("");
65 $("#controls").animate({ opacity: 'show' }, 'slow');
66 });
3 eva 67 }
4 eva 68 // Polls the chatlog every second for changes.
5 zed 69 (function retrieveMessages() {
3 eva 70 $.get("chat.log?t=" + Math.random(), function(data) {
71 $("#chat").html(data);
22 office 72 $("#chat").scrollTop($("#chat")[0].scrollHeight);
5 zed 73 setTimeout(retrieveMessages, 1000);
3 eva 74 });
5 zed 75 }());
4 eva 76 // When the send button is pressed, then call the sendGroupMessage function to
77 // send the message to the PHP script, which then send the message to Corrade.
3 eva 78 $("#send").click(function(e){
79 sendGroupMessage();
2 eva 80 });
3 eva 81 // Subscribe to pressing enter with the message input box selected.
82 $("#message").keypress(function(e) {
83 if (e.which == 13) {
84 sendGroupMessage();
85 return false;
86 }
87 });
2 eva 88 });
89 </script>
90 </body>
91 </html>