]> git.mjollnir.org Git - moodle.git/commitdiff
chat: Prevent user from submitting a 2nd message before his 1st is received.
authormartinlanghoff <martinlanghoff>
Wed, 12 Jul 2006 02:29:12 +0000 (02:29 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 12 Jul 2006 02:29:12 +0000 (02:29 +0000)
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>

mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/insert.php
theme/standard/styles_color.css

index 2ed66eafffa2d4bba5715019d5bf39c726695a69..f3502e2dc4c24ae2f49d99c09b609ed9e0f372a7 100644 (file)
     ?>
     <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()">
-        &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>
 
index 7fd33fb838fc7cc241265abfd3088a930a286f6c..77e127c8a7bacfb04d780369bbde70be6cea15e1 100644 (file)
@@ -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');
index 01a2350d71fb1dff2d2970858caaf9857fec13f0..fd771394a32f5f881b12f7c999fd5e136aa4fc98 100644 (file)
@@ -709,6 +709,10 @@ table.message_search_results td {
   color:#888
 }
 
+#mod-chat-gui_header_js-chatinput .wait {
+    background: #dddddd;
+}
+
 /***
  *** Modules: Choice
  ***/