]> git.mjollnir.org Git - moodle.git/commitdiff
mod-chat MDL-16706 Removed inline JS and replaced with new PAGE methods
authorsamhemelryk <samhemelryk>
Fri, 26 Jun 2009 06:53:23 +0000 (06:53 +0000)
committersamhemelryk <samhemelryk>
Fri, 26 Jun 2009 06:53:23 +0000 (06:53 +0000)
mod/chat/gui_sockets/chat_gui_sockets.js [new file with mode: 0644]
mod/chat/gui_sockets/chatinput.php

diff --git a/mod/chat/gui_sockets/chat_gui_sockets.js b/mod/chat/gui_sockets/chat_gui_sockets.js
new file mode 100644 (file)
index 0000000..68a8d1b
--- /dev/null
@@ -0,0 +1,14 @@
+scroll_active = true;
+function empty_field_and_submit() {
+    var cf   = document.getElementById('sendform');
+    var inpf = document.getElementById('inputform');
+    cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
+    cf.chat_message.value = inpf.chat_message.value;
+    inpf.chat_message.value='';
+    cf.submit();
+    inpf.chat_message.focus();
+    return false;
+}
+function setfocus() {
+    document.getElementsByName("chat_message")[0].focus();
+}
\ No newline at end of file
index 53dbc5c1b9b4cbd15281388fce6affc8e0d4a811..71c9e28ea93f21633f04642609277816cca7de6e 100644 (file)
 
     //Setup course, lang and theme
     $PAGE->set_course($DB->get_record('course', array('id' => $chatuser->course)));
-
-    ob_start();
-    ?>
-<script type="text/javascript">
-scroll_active = true;
-function empty_field_and_submit() {
-    var cf   = document.getElementById('sendform');
-    var inpf = document.getElementById('inputform');
-    cf.chat_msgidnr.value = parseInt(cf.chat_msgidnr.value) + 1;
-    cf.chat_message.value = inpf.chat_message.value;
-    inpf.chat_message.value='';
-    cf.submit();
-    inpf.chat_message.focus();
-    return false;
-}
-function setfocus() {
-    document.getElementsByName("chat_message")[0].focus(); 
-}
-</script>
-    <?php
-
-    $meta = ob_get_clean();
+    $PAGE->requires->js('mod/chat/gui_sockets/chat_gui_sockets.js')->in_head();
+    $PAGE->requires->js_function_call('setfocus');
     // TODO: there will be two onload in body tag, does it matter?
-    print_header('', '', '', 'inputform.chat_message', $meta, false, '&nbsp;', '', false, 'onload="setfocus();"');
+    print_header('', '', '', 'inputform.chat_message', '', false, '&nbsp;', '', false);
 
 ?>