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