PageSourceSearch

https://www.csb.gov/cms/includes/js/modules/base.js?Guid=ub8LV%2FV…0c2fMfolKPeQJwVXbf44V5zxZmZyBAnaBkxTLeWpkui

js csb.gov collected 2026-10-02 02:20:22 UTC 16,852 bytes, 494 lines download raw bytes

1//EP - Currently only used for reinitialization of modules during ajax loading or update panel partial postbacks.
2(function (BaseModule, $, undefined) {
3    var modulesToRebind = {};
4
5    var rebindAllModules = function (rebindFunctions) {
6        for (var bindFunc in rebindFunctions) {
7            var callFunc = rebindFunctions[bindFunc];
8            if (typeof callFunc === "function")
9                callFunc();
10        }
11    };
12
13    BaseModule.addModuleRebindFunction = function (key, rebindFunction) {
14        modulesToRebind[key] = rebindFunction;
15    }
16
17    BaseModule.rebindModules = function () {
18        rebindAllModules(modulesToRebind);
19    }
20
21    BaseModule.getQueryVariable = function (variable) {
22        var query = window.location.search.substring(1);
23        var vars = query.split("&");
24        for (var i = 0; i < vars.length; i++) {
25            var pair = vars[i].split("=");
26            if (pair[0].toLowerCase() == variable.toLowerCase()) {
27                return pair[1];
28            }
29        }
30    };
31
32    //EP - Quick jQuery UI Extension for Tabs
33    $.fn.tabIndex = function () {
34        return $(this).parent().find(this).index() - 1;
35    };
36    $.fn.selectTabByID = function (tabID) {
37        $(this).tabs("option", "active", $('#' + tabID).tabIndex() - 1);
38    };
39    $.fn.selectTabByIndex = function (tabIndex) {
40        $(this).tabs("option", "active", tabIndex);
41    };
42
43    //EP - Start core functions (from functionsC.js)
44
45    BaseModule.NewWindow = function (sURL, sWindowName, iWidth, iHeight, sScrollYesNo, sResizableYesNo) {
46        var fLeftPosition, fTopPosition;
47        var sSettings;
48
49        fLeftPosition = (screen.width) ? (screen.width - iWidth) / 2 : 0;
50        fTopPosition = (screen.height) ? (screen.height - iHeight) / 2 : 0;
51
52        sSettings =
53        'height=' + iHeight + ',width=' + iWidth + ',top=' + fTopPosition + ',left=' + fLeftPosition + ',scrollbars=' + sScrollYesNo + ',resizable=' + sResizableYesNo
54
55        window.open(sURL, sWindowName, sSettings)
56    }
57
58    BaseModule.isEmpty = function (s) {
59        if (s == null || this.trim(s) == '') {
60            return true;
61        }
62        else {
63            return false;
64        }
65    }
66
67    BaseModule.isNotEmptyDate = function (val) {
68        return !this.isEmptyDate(val);
69    }
70
71    BaseModule.isNotEmptyTime = function (val) {
72        return !this.isEmptyTime(val);
73    }
74
75    BaseModule.isEmptyDate = function (val) {
76        var ctrl = document.getElementById(val.controltovalidate + '_txtDatePicker');
77        return this.isEmptyField(ctrl);
78    }
79
80    BaseModule.isEmptyTime = function (val) {
81        var ctrl_h = document.getElementById(val.controltovalidate + '_H');
82        var ctrl_m = document.getElementById(val.controltovalidate + '_M');
83        var ctrl_ampm = document.getElementById(val.controltovalidate + '_AMPM');
84
85        if (ctrl_h.selectedIndex == 0) return true;
86        if (ctrl_m.selectedIndex == 0) return true;
87        if (ctrl_ampm.selectedIndex == 0) return true;
88
89        return false;
90    }
91
92    BaseModule.isDate = function (Field) {
93        if (this.isEmptyField(Field)) return true;
94
95        var dtArray = Field.value.split('/');
96        if (dtArray.length != 3) return false;
97        return CheckDate(dtArray[0], dtArray[1], dtArray[2]);
98    }
99
100    BaseModule.isValidDate = function (val) {
101        var ctrl = document.getElementById(val.controltovalidate + '_txtDatePicker');
102        return BaseModule.isDate(ctrl);
103    }
104
105    BaseModule.CheckDate = function (m, d, y) {
106        Months = "31/!/28/!/31/!/30/!/31/!/30/!/31/!/31/!/30/!/31/!/30/!/31";
107        MonthArray = Months.split("/!/");
108
109        if (isNaN(parseInt(m, 10))) return false;
110        if (isNaN(parseInt(d, 10))) return false;
111        if (isNaN(parseInt(y, 10))) return false;
112
113        if (d != parseInt(d, 10)) return false;
114        if (m != parseInt(m, 10)) return false;
115        if (y != parseInt(y, 10)) return false;
116
117        d = parseInt(d, 10);
118        m = parseInt(m, 10);
119        y = parseInt(y, 10);
120
121        y = convertYear(y);
122
123        if (y <= 1900) return false;
124        if (y >= 2100) return false;
125        if (m < 1 || m > 12) return false;
126        if (isLeapYear(y)) MonthArray[1] = eval(eval(MonthArray[1]) + 1);
127
128        if (d < 1 || MonthArray[m - 1] < d) return false;
129        return true;
130    }
131
132    BaseModule.isValidTime = function (val) {
133        var ctrl_h = document.getElementById(val.controltovalidate + '_H');
134        var ctrl_m = document.getElementById(val.controltovalidate + '_M');
135        var ctrl_ampm = document.getElementById(val.controltovalidate + '_AMPM');
136
137        if (ctrl_h.selectedIndex == 0 && ctrl_m.selectedIndex == 0 && ctrl_ampm.selectedIndex == 0) return true;
138        if (ctrl_h.selectedIndex == 0) return false;
139        if (ctrl_m.selectedIndex == 0) return false;
140        if (ctrl_ampm.selectedIndex == 0) return false;
141
142        return true;
143    }
144
145    BaseModule.isNotEmptyCK = function (val) {
146        var ctrl = document.getElementById(val.controltovalidate);
147        return !this.isEmptyCK(ctrl);
148    }
149
150    BaseModule.isLeapYear = function (Year) {
151        if (Math.round(Year / 4) == Year / 4) {
152            if (Math.round(Year / 100) == Year / 100) {
153                if (Math.round(Year / 400) == Year / 400)
154                    return true;
155                else return false;
156            } else return true;
157        }
158        return false;
159    }
160
161    BaseModule.getValue = function (Field) {
162        fieldType = Field.type;
163
164        if (fieldType == "text") {
165            return this.getTextValue(Field);
166        } else if (fieldType == "hidden") {
167            return this.getTextValue(Field);
168        } else if (fieldType == "select-one") {
169            return this.getListValue(Field);
170        } else if (fieldType == "textarea") {
171            return this.getTextValue(Field);
172        } else if (fieldType == "file") {
173            return this.getTextValue(Field);
174        } else if (fieldType == "password") {
175            return this.getTextValue(Field);
176        } else if (fieldType == "checkbox") {
177            return this.getCheckboxValue(Field);
178        } else if (isNaN(fieldType)) {
179            return this.getRadioValue(Field);
180        } else {
181            return this.getTextValue(Field);
182        }
183    }
184
185    BaseModule.getListValue = function (Field) {
186        return Field[Field.selectedIndex].value;
187    }
188
189    BaseModule.getTextValue = function (Field) {
190        return Field.value;
191    }
192
193    BaseModule.getCheckboxValue = function (Field) {
194
195        if (Field.checked) return Field.value;
196        return '';
197    }
198
199    BaseModule.getRadioValue = function (Field) {
200        found = false;
201
202        if (isNaN(Field.length)) {
203            return Field.value;
204        }
205
206        for (var i = 0; i < Field.length; i++) {
207            if (Field[i].checked) {
208                return Field[i].value;
209                break;
210            }
211        }
212        return !found;
213    }
214
215    BaseModule.trim = function (str) {
216        while (str.substring(0, 1) == " ") {
217            str = str.substring(1, str.length);
218        }
219        while (str.substring(str.length - 1, str.length) == " ") {
220            str = str.substring(0, str.length - 1);
221        }
222        return str;
223    }
224
225    BaseModule.isEmptyList = function (Field) {
226        return this.isEmpty(Field[Field.selectedIndex].value);
227    }
228
229    BaseModule.isEmptyText = function (Field) {
230        return this.isEmpty(Field.value)
231    }
232
233    BaseModule.isEmptyCheckbox = function (Field) {
234        return !Field.checked;
235    }
236
237    BaseModule.isEmptyField = function (Field) {
238        fieldType = Field.type;
239
240        if (fieldType == "text") {
241            return this.isEmptyText(Field);
242        } else if (fieldType == "hidden") {
243            return this.isEmptyText(Field);
244        } else if (fieldType == "file") {
245            return this.isEmptyText(Field);
246        } else if (fieldType == "select-one") {
247            return this.isEmptyList(Field);
248        } else if (fieldType == "textarea") {
249            return this.isEmptyText(Field);
250        } else if (fieldType == "password") {
251            return this.isEmptyText(Field);
252        } else if (fieldType == "checkbox") {
253            return this.isEmptyCheckbox(Field)
254        } else if (isNaN(fieldType)) {
255            return this.isEmptyRadio(Field)
256        } else {
257            return this.isEmptyText(Field);
258        }
259    }
260
261    BaseModule.isDefined = function (obj) {
262        return (typeof (obj) !== "undefined");
263    }
264
265    BaseModule.isEmptyRadio = function (Field) {
266        found = false;
267
268        if (isNaN(Field.length)) {
269            return !Field.checked;
270        }
271
272        for (var i = 0; i < Field.length; i++) {
273            if (Field[i].checked) {
274                found = true;
275                break;
276            }
277        }
278        return !found;
279    }
280
281    BaseModule.isNotEmptyFile = function (val) {
282        return !this.isEmptyFile(val);
283    }
284
285    BaseModule.isEmptyFile = function (val) {
286        var oid, fid, cid, bDelChecked = false;
287
288        oid = document.getElementById(val.controltovalidate + '_OLD');
289        fid = document.getElementById(val.controltovalidate + '_FILE');
290        cid = document.getElementById(val.controltovalidate + '_CHK');
291
292        if (cid != null) { bDelChecked = cid.checked; }
293
294        return (this.isEmptyField(oid) && this.isEmptyField(fid) || this.isEmptyField(fid) && bDelChecked);
295    }
296
297    BaseModule.isNotEmptyCheckBoxList = function (val) {
298        var parent = document.getElementById(val.controltovalidate);
299        var checkboxes = parent.getElementsByTagName('INPUT');
300        var checked = false;
301        for (var i = 0; i < checkboxes.length; i++) {
302            if (checkboxes[i].checked) return true;
303        }
304        return false;
305    }
306
307    BaseModule.isValidFile = function (val) {
308        if (this.isEmptyFile(val)) return true;
309
310        var fid = document.getElementById(val.controltovalidate + '_FILE');
311        if (this.isEmptyField(fid)) return true;
312
313        var filename = getValue(fid);
314        var lastDot = filename.lastIndexOf(".")
315
316        if (lastDot == -1) return false;
317
318        var ext = filename.substring(lastDot + 1, filename.length);
319        filename = filename.substring(0, lastDot);
320
321        if (filename == '') return false;
322
323        var aExtensions = val.extensions.split(",");
324
325        for (i = 0; i < aExtensions.length; i++) {
326            if (aExtensions[i] == ext.toLowerCase()) return true;
327        }
328
329        return false;
330    }
331
332    //START COOKIE UTILITIES
333    BaseModule.createCookie = function (name, value, days) {
334        var cookie_string = name + "=" + escape(value);
335
336        if (days) {
337            var date = new Date();
338            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
339            cookie_string += "; expires=" + date.toGMTString();
340        }
341
342        document.cookie = cookie_string + "; path=/"
343    }
344
345    BaseModule.readCookie = function (name) {
346        var nameEQ = name + "=";
347        var ca = document.cookie.split(';');
348        for (var i = 0; i < ca.length; i++) {
349            var c = ca[i];
350            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
351            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
352        }
353        return null;
354    }
355
356    BaseModule.eraseCookie = function (name) {
357        this.createCookie(name, "", -1);
358    }
359
360    BaseModule.getCookie = function (NameOfCookie) {
361        if (document.cookie.length > 0) {
362            begin = document.cookie.indexOf(NameOfCookie + "=");
363            if (begin != -1) {
364                begin += NameOfCookie.length + 1;
365                end = document.cookie.indexOf(";", begin);
366                if (end == -1) end = document.cookie.length;
367                return unescape(document.cookie.substring(begin, end));
368            }
369        }
370        return null;
371    }
372
373    // Ensure that cookie does not exceed 4kb.
374    BaseModule.TrimCookieSize = function (valueArray) {
375        //Take off the first two values in the list to reduce size.
376        var slicedArray = valueArray.slice(1);
377        var newValues = "";
378        for (i = 0; i < slicedArray.length; i++) {
379            newValues += slicedArray[i]
380        }
381        return newValues;
382    }
383
384    //END COOKIE UTILITIES
385
386    BaseModule.getElementsByClassName = function(oElm, strTagName, strClassName) {
387        var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
388        var arrReturnElements = new Array();
389        strClassName = strClassName.replace(/\-/g, "\\-");
390        var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
391        var oElement;
392        for (var i = 0; i < arrElements.length; i++) {
393            oElement = arrElements[i];
394            if (oRegExp.test(oElement.className)) {
395                arrReturnElements.push(oElement);
396            }
397        }
398        return (arrReturnElements)
399    }
400
401}(window.BaseModule = window.BaseModule || {}, jQuery));
402
403function UpdatePanelPartialPostback(sender, args) {
404    if (args.get_isPartialLoad())
405        BaseModule.rebindModules();
406}
407
408var globalSiteSubDirectory = '';
409
410BaseModule.getGlobalSiteSubDirectory = function () {
411    if ($('#hdnSubDirectory').size() > 0)
412        return $('#hdnSubDirectory').val();
413    else
414        return '';
415}
416
417jQuery(function () {
418    if (typeof Sys != 'undefined') Sys.Application.add_load(UpdatePanelPartialPostback);
419
420    globalSiteSubDirectory = BaseModule.getGlobalSiteSubDirectory();
421});
422
423// EP - Added because IE8 doesn't have map()...
424// Production steps of ECMA-262, Edition 5, 15.4.4.19
425// Reference: http://es5.github.com/#x15.4.4.19
426if (!Array.prototype.map) {
427    Array.prototype.map = function (callback, thisArg) {
428
429        var T, A, k;
430
431        if (this == null) {
432            throw new TypeError(" this is null or not defined");
433        }
434
435        // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
436        var O = Object(this);
437
438        // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
439        // 3. Let len be ToUint32(lenValue).
440        var len = O.length >>> 0;
441
442        // 4. If IsCallable(callback) is false, throw a TypeError exception.
443        // See: http://es5.github.com/#x9.11
444        if (typeof callback !== "function") {
445            throw new TypeError(callback + " is not a function");
446        }
447
448        // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
449        if (thisArg) {
450            T = thisArg;
451        }
452
453        // 6. Let A be a new array created as if by the expression new Array(len) where Array is
454        // the standard built-in constructor with that name and len is the value of len.
455        A = new Array(len);
456
457        // 7. Let k be 0
458        k = 0;
459
460        // 8. Repeat, while k < len
461        while (k < len) {
462
463            var kValue, mappedValue;
464
465            // a. Let Pk be ToString(k).
466            //   This is implicit for LHS operands of the in operator
467            // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
468            //   This step can be combined with c
469            // c. If kPresent is true, then
470            if (k in O) {
471
472                // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
473                kValue = O[k];
474
475                // ii. Let mappedValue be the result of calling the Call internal method of callback
476                // with T as the this value and argument list containing kValue, k, and O.
477                mappedValue = callback.call(T, kValue, k, O);
478
479                // iii. Call the DefineOwnProperty internal method of A with arguments
480                // Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
481                // and false.
482
483                // In browsers that support Object.defineProperty, use the following:
484                // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
485
486                // For best browser support, use the following:
487                A[k] = mappedValue;
488            }
489            // d. Increase k by 1.
490            k++;
491        }
492        return A;
493    };
494}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.