corrade-http-templates – Diff between revs 46 and 52
?pathlinks?
Rev 46 | Rev 52 | |||
---|---|---|---|---|
Line 58... | Line 58... | |||
58 | <script src="bower_components/bootstrap-validator/js/validator.js"></script> |
58 | <script src="bower_components/bootstrap-validator/js/validator.js"></script> |
|
59 | <!-- Include Velocity --> |
59 | <!-- Include Velocity --> |
|
60 | <script src="bower_components/velocity/velocity.min.js"></script> |
60 | <script src="bower_components/velocity/velocity.min.js"></script> |
|
61 | <script> |
61 | <script> |
|
62 | $(document).ready(function () { |
62 | $(document).ready(function () { |
|
63 | function sendGroupMessage() { |
63 | function sendGroupMessage(token) { |
|
64 | // Hide the controls. |
64 | // Hide the controls. |
|
65 | $("#controls").animate( |
65 | $("#controls").animate( |
|
66 | { |
66 | { |
|
67 | opacity: 0 |
67 | opacity: 0 |
|
68 | }, |
68 | }, |
|
Line 75... | Line 75... | |||
75 | $.ajax({ |
75 | $.ajax({ |
|
76 | type: 'post', |
76 | type: 'post', |
|
77 | url: "sendGroupMessage.php", |
77 | url: "sendGroupMessage.php", |
|
78 | data: { |
78 | data: { |
|
79 | name: $("#name").val(), |
79 | name: $("#name").val(), |
|
80 | message: $("#message").val() |
80 | message: $("#message").val(), |
|
- | 81 | token: token |
||
81 | } |
82 | } |
|
82 | }).done(function(data) { |
83 | }).done(function(data) { |
|
83 | // If any error occurred, display it. |
84 | // If any error occurred, display it. |
|
84 | if(data) |
85 | if(data) |
|
85 | alert(data); |
86 | alert(data); |
|
Line 94... | Line 95... | |||
94 | easing: "linear" |
95 | easing: "linear" |
|
95 | } |
96 | } |
|
96 | ); |
97 | ); |
|
97 | }); |
98 | }); |
|
98 | } |
99 | } |
|
- | 100 | |
||
99 | // Polls the chatlog every second for changes. |
101 | // Polls the chatlog every second for changes. |
|
100 | (function retrieveMessages() { |
102 | (function retrieveMessages() { |
|
101 | $.get("chat.log?t=" + Math.random(), function(data) { |
103 | $.get("chat.log?t=" + Math.random(), function(data) { |
|
102 | $("#chat").html(data); |
104 | $("#chat").html(data); |
|
103 | $("#chat").scrollTop($("#chat")[0].scrollHeight); |
105 | $("#chat").scrollTop($("#chat")[0].scrollHeight); |
|
104 | setTimeout(retrieveMessages, 1000); |
106 | setTimeout(retrieveMessages, 1000); |
|
105 | }); |
107 | }); |
|
106 | }()); |
108 | }()); |
|
- | 109 | |
||
- | 110 | $.get('session.php').then((token) => { |
||
107 | // When the send button is pressed, then call the sendGroupMessage function to |
111 | // When the send button is pressed, then call the sendGroupMessage function to |
|
108 | // send the message to the PHP script, which then send the message to Corrade. |
112 | // send the message to the PHP script, which then send the message to Corrade. |
|
109 | $("#send").click(function(e){ |
113 | $("#send").click(function(e){ |
|
110 | sendGroupMessage(); |
114 | sendGroupMessage(token); |
|
111 | }); |
115 | }); |
|
- | 116 | |
||
112 | // Subscribe to pressing enter with the message input box selected. |
117 | // Subscribe to pressing enter with the message input box selected. |
|
113 | $("#message").keypress(function(e) { |
118 | $("#message").keypress(function(e) { |
|
114 | if (e.which == 13) { |
119 | if (e.which == 13) { |
|
115 | sendGroupMessage(); |
120 | sendGroupMessage(token); |
|
116 | return false; |
121 | return false; |
|
- | 122 | } |
||
117 | } |
123 | }); |
|
118 | }); |
124 | }); |
|
119 | }); |
125 | }); |
|
120 | </script> |
126 | </script> |
|
121 | </body> |
127 | </body> |
|
122 | </html> |
128 | </html> |