49db257d |
1 | /** |
2 | * This array is used to remember mark status of rows in browse mode |
3 | */ |
4 | var marked_row = new Array; |
5 | var orig_row_colors = new Array(); |
6 | |
7 | |
8 | /* |
9 | * (un)Checks checkbox for the row that the current table cell is in |
10 | * when it gets clicked. |
11 | * |
12 | * @param string the name of the checkbox that should be (un)checked |
13 | */ |
14 | function row_click(chkboxName) { |
15 | chkbox = document.getElementById(chkboxName); |
16 | if (chkbox) { |
17 | // initialize orig_row_color if not defined already |
18 | if (!orig_row_colors[chkboxName]) { |
19 | orig_row_colors[chkboxName] = chkbox.parentNode.getAttribute('bgcolor'); |
20 | } |
21 | chkbox.checked = (chkbox.checked ? false : true); |
22 | } |
23 | } |
24 | /* |
25 | * This function is used to initialize the orig_row_color array so we do not |
26 | * need to predefine the entire array |
27 | */ |
28 | function rowOver(chkboxName, overColor, clickedColor) { |
29 | chkbox = document.getElementById(chkboxName); |
30 | if (chkbox) { |
31 | if (!orig_row_colors[chkboxName]) { |
32 | bgColor = chkbox.parentNode.getAttribute('bgcolor'); |
33 | orig_row_colors[chkboxName] = bgColor; |
34 | } else { |
35 | bgColor = orig_row_colors[chkboxName]; |
36 | } |
37 | j = chkbox.name.length - 1 |
38 | setPointer(chkbox.parentNode.parentNode, j,'over' , bgColor, overColor, clickedColor); |
39 | } |
40 | } |
41 | |
42 | /* |
43 | * (un)Checks all checkboxes for the message list from a specific form |
44 | * when it gets clicked. |
45 | * |
46 | * @param string the id of the form where all checkboxes should be (un)checked |
47 | * @param boolean use fancy row coloring when a checkbox is checked |
48 | * @param string new color of the checked rows |
49 | */ |
50 | function toggle_all(formname, fancy, clickedColor) { |
51 | TargetForm = document.getElementById(formname); |
52 | j = 0; |
53 | for (var i = 0; i < TargetForm.elements.length; i++) { |
54 | if (TargetForm.elements[i].type == 'checkbox' && TargetForm.elements[i].name.substring(0,3) == 'msg') { |
55 | if (fancy) { |
56 | array_key = TargetForm.elements[i].getAttribute('id'); |
57 | if (TargetForm.elements[i].checked == false) { |
58 | // initialize orig_row_color if not defined already |
59 | if (!orig_row_colors[array_key]) { |
60 | orig_row_colors[array_key] = TargetForm.elements[i].parentNode.getAttribute('bgcolor'); |
61 | } |
62 | } |
63 | origColor = orig_row_colors[array_key]; |
64 | setPointer(TargetForm.elements[i].parentNode.parentNode, j,'click' , origColor, origColor, clickedColor); |
65 | j++ |
66 | } |
67 | TargetForm.elements[i].checked = !(TargetForm.elements[i].checked); |
68 | } |
69 | } |
70 | } |
71 | |
72 | /* |
73 | * Sets/unsets the pointer and marker in browse mode |
74 | * |
75 | * @param object the table row |
76 | * @param integer the row number |
77 | * @param string the action calling this script (over, out or click) |
78 | * @param string the default background color |
79 | * @param string the color to use for mouseover |
80 | * @param string the color to use for marking a row |
81 | * |
82 | * @return boolean whether pointer is set or not |
83 | */ |
84 | function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) |
85 | { |
86 | var theCells = null; |
87 | |
88 | // 1. Pointer and mark feature are disabled or the browser can't get the |
89 | // row -> exits |
90 | if ((thePointerColor == '' && theMarkColor == '') |
91 | || typeof(theRow.style) == 'undefined') { |
92 | return false; |
93 | } |
94 | |
95 | // 2. Gets the current row and exits if the browser can't get it |
96 | if (typeof(document.getElementsByTagName) != 'undefined') { |
97 | theCells = theRow.getElementsByTagName('td'); |
98 | } |
99 | else if (typeof(theRow.cells) != 'undefined') { |
100 | theCells = theRow.cells; |
101 | } |
102 | else { |
103 | return false; |
104 | } |
105 | |
106 | // 3. Gets the current color... |
107 | var rowCellsCnt = theCells.length; |
108 | var domDetect = null; |
109 | var currentColor = null; |
110 | var newColor = null; |
111 | // 3.1 ... with DOM compatible browsers except Opera that does not return |
112 | // valid values with "getAttribute" |
113 | if (typeof(window.opera) == 'undefined' |
114 | && typeof(theCells[0].getAttribute) != 'undefined') { |
115 | currentColor = theCells[0].getAttribute('bgcolor'); |
116 | domDetect = true; |
117 | } |
118 | // 3.2 ... with other browsers |
119 | else { |
120 | currentColor = theCells[0].style.backgroundColor; |
121 | domDetect = false; |
122 | } // end 3 |
123 | |
124 | // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it |
125 | if (currentColor.indexOf("rgb") >= 0) |
126 | { |
127 | var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1, |
128 | currentColor.indexOf(')')); |
129 | var rgbValues = rgbStr.split(","); |
130 | currentColor = "#"; |
131 | var hexChars = "0123456789ABCDEF"; |
132 | for (var i = 0; i < 3; i++) |
133 | { |
134 | var v = rgbValues[i].valueOf(); |
135 | currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16); |
136 | } |
137 | } |
138 | |
139 | // 4. Defines the new color |
140 | // 4.1 Current color is the default one |
141 | if (currentColor == '' |
142 | || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) { |
143 | if (theAction == 'over' && thePointerColor != '') { |
144 | newColor = thePointerColor; |
145 | } |
146 | else if (theAction == 'click' && theMarkColor != '') { |
147 | newColor = theMarkColor; |
148 | marked_row[theRowNum] = true; |
149 | // deactivated onclick marking of the checkbox because it's also executed |
150 | // when an action (clicking on the checkbox itself) on a single item is |
151 | // performed. Then the checkbox would get deactived, even though we need |
152 | // it activated. Maybe there is a way to detect if the row was clicked, |
153 | // and not an item therein... |
154 | //document.getElementById('msg[' + theRowNum + ']').checked = true; |
155 | } |
156 | } |
157 | // 4.1.2 Current color is the pointer one |
158 | else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() |
159 | && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) { |
160 | if (theAction == 'out') { |
161 | newColor = theDefaultColor; |
162 | } |
163 | else if (theAction == 'click' && theMarkColor != '') { |
164 | newColor = theMarkColor; |
165 | marked_row[theRowNum] = true; |
166 | //document.getElementById('msg[' + theRowNum + ']').checked = true; |
167 | } |
168 | } |
169 | // 4.1.3 Current color is the marker one |
170 | else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) { |
171 | if (theAction == 'click') { |
172 | newColor = (thePointerColor != '') |
173 | ? thePointerColor |
174 | : theDefaultColor; |
175 | marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) |
176 | ? true |
177 | : null; |
178 | //document.getElementById('msg[' + theRowNum + ']').checked = false; |
179 | } |
180 | } // end 4 |
181 | |
182 | // 5. Sets the new color... |
183 | if (newColor) { |
184 | var c = null; |
185 | // 5.1 ... with DOM compatible browsers except Opera |
186 | if (domDetect) { |
187 | for (c = 0; c < rowCellsCnt; c++) { |
188 | theCells[c].setAttribute('bgcolor', newColor, 0); |
189 | } // end for |
190 | } |
191 | // 5.2 ... with other browsers |
192 | else { |
193 | for (c = 0; c < rowCellsCnt; c++) { |
194 | theCells[c].style.backgroundColor = newColor; |
195 | } |
196 | } |
197 | } // end 5 |
198 | |
199 | return true; |
200 | } // end of the 'setPointer()' function |
201 | |
202 | function comp_in_new_form(comp_uri, button, myform, iWidth, iHeight) { |
203 | comp_uri += "&" + button.name + "=1"; |
204 | for ( var i=0; i < myform.elements.length; i++ ) { |
205 | if ( myform.elements[i].type == "checkbox" && myform.elements[i].checked ) |
206 | comp_uri += "&" + myform.elements[i].name + "=1"; |
207 | } |
208 | if (!iWidth) iWidth = 640; |
209 | if (!iHeight) iHeight = 550; |
210 | sArg = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes,resizable=yes,status=yes"; |
211 | var newwin = window.open(comp_uri, "_blank", sArg); |
212 | } |
213 | |
214 | function comp_in_new(comp_uri, iWidth, iHeight) { |
215 | if (!iWidth) iWidth = 640; |
216 | if (!iHeight) iHeight = 550; |
217 | sArg = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes,resizable=yes,status=yes"; |
218 | var newwin = window.open(comp_uri , "_blank", sArg); |
219 | } |
220 | |
221 | /* |
222 | * Reload the read_body screen on sending an mdn receipt |
223 | */ |
224 | function sendMDN() { |
225 | mdnuri=window.location+'&sendreceipt=1'; |
226 | var newwin = window.open(mdnuri,'right'); |
227 | } |
228 | |
87745b9c |
229 | var alreadyFocused = false; |
49db257d |
230 | function checkForm(smaction) { |
87745b9c |
231 | |
232 | if (alreadyFocused) return; |
233 | |
49db257d |
234 | /* |
235 | * this part is used for setting the focus in the compose screen |
236 | */ |
237 | if (smaction) { |
238 | if (smaction == "select") { |
239 | document.forms['compose'].body.select(); |
240 | } else if (smaction == "focus") { |
241 | document.forms['compose'].body.focus(); |
242 | } |
243 | } else { |
244 | /* |
245 | * All other forms that need to set the focus |
246 | */ |
247 | var f = document.forms.length; |
248 | var i = 0; |
249 | var pos = -1; |
250 | while( pos == -1 && i < f ) { |
251 | var e = document.forms[i].elements.length; |
252 | var j = 0; |
253 | while( pos == -1 && j < e ) { |
254 | if ( document.forms[i].elements[j].type == 'text' || document.forms[i].elements[j].type == 'password' ) { |
255 | pos = j; |
256 | } |
257 | j++; |
258 | } |
259 | i++; |
260 | } |
261 | if( pos >= 0 ) { |
262 | document.forms[i-1].elements[pos].focus(); |
263 | } |
264 | } |
265 | } |