]> git.mjollnir.org Git - moodle.git/commitdiff
chat MDL-16673 Clean up inline script and output calls
authorsamhemelryk <samhemelryk>
Thu, 17 Sep 2009 06:17:05 +0000 (06:17 +0000)
committersamhemelryk <samhemelryk>
Thu, 17 Sep 2009 06:17:05 +0000 (06:17 +0000)
mod/chat/gui_header_js/chat_gui_header.js
mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/insert.php

index c9c9b7039dcff10797846aa8f0cb0bc7368a53c9..e4172c33a5da1e78bec48454ae690daac488c939 100644 (file)
@@ -43,4 +43,8 @@ function update() {
         }
     }
     timer = setTimeout("update()", f*1000);
+}
+
+function insert_redirect() {
+    parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;
 }
\ No newline at end of file
index cd52b35bb732d1070d21377e63bd87e164b73a30..45117f2d11bb3028e4ac64e0eb44faddfcac90c1 100644 (file)
@@ -22,7 +22,9 @@
     if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
         error('Course Module ID was incorrect');
     }
-    
+
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/chat/gui_header_js/chatinput.php', array('chat_sid'=>$chat_sid, 'chat_id'=>$chatid)));
+
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     //Get the user theme
index 08cc3d5ebab93b4c3696e132fdd65dc3d84d02df..d92a45f3d608dfe12998cd020b8ecab055a93fdf 100644 (file)
 
     if ($chatuser->version == 'header_js') {
         /// force msg referesh ASAP
-        if ($CFG->chat_normal_updatemode == 'jsupdated') {  // See bug MDL-6791
-            echo '<script type="text/javascript">'.
-                 "//<![CDATA[ \n".
-                 '  parent.input.enableForm();'.
-                 "//]]> \n".
-                 '</script>';
-        } else {
-            echo '<script type="text/javascript">'.
-                 "//<![CDATA[ \n".
-                 '  parent.jsupdate.location.href = parent.jsupdate.document.anchors[0].href;'.
-                 '  parent.input.enableForm();'.
-                 "//]]> \n".
-                 '</script>';
+        echo $PAGE->requires->js('mod/chat/gui_header_js/chat_gui_header.js')->asap();
+        if ($CFG->chat_normal_updatemode != 'jsupdated') {  // See bug MDL-6791
+            echo $PAGE->requires->js_function_call('insert_redirect')->asap();;
         }
+        echo $PAGE->requires->js_function_call('parent.input.enableForm')->asap();
     }
 
     redirect('../empty.php');