PageSourceSearch

https://www.matatransit.com/cms/includes/js/modules/base.js?Guid=C…4OVfgrC55aTA4nxwzM93t8RxnqROzo%2F91WlWB7lVd

js matatransit.com collected 2026-09-24 09:55:59 UTC 18,237 bytes, 540 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
333    BaseModule.filterPhoneChars = function (e) {
334        var charCode = e.which || e.keyCode;
335        // dash
336        if (charCode == 45)
337            return true;
338        // numbers
339        if (charCode > 31 && (charCode < 47 || charCode > 57))
340            return false;
341        if (e.shiftKey)
342            return false;
343        return true;
344    }
345
346    //START COOKIE UTILITIES
347    BaseModule.createCookie = function (name, value, days) {
348        var cookie_string = name + "=" + escape(value);
349
350        if (days) {
351            var date = new Date();
352            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
353            cookie_string += "; expires=" + date.toGMTString();
354        }
355
356        document.cookie = cookie_string + "; path=/"
357    }
358
359    BaseModule.readCookie = function (name) {
360        var nameEQ = name + "=";
361        var ca = document.cookie.split(';');
362        for (var i = 0; i < ca.length; i++) {
363            var c = ca[i];
364            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
365            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
366        }
367        return null;
368    }
369
370    BaseModule.eraseCookie = function (name) {
371        this.createCookie(name, "", -1);
372    }
373
374    BaseModule.getCookie = function (NameOfCookie) {
375        if (document.cookie.length > 0) {
376            begin = document.cookie.indexOf(NameOfCookie + "=");
377            if (begin != -1) {
378                begin += NameOfCookie.length + 1;
379                end = document.cookie.indexOf(";", begin);
380                if (end == -1) end = document.cookie.length;
381                return unescape(document.cookie.substring(begin, end));
382            }
383        }
384        return null;
385    }
386
387    // Ensure that cookie does not exceed 4kb.
388    BaseModule.TrimCookieSize = function (valueArray) {
389        //Take off the first two values in the list to reduce size.
390        var slicedArray = valueArray.slice(1);
391        var newValues = "";
392        for (i = 0; i < slicedArray.length; i++) {
393            newValues += slicedArray[i]
394        }
395        return newValues;
396    }
397
398    //END COOKIE UTILITIES
399
400    BaseModule.getElementsByClassName = function(oElm, strTagName, strClassName) {
401        var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
402        var arrReturnElements = new Array();
403        strClassName = strClassName.replace(/\-/g, "\\-");
404        var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
405        var oElement;
406        for (var i = 0; i < arrElements.length; i++) {
407            oElement = arrElements[i];
408            if (oRegExp.test(oElement.className)) {
409                arrReturnElements.push(oElement);
410            }
411        }
412        return (arrReturnElements)
413    }
414
415    //loading spinner
416    BaseModule.addLoadingIndicator = function () {
417        var width = window.innerWidth;
418        var height = window.innerHeight;
419
420        var $spinner = $('#ajax_loading_spinner');
421
422        if ($spinner.length === 0) {
423            $spinner = $('<div id="ajax_loading_spinner" class="spinner" role="status"><span class="visually-hidden">Loading</span><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>');
424
425            var main = $('#main-content');
426
427            if (main.length > 0) {
428                main.prepend($spinner);
429            } else {
430                $('body').prepend($spinner);
431            }
432        }
433
434        $spinner.css("top", height / 2 - 50);
435        $spinner.css("left", width / 2 - 50);
436        $spinner.show();
437    }
438
439    BaseModule.removeLoadingIndicator = function () {
440        var $spinner = $('#ajax_loading_spinner');
441
442        if ($spinner.length !== 0) {
443            $spinner.hide();
444        }
445    }
446
447}(window.BaseModule = window.BaseModule || {}, jQuery));
448
449function UpdatePanelPartialPostback(sender, args) {
450    if (args.get_isPartialLoad())
451        BaseModule.rebindModules();
452}
453
454var globalSiteSubDirectory = '';
455
456BaseModule.getGlobalSiteSubDirectory = function () {
457    if ($('#hdnSubDirectory').size() > 0)
458        return $('#hdnSubDirectory').val();
459    else
460        return '';
461}
462
463jQuery(function () {
464    if (typeof Sys != 'undefined') Sys.Application.add_load(UpdatePanelPartialPostback);
465
466    globalSiteSubDirectory = BaseModule.getGlobalSiteSubDirectory();
467});
468
469// EP - Added because IE8 doesn't have map()...
470// Production steps of ECMA-262, Edition 5, 15.4.4.19
471// Reference: http://es5.github.com/#x15.4.4.19
472if (!Array.prototype.map) {
473    Array.prototype.map = function (callback, thisArg) {
474
475        var T, A, k;
476
477        if (this == null) {
478            throw new TypeError(" this is null or not defined");
479        }
480
481        // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
482        var O = Object(this);
483
484        // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
485        // 3. Let len be ToUint32(lenValue).
486        var len = O.length >>> 0;
487
488        // 4. If IsCallable(callback) is false, throw a TypeError exception.
489        // See: http://es5.github.com/#x9.11
490        if (typeof callback !== "function") {
491            throw new TypeError(callback + " is not a function");
492        }
493
494        // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
495        if (thisArg) {
496            T = thisArg;
497        }
498
499        // 6. Let A be a new array created as if by the expression new Array(len) where Array is
500        // the standard built-in constructor with that name and len is the value of len.
501        A = new Array(len);
502
503        // 7. Let k be 0
504        k = 0;
505
506        // 8. Repeat, while k < len
507        while (k < len) {
508
509            var kValue, mappedValue;
510
511            // a. Let Pk be ToString(k).
512            //   This is implicit for LHS operands of the in operator
513            // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
514            //   This step can be combined with c
515            // c. If kPresent is true, then
516            if (k in O) {
517
518                // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
519                kValue = O[k];
520
521                // ii. Let mappedValue be the result of calling the Call internal method of callback
522                // with T as the this value and argument list containing kValue, k, and O.
523                mappedValue = callback.call(T, kValue, k, O);
524
525                // iii. Call the DefineOwnProperty internal method of A with arguments
526                // Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true},
527                // and false.
528
529                // In browsers that support Object.defineProperty, use the following:
530                // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true });
531
532                // For best browser support, use the following:
533                A[k] = mappedValue;
534            }
535            // d. Increase k by 1.
536            k++;
537        }
538        return A;
539    };
540}

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.