1 | /**
|
---|
2 |
|
---|
3 | * This JavaScript file contains functions that are needed for login.
|
---|
4 |
|
---|
5 | * @author Infrastructure & Security Service
|
---|
6 |
|
---|
7 | * @version 1.0.1.002
|
---|
8 |
|
---|
9 | */
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 | function preserveRadioGroup (evt) {
|
---|
14 |
|
---|
15 | this.checked = this.storedChecked;
|
---|
16 |
|
---|
17 | var rgb = this.form[this.name];
|
---|
18 |
|
---|
19 | if (!rgb.length && rgb.storedChecked)
|
---|
20 |
|
---|
21 | rgb.checked = true;
|
---|
22 |
|
---|
23 | else
|
---|
24 |
|
---|
25 | for (var b = 0; b < rgb.length; b++)
|
---|
26 |
|
---|
27 | rgb[b].checked = rgb[b].storedChecked ? true : false;
|
---|
28 |
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 | function disableRadioGroup (radioGroup) {
|
---|
34 |
|
---|
35 | if (!radioGroup.disabled) {
|
---|
36 |
|
---|
37 | radioGroup.disabled = true;
|
---|
38 |
|
---|
39 | if (document.all || document.getElementById) {
|
---|
40 |
|
---|
41 | if (!radioGroup.length)
|
---|
42 |
|
---|
43 | radioGroup.disabled = true;
|
---|
44 |
|
---|
45 | else
|
---|
46 |
|
---|
47 | for (var b = 0; b < radioGroup.length; b++)
|
---|
48 |
|
---|
49 | radioGroup[b].disabled = true;
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 | else {
|
---|
54 |
|
---|
55 | if (!radioGroup.length) {
|
---|
56 |
|
---|
57 | radioGroup.storedChecked = radioGroup.checked;
|
---|
58 |
|
---|
59 | radioGroup.oldOnClick = radioGroup.onclick;
|
---|
60 |
|
---|
61 | radioGroup.onclick = preserveRadioGroup;
|
---|
62 |
|
---|
63 | }
|
---|
64 |
|
---|
65 | else
|
---|
66 |
|
---|
67 | for (var b = 0; b < radioGroup.length; b++) {
|
---|
68 |
|
---|
69 | radioGroup[b].storedChecked = radioGroup[b].checked;
|
---|
70 |
|
---|
71 | radioGroup[b].oldOnClick = radioGroup[b].onclick;
|
---|
72 |
|
---|
73 | radioGroup[b].onclick = preserveRadioGroup;
|
---|
74 |
|
---|
75 | }
|
---|
76 |
|
---|
77 | }
|
---|
78 |
|
---|
79 | }
|
---|
80 |
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | function enableRadioGroup (radioGroup) {
|
---|
86 |
|
---|
87 | if (radioGroup.disabled) {
|
---|
88 |
|
---|
89 | radioGroup.disabled = false;
|
---|
90 |
|
---|
91 | if (document.all || document.getElementById) {
|
---|
92 |
|
---|
93 | if (!radioGroup.length)
|
---|
94 |
|
---|
95 | radioGroup.disabled = false;
|
---|
96 |
|
---|
97 | else
|
---|
98 |
|
---|
99 | for (var b = 0; b < radioGroup.length; b++)
|
---|
100 |
|
---|
101 | radioGroup[b].disabled = false;
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | else {
|
---|
106 |
|
---|
107 | if (!radioGroup.length) {
|
---|
108 |
|
---|
109 | radioGroup.onclick = radioGroup.oldOnClick;
|
---|
110 |
|
---|
111 | }
|
---|
112 |
|
---|
113 | else
|
---|
114 |
|
---|
115 | for (var b = 0; b < radioGroup.length; b++) {
|
---|
116 |
|
---|
117 | radioGroup[b].onclick = radioGroup[b].oldOnClick;
|
---|
118 |
|
---|
119 | }
|
---|
120 |
|
---|
121 | }
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 | function isblank(s) {
|
---|
130 |
|
---|
131 | slen = s.length;
|
---|
132 |
|
---|
133 | for (var i = 0; i < slen; i++) {
|
---|
134 |
|
---|
135 | var c = s.charAt(i);
|
---|
136 |
|
---|
137 | if ((c != ' ') && (c != '\n') && (c != '')) return false;
|
---|
138 |
|
---|
139 | }
|
---|
140 |
|
---|
141 | return true;
|
---|
142 |
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 | function disableObj(obj) {
|
---|
148 |
|
---|
149 | obj.disabled = true;
|
---|
150 |
|
---|
151 | }
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 | function enableObj(obj) {
|
---|
156 |
|
---|
157 | obj.disabled = false;
|
---|
158 |
|
---|
159 | }
|
---|
160 |
|
---|
161 |
|
---|
162 |
|
---|
163 | function checkHF(myForm,mySelect,myRadioButtonGroup,myHiddenObj1,myHiddenObj2,myHiddenObj3) {
|
---|
164 |
|
---|
165 | disableInstitutionObj(myForm,mySelect,myRadioButtonGroup,myHiddenObj1,myHiddenObj2)
|
---|
166 |
|
---|
167 | if (myHiddenObj3.value == "number") {
|
---|
168 |
|
---|
169 | reSortSelectOptions(myForm,mySelect,"value");
|
---|
170 |
|
---|
171 | }
|
---|
172 |
|
---|
173 | else if (myHiddenObj3.value == "name") {
|
---|
174 |
|
---|
175 | reSortSelectOptions(myForm,mySelect,"text");
|
---|
176 |
|
---|
177 | }
|
---|
178 |
|
---|
179 | }
|
---|
180 |
|
---|
181 |
|
---|
182 |
|
---|
183 | function disableInstitutionObj(myForm,mySelect,myRadioButtonGroup,myHiddenObj1,myHiddenObj2) {
|
---|
184 |
|
---|
185 | if (myHiddenObj1.value == "true") disableObj(mySelect);
|
---|
186 |
|
---|
187 | if ((myHiddenObj1.value == "true") || (myHiddenObj2.value == "true")) {
|
---|
188 |
|
---|
189 | disableRadioGroup(myRadioButtonGroup);
|
---|
190 |
|
---|
191 | }
|
---|
192 |
|
---|
193 | }
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 | function enableInstitutionObj(myForm,mySelect,myRadioButtonGroup,myHiddenObj1,myHiddenObj2) {
|
---|
198 |
|
---|
199 | myHiddenObj1.value = "false";
|
---|
200 |
|
---|
201 | myHiddenObj2.value = "false";
|
---|
202 |
|
---|
203 | enableObj(mySelect);
|
---|
204 |
|
---|
205 | enableRadioGroup(myRadioButtonGroup);
|
---|
206 |
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 |
|
---|
211 | function hasOptions(obj) {
|
---|
212 |
|
---|
213 | if (obj!=null && obj.options!=null) { return true; }
|
---|
214 |
|
---|
215 | return false;
|
---|
216 |
|
---|
217 | }
|
---|
218 |
|
---|
219 |
|
---|
220 |
|
---|
221 | function sortSelect(obj,sortBy) {
|
---|
222 |
|
---|
223 | var o = new Array();
|
---|
224 |
|
---|
225 | if (!hasOptions(obj)) { return false; }
|
---|
226 |
|
---|
227 | for (var i=0; i<obj.options.length; i++) {
|
---|
228 |
|
---|
229 | o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
|
---|
230 |
|
---|
231 | }
|
---|
232 |
|
---|
233 | if (o.length==0) { return true; }
|
---|
234 |
|
---|
235 | if (sortBy == "text") {
|
---|
236 |
|
---|
237 | o = o.sort(
|
---|
238 |
|
---|
239 | function(a,b) {
|
---|
240 |
|
---|
241 | if ((a.text+"") < (b.text+"")) { return -1; }
|
---|
242 |
|
---|
243 | if ((a.text+"") > (b.text+"")) { return 1; }
|
---|
244 |
|
---|
245 | return 0;
|
---|
246 |
|
---|
247 | }
|
---|
248 |
|
---|
249 | );
|
---|
250 |
|
---|
251 | }
|
---|
252 |
|
---|
253 | else if (sortBy == "value") {
|
---|
254 |
|
---|
255 | o = o.sort(
|
---|
256 |
|
---|
257 | function(a,b) {
|
---|
258 |
|
---|
259 | if ((a.value+"") < (b.value+"")) { return -1; }
|
---|
260 |
|
---|
261 | if ((a.value+"") > (b.value+"")) { return 1; }
|
---|
262 |
|
---|
263 | return 0;
|
---|
264 |
|
---|
265 | }
|
---|
266 |
|
---|
267 | );
|
---|
268 |
|
---|
269 | }
|
---|
270 |
|
---|
271 | else {
|
---|
272 |
|
---|
273 | alert("\nError encountered while sorting institutions!!!");
|
---|
274 |
|
---|
275 | }
|
---|
276 |
|
---|
277 |
|
---|
278 |
|
---|
279 | for (var i=0; i<o.length; i++) {
|
---|
280 |
|
---|
281 | obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
|
---|
282 |
|
---|
283 | }
|
---|
284 |
|
---|
285 | return true;
|
---|
286 |
|
---|
287 | }
|
---|
288 |
|
---|
289 |
|
---|
290 |
|
---|
291 | function reSortSelectOptions(formRef,selectRef,sortBy) {
|
---|
292 |
|
---|
293 | if (!formRef) {
|
---|
294 |
|
---|
295 | alert("\nForm reference unknown!!!");
|
---|
296 |
|
---|
297 | }
|
---|
298 |
|
---|
299 | else if (selectRef.length <1) {
|
---|
300 |
|
---|
301 | alert("\n" + selectRef.name + " drop down component is empty!!!");
|
---|
302 |
|
---|
303 | }
|
---|
304 |
|
---|
305 | else {
|
---|
306 |
|
---|
307 | var result = sortSelect(selectRef,sortBy);
|
---|
308 |
|
---|
309 | if (!result) {
|
---|
310 |
|
---|
311 | alert("\nSorting Select Object failed!!!");
|
---|
312 |
|
---|
313 | }
|
---|
314 |
|
---|
315 | }
|
---|
316 |
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 |
|
---|
321 | function doInitialSortOnDivisions(myForm,mySelect,mySortPref,mycookie) {
|
---|
322 |
|
---|
323 | var allcookies = mycookie;
|
---|
324 |
|
---|
325 | var cookieArry = allcookies.split(";");
|
---|
326 |
|
---|
327 | for (var i=0; i < cookieArry.length; i++) {
|
---|
328 |
|
---|
329 | cookieArry[i]=cookieArry[i].split("=");
|
---|
330 |
|
---|
331 | if ((cookieArry[i][0].indexOf("gov.va.med.authentication.kernel.defaultSortDivisionBy") != -1) &&
|
---|
332 |
|
---|
333 | (cookieArry[i][1] == "name")) {
|
---|
334 |
|
---|
335 | //Now call function to sort divisions by name.
|
---|
336 |
|
---|
337 | reSortSelectOptions(myForm,mySelect,mySortPref)
|
---|
338 |
|
---|
339 | break;
|
---|
340 |
|
---|
341 | }
|
---|
342 |
|
---|
343 | }
|
---|
344 |
|
---|
345 | }
|
---|