PageSourceSearch

https://www.stopwatchtimer.net/content/_common/assets/scripts/jque…SWKigRBQvgUdr1HcfzkojMOJMYUqXh6uTgWBBhoDc5Y

js stopwatchtimer.net collected 2026-10-02 23:16:19 UTC 20,303 bytes, 444 lines download raw bytes

vendor: 20,303 bytes, lines 1-444
1/* NUGET: BEGIN LICENSE TEXT
2 *
3 * Microsoft grants you the right to use these script files for the sole
4 * purpose of either: (i) interacting through your browser with the Microsoft
5 * website or online service, subject to the applicable licensing or use
6 * terms; or (ii) using the files as included with a Microsoft product subject
7 * to that product's license terms. Microsoft reserves all other rights to the
8 * files not expressly granted by Microsoft, whether by implication, estoppel
9 * or otherwise. Insofar as a script file is dual licensed under GPL,
10 * Microsoft neither took the code under GPL nor distributes it thereunder but
11 * under the terms set out in this paragraph. All notices and licenses
12 * below are for informational purposes only.
13 *
14 * NUGET: END LICENSE TEXT */
15/*!
16** Unobtrusive validation support library for jQuery and jQuery Validate
17** Copyright (C) Microsoft Corporation. All rights reserved.
18*/
19
20/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
21/*global document: false, jQuery: false */
22
23(function ($) {
24    var $jQval = $.validator,
25        adapters,
26        data_validation = "unobtrusiveValidation";
27
28    function setValidationValues(options, ruleName, value) {
29        options.rules[ruleName] = value;
30        if (options.message) {
31            options.messages[ruleName] = options.message;
32        }
33    }
34
35    function splitAndTrim(value) {
36        return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g);
37    }
38
39    function escapeAttributeValue(value) {
40        // As mentioned on http://api.jquery.com/category/selectors/
41        return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
42    }
43
44    function getModelPrefix(fieldName) {
45        return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
46    }
47
48    function appendModelPrefix(value, prefix) {
49        if (value.indexOf("*.") === 0) {
50            value = value.replace("*.", prefix);
51        }
52        return value;
53    }
54
55    function onError(error, inputElement) {  // 'this' is the form element
56        var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"),
57            replaceAttrValue = container.attr("data-valmsg-replace"),
58            replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null;
59
60        container.removeClass("field-validation-valid").addClass("field-validation-error");
61        error.data("unobtrusiveContainer", container);
62
63        if (replace) {
64            container.empty();
65            error.removeClass("input-validation-error").appendTo(container);
66        }
67        else {
68            error.hide();
69        }
70    }
71
72    function onErrors(event, validator) {  // 'this' is the form element
73        var container = $(this).find("[data-valmsg-summary=true]"),
74            list = container.find("ul");
75
76        if (list && list.length && validator.errorList.length) {
77            list.empty();
78            container.addClass("validation-summary-errors").removeClass("validation-summary-valid");
79
80            $.each(validator.errorList, function () {
81                $("<li />").html(this.message).appendTo(list);
82            });
83        }
84    }
85
86    function onSuccess(error) {  // 'this' is the form element
87        var container = error.data("unobtrusiveContainer"),
88            replaceAttrValue = container.attr("data-valmsg-replace"),
89            replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null;
90
91        if (container) {
92            container.addClass("field-validation-valid").removeClass("field-validation-error");
93            error.removeData("unobtrusiveContainer");
94
95            if (replace) {
96                container.empty();
97            }
98        }
99    }
100
101    function onReset(event) {  // 'this' is the form element
102        var $form = $(this);
103        $form.data("validator").resetForm();
104        $form.find(".validation-summary-errors")
105            .addClass("validation-summary-valid")
106            .removeClass("validation-summary-errors");
107        $form.find(".field-validation-error")
108            .addClass("field-validation-valid")
109            .removeClass("field-validation-error")
110            .removeData("unobtrusiveContainer")
111            .find(">*")  // If we were using valmsg-replace, get the underlying error
112                .removeData("unobtrusiveContainer");
113    }
114
115    function validationInfo(form) {
116        var $form = $(form),
117            result = $form.data(data_validation),
118            onResetProxy = $.proxy(onReset, form),
119            defaultOptions = $jQval.unobtrusive.options || {},
120            execInContext = function (name, args) {
121                var func = defaultOptions[name];
122                func && $.isFunction(func) && func.apply(form, args);
123            }
124
125        if (!result) {
126            result = {
127                options: {  // options structure passed to jQuery Validate's validate() method
128                    errorClass: defaultOptions.errorClass || "input-validation-error",
129                    errorElement: defaultOptions.errorElement || "span",
130                    errorPlacement: function () {
131                        onError.apply(form, arguments);
132                        execInContext("errorPlacement", arguments);
133                    },
134                    invalidHandler: function () {
135                        onErrors.apply(form, arguments);
136                        execInContext("invalidHandler", arguments);
137                    },
138                    messages: {},
139                    rules: {},
140                    success: function () {
141                        onSuccess.apply(form, arguments);
142                        execInContext("success", arguments);
143                    },
144                    ignore:'' //ȡȫֲ飺hidden Ԫء
145                },
146                attachValidation: function () {
147                    $form
148                        .off("reset." + data_validation, onResetProxy)
149                        .on("reset." + data_validation, onResetProxy)
150                        .validate(this.options);
151                },
152                validate: function () {  // a validation function that is called by unobtrusive Ajax
153                    $form.validate();
154                    return $form.valid();
155                }
156            };
157            $form.data(data_validation, result);
158        }
159
160        return result;
161    }
162
163    $jQval.unobtrusive = {
164        adapters: [],
165
166        parseElement: function (element, skipAttach) {
167            /// <summary>
168            /// Parses a single HTML element for unobtrusive validation attributes.
169            /// </summary>
170            /// <param name="element" domElement="true">The HTML element to be parsed.</param>
171            /// <param name="skipAttach" type="Boolean">[Optional] true to skip attaching the
172            /// validation to the form. If parsing just this single element, you should specify true.
173            /// If parsing several elements, you should specify false, and manually attach the validation
174            /// to the form when you are finished. The default is false.</param>
175            var $element = $(element),
176                form = $element.parents("form")[0],
177                valInfo, rules, messages;
178
179            if (!form) {  // Cannot do client-side validation without a form
180                return;
181            }
182
183            valInfo = validationInfo(form);
184            valInfo.options.rules[element.name] = rules = {};
185            valInfo.options.messages[element.name] = messages = {};
186
187            $.each(this.adapters, function () {
188                var prefix = "data-val-" + this.name,
189                    message = $element.attr(prefix),
190                    paramValues = {};
191
192                if (message !== undefined) {  // Compare against undefined, because an empty message is legal (and falsy)
193                    prefix += "-";
194
195                    $.each(this.params, function () {
196                        paramValues[this] = $element.attr(prefix + this);
197                    });
198
199                    this.adapt({
200                        element: element,
201                        form: form,
202                        message: message,
203                        params: paramValues,
204                        rules: rules,
205                        messages: messages
206                    });
207                }
208            });
209
210            $.extend(rules, { "__dummy__": true });
211
212            if (!skipAttach) {
213                valInfo.attachValidation();
214            }
215        },
216
217        parse: function (selector) {
218            /// <summary>
219            /// Parses all the HTML elements in the specified selector. It looks for input elements decorated
220            /// with the [data-val=true] attribute value and enables validation according to the data-val-*
221            /// attribute values.
222            /// </summary>
223            /// <param name="selector" type="String">Any valid jQuery selector.</param>
224
225            // $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one
226            // element with data-val=true
227            var $selector = $(selector),
228                $forms = $selector.parents()
229                                  .addBack()
230                                  .filter("form")
231                                  .add($selector.find("form"))
232                                  .has("[data-val=true]");
233
234            $selector.find("[data-val=true]").each(function () {
235                $jQval.unobtrusive.parseElement(this, true);
236            });
237
238            $forms.each(function () {
239                var info = validationInfo(this);
240                if (info) {
241                    info.attachValidation();
242                }
243            });
244        },
245
246        parseDynamic: function (selector) {
247            $(selector).find('*[data-val=true]').each(function () {
248                $jQval.unobtrusive.parseElement(this, false);
249            });
250
251            //get the relevant form
252            var form = $(selector).first().closest('form');
253
254            //get the collections of unobstrusive validators, and jquery validators
255            //and compare the two
256            var unobtrusiveValidation = form.data('unobtrusiveValidation');
257            var validator = form.validate();
258            if (unobtrusiveValidation) {
259                $.each(unobtrusiveValidation.options.rules, function (elname, elrules) {
260                    if (validator.settings.rules[elname] == undefined) {
261                        var args = {};
262                        $.extend(args, elrules);
263                        args.messages = unobtrusiveValidation.options.messages[elname];
264                        $('[name="' + elname + '"]').rules("add", args);
265                    } else {
266                        $.each(elrules, function (rulename, data) {
267                            if (validator.settings.rules[elname][rulename] == undefined) {
268                                var args = {};
269                                args[rulename] = data;
270                                args.messages = unobtrusiveValidation.options.messages[elname][rulename];
271                                $('[name="' + elname + '"]').rules("add", args);
272                            }
273                        });
274                    }
275                });
276            }
277        }
278    };
279
280    adapters = $jQval.unobtrusive.adapters;
281
282    adapters.add = function (adapterName, params, fn) {
283        /// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation.</summary>
284        /// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
285        /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
286        /// <param name="params" type="Array" optional="true">[Optional] An array of parameter names (strings) that will
287        /// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and
288        /// mmmm is the parameter name).</param>
289        /// <param name="fn" type="Function">The function to call, which adapts the values from the HTML
290        /// attributes into jQuery Validate rules and/or messages.</param>
291        /// <returns type="jQuery.validator.unobtrusive.adapters" />
292        if (!fn) {  // Called with no params, just a function
293            fn = params;
294            params = [];
295        }
296        this.push({ name: adapterName, params: params, adapt: fn });
297        return this;
298    };
299
300    adapters.addBool = function (adapterName, ruleName) {
301        /// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
302        /// the jQuery Validate validation rule has no parameter values.</summary>
303        /// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
304        /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
305        /// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
306        /// of adapterName will be used instead.</param>
307        /// <returns type="jQuery.validator.unobtrusive.adapters" />
308        return this.add(adapterName, function (options) {
309            setValidationValues(options, ruleName || adapterName, true);
310        });
311    };
312
313    adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) {
314        /// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
315        /// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and
316        /// one for min-and-max). The HTML parameters are expected to be named -min and -max.</summary>
317        /// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
318        /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
319        /// <param name="minRuleName" type="String">The name of the jQuery Validate rule to be used when you only
320        /// have a minimum value.</param>
321        /// <param name="maxRuleName" type="String">The name of the jQuery Validate rule to be used when you only
322        /// have a maximum value.</param>
323        /// <param name="minMaxRuleName" type="String">The name of the jQuery Validate rule to be used when you
324        /// have both a minimum and maximum value.</param>
325        /// <param name="minAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
326        /// contains the minimum value. The default is "min".</param>
327        /// <param name="maxAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
328        /// contains the maximum value. The default is "max".</param>
329        /// <returns type="jQuery.validator.unobtrusive.adapters" />
330        return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) {
331            var min = options.params.min,
332                max = options.params.max;
333
334            if (min && max) {
335                setValidationValues(options, minMaxRuleName, [min, max]);
336            }
337            else if (min) {
338                setValidationValues(options, minRuleName, min);
339            }
340            else if (max) {
341                setValidationValues(options, maxRuleName, max);
342            }
343        });
344    };
345
346    adapters.addSingleVal = function (adapterName, attribute, ruleName) {
347        /// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
348        /// the jQuery Validate validation rule has a single value.</summary>
349        /// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
350        /// in the data-val-nnnn HTML attribute(where nnnn is the adapter name).</param>
351        /// <param name="attribute" type="String">[Optional] The name of the HTML attribute that contains the value.
352        /// The default is "val".</param>
353        /// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
354        /// of adapterName will be used instead.</param>
355        /// <returns type="jQuery.validator.unobtrusive.adapters" />
356        return this.add(adapterName, [attribute || "val"], function (options) {
357            setValidationValues(options, ruleName || adapterName, options.params[attribute]);
358        });
359    };
360
361    $jQval.addMethod("__dummy__", function (value, element, params) {
362        return true;
363    });
364
365    $jQval.addMethod("regex", function (value, element, params) {
366        var match;
367        if (this.optional(element)) {
368            return true;
369        }
370
371        match = new RegExp(params).exec(value);
372        return (match && (match.index === 0) && (match[0].length === value.length));
373    });
374
375    $jQval.addMethod("nonalphamin", function (value, element, nonalphamin) {
376        var match;
377        if (nonalphamin) {
378            match = value.match(/\W/g);
379            match = match && match.length >= nonalphamin;
380        }
381        return match;
382    });
383
384    if ($jQval.methods.extension) {
385        adapters.addSingleVal("accept", "mimtype");
386        adapters.addSingleVal("extension", "extension");
387    } else {
388        // for backward compatibility, when the 'extension' validation method does not exist, such as with versions
389        // of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for
390        // validating the extension, and ignore mime-type validations as they are not supported.
391        adapters.addSingleVal("extension", "extension", "accept");
392    }
393
394    adapters.addSingleVal("regex", "pattern");
395    adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");
396    adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range");
397    adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength");
398    adapters.add("equalto", ["other"], function (options) {
399        var prefix = getModelPrefix(options.element.name),
400            other = options.params.other,
401            fullOtherName = appendModelPrefix(other, prefix),
402            element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0];
403
404        setValidationValues(options, "equalTo", element);
405    });
406    adapters.add("required", function (options) {
407        // jQuery Validate equates "required" with "mandatory" for checkbox elements
408        if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") {
409            setValidationValues(options, "required", true);
410        }
411    });
412    adapters.add("remote", ["url", "type", "additionalfields"], function (options) {
413        var value = {
414            url: options.params.url,
415            type: options.params.type || "GET",
416            data: {}
417        },
418            prefix = getModelPrefix(options.element.name);
419
420        $.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) {
421            var paramName = appendModelPrefix(fieldName, prefix);
422            value.data[paramName] = function () {
423                return $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']").val();
424            };
425        });
426
427        setValidationValues(options, "remote", value);
428    });
429    adapters.add("password", ["min", "nonalphamin", "regex"], function (options) {
430        if (options.params.min) {
431            setValidationValues(options, "minlength", options.params.min);
432        }
433        if (options.params.nonalphamin) {
434            setValidationValues(options, "nonalphamin", options.params.nonalphamin);
435        }
436        if (options.params.regex) {
437            setValidationValues(options, "regex", options.params.regex);
438        }
439    });
440
441    $(function () {
442        $jQval.unobtrusive.parse(document);
443    });
444}(jQuery));

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.