Code

Add "action" attributes to forms.
[roundup.git] / templates / classic / html / help_controls.js
1 // initial values for either Nosy, Superseder, Topic and Waiting On,
2 // depending on which has called
4 original_field = window.opener.document.itemSynopsis[field].value;
7 // pop() and push() methods for pre5.5 IE browsers
9 function bName() {
10     // test for IE 
11     if (navigator.appName == "Microsoft Internet Explorer")
12       return 1;
13     return 0;
14 }
16 function bVer() {
17     // return version number (e.g., 4.03)
18     msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
19     return(parseFloat(navigator.appVersion.substr(msieIndex,3)));
20 }
22 function pop() {
23     // make a pop method for old IE browsers
24     var lastElement = this[this.length - 1];
25     this.length--;
26     return lastElement;
27 }
29 function push() {
30     // make a pop method for old IE browsers
31     var sub = this.length;
32     for (var i = 0; i < push.arguments.length; ++i) {
33       this[sub] = push.arguments[i];
34         sub++;
35   }
36 }
38 // add the pop() and push() method to Array prototype for old IE browser
39 if (bName() == 1 && bVer() >= 5.5);
40 else {
41     Array.prototype.pop = pop;
42     Array.prototype.push = push;
43 }
45 function trim(value) {
46   var temp = value;
47   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
48   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
49   var obj = /  /g;
50   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
51   return temp;
52 }
54 function updateList() {
55   // write back to opener window
56   if (document.frm_help.check==undefined) { return; }
57   var list = new Array();
58   for (box=0; box < document.frm_help.check.length; box++) {
59       if (document.frm_help.check[box].checked) {
60           list.push(document.frm_help.check[box].value);
61       }
62   }
63   window.opener.document.itemSynopsis[field].value = list.join(",");
64 }
66 function updatePreview() {
67   // add new checkbox selections to preview
68   if (document.frm_help.check==undefined) { return; }
69   var list = new Array();
70   for (box=0; box < document.frm_help.check.length; box++) {
71       if (document.frm_help.check[box].checked) {
72           list.push(document.frm_help.check[box].value);
73       }
74   }
75   listString = new String(list.join(','));
76   writePreview(listString);
77 }
79 function clearList() {
80   // uncheck all checkboxes
81   if (document.frm_help.check==undefined) { return; }
82   for (box=0; box < document.frm_help.check.length; box++) {
83       document.frm_help.check[box].checked = false;
84   }
85 }
87 function reviseList(vals) {
88   // update the checkboxes based on the preview field
89   if (document.frm_help.check==undefined) { return; }
90   var to_check;
91   var list = vals.split(",");
92    for (box=0; box < document.frm_help.check.length; box++) {
93       check = document.frm_help.check[box];
94       to_check = false;
95       for (val in list) {
96           if (check.value==trim(list[val])) {
97               to_check = true;
98               break;
99           }
100       }
101       check.checked = to_check;
102   }
105 function resetList() {
106   // reset preview and check boxes to initial values
107   if (document.frm_help.check==undefined) { return; }
108   var to_check;
109   var list = original_field.split(',');
110   writePreview(list);
111   for (box=0; box < document.frm_help.check.length; box++) {
112       check = document.frm_help.check[box];
113       to_check = false;
114       for (val in list) {
115           if (check.value==trim(list[val])) {
116               to_check = true;
117               break;
118           }
119       }
120       check.checked = to_check;
121   }
124 function writePreview(val) {
125    // writes a value to the text_preview
126    document.frm_help.text_preview.value = val;
129 function focusField(name) {
130     for(i=0; i < document.forms.length; ++i) {
131       var obj = document.forms[i].elements[name];
132       if (obj && obj.focus) {obj.focus();}
133     }
136 function selectField(name) {
137     for(i=0; i < document.forms.length; ++i) {
138       var obj = document.forms[i].elements[name];
139       if (obj && obj.focus){obj.focus();} 
140       if (obj && obj.select){obj.select();}
141     }