PageSourceSearch

https://book.allianceairlines.com.au/B2C/Scripts/mvcfoolproof.unobtrusive.js

js allianceairlines.com.au collected 2026-10-02 10:58:54 UTC 7,474 bytes, 183 lines download raw bytes

1var foolproof = function () { };
2foolproof.is = function (value1, operator, value2, passOnNull) {
3    if (passOnNull) {
4        var isNullish = function (input) {
5            return input == null || input == undefined || input == "";
6        };
7
8        var value1nullish = isNullish(value1);
9        var value2nullish = isNullish(value2);
10
11        if ((value1nullish && !value2nullish) || (value2nullish && !value1nullish))
12            return true;
13    }
14    
15    var isNumeric = function (input) {
16        return (input - 0) == input && input.length > 0;
17    };
18
19    var isDate = function (input) {
20        var dateTest = new RegExp(/(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/);
21
22        return dateTest.test(input);
23    };
24
25    var isBool = function (input) {
26        return input === true || input === false || input === "true" || input === "false";
27    };
28
29    if (isDate(value1)) {
30        value1 = Date.parse(value1);
31        value2 = Date.parse(value2);
32    }
33    else if (isBool(value1)) {
34        if (value1 == "false") value1 = false;
35        if (value2 == "false") value2 = false;
36        value1 = !!value1;
37        value2 = !!value2;
38    }
39    else if (isNumeric(value1)) {
40        value1 = parseFloat(value1);
41        value2 = parseFloat(value2);
42    }
43
44    switch (operator) {
45        case "EqualTo": if (value1 == value2) return true; break;
46        case "NotEqualTo": if (value1 != value2) return true; break;
47        case "GreaterThan": if (value1 > value2) return true; break;
48        case "LessThan": if (value1 < value2) return true; break;
49        case "GreaterThanOrEqualTo": if (value1 >= value2) return true; break;
50        case "LessThanOrEqualTo": if (value1 <= value2) return true; break;
51        case "RegExMatch": return (new RegExp(value2)).test(value1); break;
52        case "NotRegExMatch": return !(new RegExp(value2)).test(value1); break;
53    }
54
55    return false;
56};
57
58foolproof.getId = function (element, dependentPropety) {
59    var pos = element.id.lastIndexOf("_") + 1;
60    return element.id.substr(0, pos) + dependentPropety.replace(/\./g, "_");
61};
62
63foolproof.getName = function (element, dependentPropety) {
64    var pos = element.name.lastIndexOf(".") + 1;
65    return element.name.substr(0, pos) + dependentPropety;
66};
67
68(function () {
69    jQuery.validator.addMethod("is", function (value, element, params) {
70        var dependentProperty = foolproof.getId(element, params["dependentproperty"]);
71        var operator = params["operator"];
72        var passOnNull = params["passonnull"];
73        var dependentValue = document.getElementById(dependentProperty).value;
74
75        if (foolproof.is(value, operator, dependentValue, passOnNull))
76            return true;
77
78        return false;
79    });
80
81    jQuery.validator.addMethod("requiredif", function (value, element, params) {
82        var dependentProperty = foolproof.getName(element, params["dependentproperty"]);
83        var dependentTestValue = params["dependentvalue"];
84        var operator = params["operator"];
85        var pattern = params["pattern"];
86        var dependentPropertyElement = document.getElementsByName(dependentProperty);
87        var dependentValue = null;
88
89        if (dependentPropertyElement.length > 1) {
90            for (var index = 0; index != dependentPropertyElement.length; index++)
91                if (dependentPropertyElement[index]["checked"]) {
92                    dependentValue = dependentPropertyElement[index].value;
93                    break;
94                }
95
96            if (dependentValue == null)
97                dependentValue = false
98        }
99        else
100            dependentValue = dependentPropertyElement[0].value;
101
102        if (foolproof.is(dependentValue, operator, dependentTestValue)) {
103            if (pattern == null) {
104                if (value != null && value.toString().replace(/^\s\s*/, '').replace(/\s\s*$/, '') != "")
105                    return true;
106            }
107            else
108                return (new RegExp(pattern)).test(value);
109        }
110        else
111            return true;
112
113        return false;
114    });
115
116    jQuery.validator.addMethod("requiredifempty", function (value, element, params) {
117        var dependentProperty = foolproof.getId(element, params["dependentproperty"]);
118        var dependentValue = document.getElementById(dependentProperty).value;
119
120        if (dependentValue == null || dependentValue.toString().replace(/^\s\s*/, '').replace(/\s\s*$/, '') == "") {
121            if (value != null && value.toString().replace(/^\s\s*/, '').replace(/\s\s*$/, '') != "")
122                return true;
123        }
124        else
125            return true;
126
127        return false;
128    });
129
130    jQuery.validator.addMethod("requiredifnotempty", function (value, element, params) {
131        var dependentProperty = foolproof.getId(element, params["dependentproperty"]);
132        var dependentValue = document.getElementById(dependentProperty).value;
133
134        if (dependentValue != null && dependentValue.toString().replace(/^\s\s*/, '').replace(/\s\s*$/, '') != "") {
135            if (value != null && value.toString().replace(/^\s\s*/, '').replace(/\s\s*$/, '') != "")
136                return true;
137        }
138        else
139            return true;
140
141        return false;
142    });
143
144    var setValidationValues = function (options, ruleName, value) {
145        options.rules[ruleName] = value;
146        if (options.message) {
147            options.messages[ruleName] = options.message;
148        }
149    };
150
151    var $Unob = $.validator.unobtrusive;
152
153    $Unob.adapters.add("requiredif", ["dependentproperty", "dependentvalue", "operator", "pattern"], function (options) {
154        var value = {
155            dependentproperty: options.params.dependentproperty,
156            dependentvalue: options.params.dependentvalue,
157            operator: options.params.operator,
158            pattern: options.params.pattern
159        };
160        setValidationValues(options, "requiredif", value);
161    });
162
163    $Unob.adapters.add("is", ["dependentproperty", "operator", "passonnull"], function (options) {
164        setValidationValues(options, "is", {
165            dependentproperty: options.params.dependentproperty,
166            operator: options.params.operator,
167            passonnull: options.params.passonnull
168        });
169    });
170
171    $Unob.adapters.add("requiredifempty", ["dependentproperty"], function (options) {
172        setValidationValues(options, "requiredifempty", {
173            dependentproperty: options.params.dependentproperty
174        });
175    });
176
177    $Unob.adapters.add("requiredifnotempty", ["dependentproperty"], function (options) {
178        setValidationValues(options, "requiredifnotempty", {
179            dependentproperty: options.params.dependentproperty
180        });
181    });
182})();
183

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.