chat: Prevent user from submitting a 2nd message before his 1st is received.
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. Author: Donal McMullan <[email protected]>
This commit is contained in:
@@ -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 @@
|
||||
?>
|
||||
<form action="../empty.php" method="POST" target="empty" name="inputForm"
|
||||
OnSubmit="return empty_field_and_submit()">
|
||||
>><input type="text" name="chat_message" size="60" value="" />
|
||||
>><input type="text" id="input_chat_message" name="chat_message" size="60" value="" />
|
||||
<?php helpbutton('chatting', get_string('helpchatting', 'chat'), 'chat', true, false); ?>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -709,6 +709,10 @@ table.message_search_results td {
|
||||
color:#888
|
||||
}
|
||||
|
||||
#mod-chat-gui_header_js-chatinput .wait {
|
||||
background: #dddddd;
|
||||
}
|
||||
|
||||
/***
|
||||
*** Modules: Choice
|
||||
***/
|
||||
|
||||
Reference in New Issue
Block a user