corrade-http-templates – Blame information for rev 37

Subversion Repositories:
Rev:
Rev Author Line No. Line
37 office 1 <!DOCTYPE html>
2 eva 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">
35 office 18 <link rel="stylesheet" href="css/style.css?v=1.3">
28 office 19 </head>
20  
21 <body>
33 office 22 <!-- Group chat container. -->
28 office 23 <div class="container">
30 office 24 <form role="form" data-toggle="validator">
28 office 25 <div class="form-group">
26 <textarea class="form-control" id="chat" readonly="readonly" rows="12"></textarea>
27 </div>
33 office 28 <div class="form-group row">
37 office 29 <!-- Controls -->
28 office 30 <div id="controls">
33 office 31 <div class="col-xs-3">
32 <div class="input-group">
33 <span class="input-group-addon">
34 <label for="name">Name</label>
35 </span>
36 <input class="form-control" id="name" maxlength="8" type="text" value="Someone" required>
37 </div>
38 </div>
34 office 39 <div class="col-lg-1">
33 office 40 <div class="input-group">
41 <span class="input-group-addon">
42 <label for="message">Message</label>
43 </span>
44 <div class="input-group col-xs-12">
45 <input class="form-control" id="message" type="text" required>
46 <span class="input-group-btn">
47 <button class="btn btn-default" id="send" type="submit">Send</button>
48 </span>
49 </div>
50 </div>
51 </div>
28 office 52 </div>
53 </div>
54 </form>
55 </div>
2 eva 56  
30 office 57 <!-- Include jQuery -->
32 office 58 <script src="bower_components/jquery/dist/jquery.min.js"></script>
30 office 59 <!-- Include Bootstrap Validator -->
60 <script src="bower_components/bootstrap-validator/js/validator.js"></script>
32 office 61 <!-- Include Velocity -->
62 <script src="bower_components/velocity/velocity.min.js"></script>
30 office 63 <script>
2 eva 64 $(document).ready(function () {
3 eva 65 function sendGroupMessage() {
4 eva 66 // Hide the controls.
32 office 67 $("#controls").animate(
68 {
69 opacity: 0
70 },
71 {
72 duration: 1000,
73 easing: "linear"
74 }
75 );
4 eva 76 // Make the POST request to the PHP script and pass the values of the fields.
2 eva 77 $.ajax({
78 type: 'post',
79 url: "sendGroupMessage.php",
80 data: {
81 name: $("#name").val(),
82 message: $("#message").val()
83 }
84 }).done(function(data) {
4 eva 85 // If any error occurred, display it.
86 if(data)
87 alert(data);
88 // When the data returns, clear the message box and show the controls.
2 eva 89 $('#message').val("");
32 office 90 $("#controls").animate(
91 {
92 opacity: 1
93 },
94 {
95 duration: 1000,
96 easing: "linear"
97 }
98 );
2 eva 99 });
3 eva 100 }
4 eva 101 // Polls the chatlog every second for changes.
5 zed 102 (function retrieveMessages() {
3 eva 103 $.get("chat.log?t=" + Math.random(), function(data) {
104 $("#chat").html(data);
22 office 105 $("#chat").scrollTop($("#chat")[0].scrollHeight);
5 zed 106 setTimeout(retrieveMessages, 1000);
3 eva 107 });
5 zed 108 }());
4 eva 109 // When the send button is pressed, then call the sendGroupMessage function to
110 // send the message to the PHP script, which then send the message to Corrade.
3 eva 111 $("#send").click(function(e){
112 sendGroupMessage();
2 eva 113 });
3 eva 114 // Subscribe to pressing enter with the message input box selected.
115 $("#message").keypress(function(e) {
116 if (e.which == 13) {
117 sendGroupMessage();
118 return false;
119 }
120 });
2 eva 121 });
122 </script>
123 </body>
124 </html>