]> 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 05:55:55 +0000 (05:55 +0000)
committersamhemelryk <samhemelryk>
Fri, 26 Jun 2009 05:55:55 +0000 (05:55 +0000)
mod/chat/gui_header_js/chat_gui_header.js
mod/chat/gui_header_js/chatinput.php
mod/chat/gui_header_js/users.php

index 7c7540054dba7d684b85bca52c3d5738c7a3586d..ddfe2614a34f0a6241f358545fc8a2b7082a7b0a 100644 (file)
@@ -18,4 +18,28 @@ function enableForm() {
     waitFlag = false;
     input_chat_message.className = '';
     input_chat_message.focus();
+}
+
+var timer = null
+var f = 1; //seconds
+function stop() {
+    clearTimeout(timer)
+}
+
+function start() {
+    timer = setTimeout("update()", f*1000);
+}
+
+function update() {
+    for(i=0; i<uidles.length; i++) {
+        el = document.getElementById(uidles[i]);
+        if (el != null) {
+            parts = el.innerHTML.split(":");
+            time = f + (parseInt(parts[0], 10)*60) + parseInt(parts[1], 10);
+            min = Math.floor(time/60);
+            sec = time % 60;
+            el.innerHTML = ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec;
+        }
+    }
+    timer = setTimeout("update()", f*1000);
 }
\ No newline at end of file
index 2729a6e18e841eb82357b9b9006afe3bdabdff08..9e3a648e51f73b11d2d3aee820bed7fe605a5543 100644 (file)
@@ -31,7 +31,7 @@
 
     //Setup course, lang and theme
     $PAGE->set_course($course);
-    $PAGE->requires->js('mod/chat/gui_header_js/chat_gui_header.js');
+    $PAGE->requires->js('mod/chat/gui_header_js/chat_gui_header.js')->in_head();
 
     print_header('', '', '', 'input_chat_message', '', false);
 
index a8f976b695ddc1320dc53134d7d21edad3217b52..18f2beb7629edd850494ed67743dc01e7db785bd 100644 (file)
         print_error('errornousers', 'chat');
     }
 
-    ob_start();
-    ?>
-    <script type="text/javascript">
-    //<![CDATA[
-    var timer = null
-    var f = 1; //seconds
-    var uidles = new Array(<?php echo count($chatusers) ?>);
-    <?php
-        $i = 0;
-        foreach ($chatusers as $chatuser) {
-            echo "uidles[$i] = 'uidle{$chatuser->id}';\n";
-            $i++;
-        }
-    ?>
-
-    function stop() {
-        clearTimeout(timer)
-    }
-
-    function start() {
-        timer = setTimeout("update()", f*1000);
-    }
-
-    function update() {
-        for(i=0; i<uidles.length; i++) {
-            el = document.getElementById(uidles[i]);
-            if (el != null) {
-                parts = el.innerHTML.split(":");
-                time = f + (parseInt(parts[0], 10)*60) + parseInt(parts[1], 10);
-                min = Math.floor(time/60);
-                sec = time % 60;
-                el.innerHTML = ((min < 10) ? "0" : "") + min + ":" + ((sec < 10) ? "0" : "") + sec;
-            }
-        }
-        timer = setTimeout("update()", f*1000);
+    $uidles = Array();
+    $i = 0;
+    foreach ($chatusers as $chatuser) {
+        $uidles[$i] = 'uidle{$chatuser->id}';
+        $i++;
     }
-    //]]>
-    </script>
-    <?php
-
-
-    /// Print headers
-    $meta = ob_get_clean();
-
+    $PAGE->requires->data_for_js('uidles', $uidles)->in_head();
+    $PAGE->requires->js('mod/chat/gui_header_js/chat_gui_header.js')->in_head();
 
     // Use ob to support Keep-Alive
     ob_start();
-    print_header('', '', '', '', $meta, false, '', '', false, 'onload="start()" onunload="stop()"');
+    print_header('', '', '', '', '', false, '', '', false, 'onload="start()" onunload="stop()"');
 
 
     /// Print user panel body