Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

chat: Prevent user from submitting a 2nd message before his 1st is re…

…ceived.

Some users reported that mod/chat was silently dropping some messages. The
user's browser may not be able to keep up with the rate at which he submits
chat messages. This update keeps things sane.

Merged from MOODLE_16_STABLE

Author: Donal McMullan <donal@catalyst.net.nz>
  • Loading branch information...
commit 07b76bad6af1b31bfaf40728fce791f611e0d497 1 parent 1a9b9a0
martinlanghoff authored
View
20 mod/chat/gui_header_js/chatinput.php
@@ -29,13 +29,25 @@
?>
<script type="text/javascript">
<!--
+ var waitFlag = false;
function empty_field_and_submit() {
- document.sendForm.chat_message.value = document.inputForm.chat_message.value;
- document.inputForm.chat_message.value = '';
+ if(waitFlag) return false;
+ waitFlag = true;
+ var input_chat_message = document.getElementById('input_chat_message');
+ document.sendForm.chat_message.value = input_chat_message.value;
+ input_chat_message.value = '';
+ input_chat_message.className = 'wait';
document.sendForm.submit();
- document.inputForm.chat_message.focus();
return false;
}
+
+ function enableForm() {
+ var input_chat_message = document.getElementById('input_chat_message');
+ waitFlag = false;
+ input_chat_message.className = '';
+ input_chat_message.focus();
+ }
+
// -->
</script>
<?php
@@ -46,7 +58,7 @@ function empty_field_and_submit() {
?>
<form action="../empty.php" method="POST" target="empty" name="inputForm"
OnSubmit="return empty_field_and_submit()">
- &gt;&gt;<input type="text" name="chat_message" size="60" value="" />
+ &gt;&gt;<input type="text" id="input_chat_message" name="chat_message" size="60" value="" />
<?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?>
</form>
View
2  mod/chat/gui_header_js/insert.php
@@ -58,7 +58,7 @@
if ($chatuser->version == 'header_js') {
/// force msg referesh ASAP
- echo '<script type="text/javascript">parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;</script>';
+ echo '<script type="text/javascript">parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;parent.input.enableForm();</script>';
}
redirect('../empty.php');
View
4 theme/standard/styles_color.css
@@ -709,6 +709,10 @@ table.message_search_results td {
color:#888
}
+#mod-chat-gui_header_js-chatinput .wait {
+ background: #dddddd;
+}
+
/***
*** Modules: Choice
***/

0 comments on commit 07b76ba

Please sign in to comment.
Something went wrong with that request. Please try again.