Added file_get_contents for PHP before 4.3.0
[moodle.git] / lib / javascript-static.js
CommitLineData
63d28811 1function popUpProperties(inobj) {
2 op = window.open();
3 op.document.open('text/plain');
4 for (objprop in inobj) {
5 op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
6 }
7 op.document.close();
8}
9
10function fillmessagebox(text) {
11 document.form.message.value = text;
12}
13
14function copyrichtext(textname) {
15/// Legacy stub for old editor - to be removed soon
16 return true;
17}
18
19function checkall() {
20 void(d=document);
21 void(el=d.getElementsByTagName('INPUT'));
22 for(i=0;i<el.length;i++)
23 void(el[i].checked=1)
24}
25
03f9425f 26function checknone() {
27 void(d=document);
28 void(el=d.getElementsByTagName('INPUT'));
29 for(i=0;i<el.length;i++)
30 void(el[i].checked=0)
31}
32
63d28811 33function lockoptions(form, master, subitems) {
34 // subitems is an array of names of sub items
35 // requires that each item in subitems has a
36 // companion hidden item in the form with the
37 // same name but prefixed by "h"
38 if (eval("document."+form+"."+master+".checked")) {
39 for (i=0; i<subitems.length; i++) {
40 unlockoption(form, subitems[i]);
41 }
42 } else {
43 for (i=0; i<subitems.length; i++) {
44 lockoption(form, subitems[i]);
45 }
46 }
47 return(true);
48}
49
50function lockoption(form,item) {
51 eval("document."+form+"."+item+".disabled=true");/* IE thing */
52 eval("document."+form+".h"+item+".value=1");
53}
54
55function unlockoption(form,item) {
56 eval("document."+form+"."+item+".disabled=false");/* IE thing */
57 eval("document."+form+".h"+item+".value=0");
58}
7678e65c 59
60function submitFormById(id) {
61 var theform = document.getElementById(id);
62 if(!theform) {
63 return false;
64 }
65 if(theform.tagName != 'FORM') {
66 return false;
67 }
68 if(!theform.onsubmit || theform.onsubmit()) {
69 return theform.submit();
70 }
71}
363cb62c 72
73function select_all_in(elTagName, elId, elClass) {
74 var inputs = document.getElementsByTagName('INPUT');
75 inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elId, elClass);});
76 for(var i = 0; i < inputs.length; ++i) {
77 if(inputs[i].type == 'checkbox') {
78 inputs[i].checked = 'checked';
79 }
80 }
81}
82
83function deselect_all_in(elTagName, elId, elClass) {
84 var inputs = document.getElementsByTagName('INPUT');
85 inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elId, elClass);});
86 for(var i = 0; i < inputs.length; ++i) {
87 if(inputs[i].type == 'checkbox') {
88 inputs[i].checked = '';
89 }
90 }
91}
92
93function confirm_if(expr, message) {
94 if(!expr) {
95 return true;
96 }
97 return confirm(message);
98}