MDL-15942 - separate data escaped for database entry from unescaped data
[moodle-linuxchix.git] / lib / javascript.php
blobcff899ea97871e5b72df2779faf03ca0cf829010
1 <?php /// $Id$
2 /// Load up any required Javascript libraries
4 if (!defined('MOODLE_INTERNAL')) {
5 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
8 if (!empty($CFG->aspellpath)) { // Enable global access to spelling feature.
9 echo '<script type="text/javascript" src="'.$CFG->httpswwwroot.'/lib/speller/spellChecker.js"></script>'."\n";
12 if (!empty($CFG->editorsrc) ) {
13 foreach ( $CFG->editorsrc as $scriptsource ) {
14 echo '<script type="text/javascript" src="'. $scriptsource .'"></script>'."\n";
19 <!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(<?php echo $CFG->httpswwwroot ?>/lib/csshover.htc);} /*]]>*/</style>-->
21 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/javascript-static.js"></script>
22 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/javascript-mod.php"></script>
23 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/overlib/overlib.js"></script>
24 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/overlib/overlib_cssstyle.js"></script>
25 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/cookies.js"></script>
26 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/ufo.js"></script>
27 <script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/dropdown.js"></script>
29 <script type="text/javascript" defer="defer">
30 //<![CDATA[
31 setTimeout('fix_column_widths()', 20);
32 //]]>
33 </script>
34 <script type="text/javascript">
35 //<![CDATA[
36 function openpopup(url,name,options,fullscreen) {
37 fullurl = "<?php echo $CFG->httpswwwroot ?>" + url;
38 windowobj = window.open(fullurl,name,options);
39 if (fullscreen) {
40 windowobj.moveTo(0,0);
41 windowobj.resizeTo(screen.availWidth,screen.availHeight);
43 windowobj.focus();
44 return false;
47 function uncheckall() {
48 void(d=document);
49 void(el=d.getElementsByTagName('INPUT'));
50 for(i=0;i<el.length;i++) {
51 void(el[i].checked=0);
55 function checkall() {
56 void(d=document);
57 void(el=d.getElementsByTagName('INPUT'));
58 for(i=0;i<el.length;i++) {
59 void(el[i].checked=1);
63 function inserttext(text) {
64 <?php
65 if (!empty($SESSION->inserttextform)) {
66 $insertfield = "opener.document.forms['$SESSION->inserttextform'].$SESSION->inserttextfield";
67 } else {
68 $insertfield = "opener.document.forms['theform'].message";
70 echo " text = ' ' + text + ' ';\n";
71 echo " if ( $insertfield.createTextRange && $insertfield.caretPos) {\n";
72 echo " var caretPos = $insertfield.caretPos;\n";
73 echo " caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;\n";
74 echo " } else {\n";
75 echo " $insertfield.value += text;\n";
76 echo " }\n";
77 echo " $insertfield.focus();\n";
80 <?php if (!empty($focus)) {
81 if(($pos = strpos($focus, '.')) !== false) {
82 //old style focus using form name - no allowed inXHTML Strict
83 $topelement = substr($focus, 0, $pos);
84 echo "addonload(function() { if(document.$topelement) document.$focus.focus(); });\n";
85 } else {
86 //focus element with given id
87 echo "addonload(function() { if(el = document.getElementById('$focus')) el.focus(); });\n";
89 $focus=false; // Prevent themes from adding it to body tag which breaks addonload(), MDL-10249
90 } ?>
92 function getElementsByClassName(oElm, strTagName, oClassNames){
93 var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
94 var arrReturnElements = new Array();
95 var arrRegExpClassNames = new Array();
96 if(typeof oClassNames == "object"){
97 for(var i=0; i<oClassNames.length; i++){
98 arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
101 else{
102 arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
104 var oElement;
105 var bMatchesAll;
106 for(var j=0; j<arrElements.length; j++){
107 oElement = arrElements[j];
108 bMatchesAll = true;
109 for(var k=0; k<arrRegExpClassNames.length; k++){
110 if(!arrRegExpClassNames[k].test(oElement.className)){
111 bMatchesAll = false;
112 break;
115 if(bMatchesAll){
116 arrReturnElements.push(oElement);
119 return (arrReturnElements)
121 //]]>
122 </script>