PageSourceSearch

https://www.hamnicwritingservices.com/assets/js/jquery.form.js

js hamnicwritingservices.com collected 2026-10-07 01:15:07 UTC 34,180 bytes, 871 lines download raw bytes

1/*!
2 * jQuery Form Plugin
3 * version: 3.32.0-2013.04.09
4 * @requires jQuery v1.5 or later
5 * Copyright (c) 2013 M. Alsup
6 * Examples and documentation at: http://malsup.com/jquery/form/
7 * Project repository: https://github.com/malsup/form
8 * Dual licensed under the MIT and GPL licenses.
9 * https://github.com/malsup/form#copyright-and-license
10 */
11;
12(function($) {
13    "use strict";
14    var feature = {};
15    feature.fileapi = $("<input type='file'/>").get(0).files !== undefined;
16    feature.formdata = window.FormData !== undefined;
17    var hasProp = !!$.fn.prop;
18    $.fn.attr2 = function() {
19        if (!hasProp)
20            return this.attr.apply(this, arguments);
21        var val = this.prop.apply(this, arguments);
22        if ((val && val.jquery) || typeof val === 'string')
23            return val;
24        return this.attr.apply(this, arguments);
25    };
26    $.fn.ajaxSubmit = function(options) {
27        if (!this.length) {
28            log('ajaxSubmit: skipping submit process - no element selected');
29            return this;
30        }
31        var method, action, url, $form = this;
32        if (typeof options == 'function') {
33            options = {
34                success: options
35            };
36        }
37        method = this.attr2('method');
38        action = this.attr2('action');
39        url = (typeof action === 'string') ? $.trim(action) : '';
40        url = url || window.location.href || '';
41        if (url) {
42            url = (url.match(/^([^#]+)/) || [])[1];
43        }
44        options = $.extend(true, {
45            url: url,
46            success: $.ajaxSettings.success,
47            type: method || 'GET',
48            iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
49        }, options);
50        var veto = {};
51        this.trigger('form-pre-serialize', [this, options, veto]);
52        if (veto.veto) {
53            log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
54            return this;
55        }
56        if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
57            log('ajaxSubmit: submit aborted via beforeSerialize callback');
58            return this;
59        }
60        var traditional = options.traditional;
61        if (traditional === undefined) {
62            traditional = $.ajaxSettings.traditional;
63        }
64        var elements = [];
65        var qx, a = this.formToArray(options.semantic, elements);
66        if (options.data) {
67            options.extraData = options.data;
68            qx = $.param(options.data, traditional);
69        }
70        if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
71            log('ajaxSubmit: submit aborted via beforeSubmit callback');
72            return this;
73        }
74        this.trigger('form-submit-validate', [a, this, options, veto]);
75        if (veto.veto) {
76            log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
77            return this;
78        }
79        var q = $.param(a, traditional);
80        if (qx) {
81            q = (q ? (q + '&' + qx) : qx);
82        }
83        if (options.type.toUpperCase() == 'GET') {
84            options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
85            options.data = null;
86        } else {
87            options.data = q;
88        }
89        var callbacks = [];
90        if (options.resetForm) {
91            callbacks.push(function() {
92                $form.resetForm();
93            });
94        }
95        if (options.clearForm) {
96            callbacks.push(function() {
97                $form.clearForm(options.includeHidden);
98            });
99        }
100        if (!options.dataType && options.target) {
101            var oldSuccess = options.success || function() {};
102            callbacks.push(function(data) {
103                var fn = options.replaceTarget ? 'replaceWith' : 'html';
104                $(options.target)[fn](data).each(oldSuccess, arguments);
105            });
106        } else if (options.success) {
107            callbacks.push(options.success);
108        }
109        options.success = function(data, status, xhr) {
110            var context = options.context || this;
111            for (var i = 0, max = callbacks.length; i < max; i++) {
112                callbacks[i].apply(context, [data, status, xhr || $form, $form]);
113            }
114        };
115        var fileInputs = $('input[type=file]:enabled[value!=""]', this);
116        var hasFileInputs = fileInputs.length > 0;
117        var mp = 'multipart/form-data';
118        var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
119        var fileAPI = feature.fileapi && feature.formdata;
120        log("fileAPI :" + fileAPI);
121        var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
122        var jqxhr;
123        if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
124            if (options.closeKeepAlive) {
125                $.get(options.closeKeepAlive, function() {
126                    jqxhr = fileUploadIframe(a);
127                });
128            } else {
129                jqxhr = fileUploadIframe(a);
130            }
131        } else if ((hasFileInputs || multipart) && fileAPI) {
132            jqxhr = fileUploadXhr(a);
133        } else {
134            jqxhr = $.ajax(options);
135        }
136        $form.removeData('jqxhr').data('jqxhr', jqxhr);
137        for (var k = 0; k < elements.length; k++)
138            elements[k] = null;
139        this.trigger('form-submit-notify', [this, options]);
140        return this;
141
142        function deepSerialize(extraData) {
143            var serialized = $.param(extraData).split('&');
144            var len = serialized.length;
145            var result = [];
146            var i, part;
147            for (i = 0; i < len; i++) {
148                serialized[i] = serialized[i].replace(/\+/g, ' ');
149                part = serialized[i].split('=');
150                result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
151            }
152            return result;
153        }
154
155        function fileUploadXhr(a) {
156            var formdata = new FormData();
157            for (var i = 0; i < a.length; i++) {
158                formdata.append(a[i].name, a[i].value);
159            }
160            if (options.extraData) {
161                var serializedData = deepSerialize(options.extraData);
162                for (i = 0; i < serializedData.length; i++)
163                    if (serializedData[i])
164                        formdata.append(serializedData[i][0], serializedData[i][1]);
165            }
166            options.data = null;
167            var s = $.extend(true, {}, $.ajaxSettings, options, {
168                contentType: false,
169                processData: false,
170                cache: false,
171                type: method || 'POST'
172            });
173            if (options.uploadProgress) {
174                s.xhr = function() {
175                    var xhr = jQuery.ajaxSettings.xhr();
176                    if (xhr.upload) {
177                        xhr.upload.addEventListener('progress', function(event) {
178                            var percent = 0;
179                            var position = event.loaded || event.position;
180                            var total = event.total;
181                            if (event.lengthComputable) {
182                                percent = Math.ceil(position / total * 100);
183                            }
184                            options.uploadProgress(event, position, total, percent);
185                        }, false);
186                    }
187                    return xhr;
188                };
189            }
190            s.data = null;
191            var beforeSend = s.beforeSend;
192            s.beforeSend = function(xhr, o) {
193                o.data = formdata;
194                if (beforeSend)
195                    beforeSend.call(this, xhr, o);
196            };
197            return $.ajax(s);
198        }
199
200        function fileUploadIframe(a) {
201            var form = $form[0],
202                el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
203            var deferred = $.Deferred();
204            if (a) {
205                for (i = 0; i < elements.length; i++) {
206                    el = $(elements[i]);
207                    if (hasProp)
208                        el.prop('disabled', false);
209                    else
210                        el.removeAttr('disabled');
211                }
212            }
213            s = $.extend(true, {}, $.ajaxSettings, options);
214            s.context = s.context || s;
215            id = 'jqFormIO' + (new Date().getTime());
216            if (s.iframeTarget) {
217                $io = $(s.iframeTarget);
218                n = $io.attr2('name');
219                if (!n)
220                    $io.attr2('name', id);
221                else
222                    id = n;
223            } else {
224                $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />');
225                $io.css({
226                    position: 'absolute',
227                    top: '-1000px',
228                    left: '-1000px'
229                });
230            }
231            io = $io[0];
232            xhr = {
233                aborted: 0,
234                responseText: null,
235                responseXML: null,
236                status: 0,
237                statusText: 'n/a',
238                getAllResponseHeaders: function() {},
239                getResponseHeader: function() {},
240                setRequestHeader: function() {},
241                abort: function(status) {
242                    var e = (status === 'timeout' ? 'timeout' : 'aborted');
243                    log('aborting upload... ' + e);
244                    this.aborted = 1;
245                    try {
246                        if (io.contentWindow.document.execCommand) {
247                            io.contentWindow.document.execCommand('Stop');
248                        }
249                    } catch (ignore) {}
250                    $io.attr('src', s.iframeSrc);
251                    xhr.error = e;
252                    if (s.error)
253                        s.error.call(s.context, xhr, e, status);
254                    if (g)
255                        $.event.trigger("ajaxError", [xhr, s, e]);
256                    if (s.complete)
257                        s.complete.call(s.context, xhr, e);
258                }
259            };
260            g = s.global;
261            if (g && 0 === $.active++) {
262                $.event.trigger("ajaxStart");
263            }
264            if (g) {
265                $.event.trigger("ajaxSend", [xhr, s]);
266            }
267            if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
268                if (s.global) {
269                    $.active--;
270                }
271                deferred.reject();
272                return deferred;
273            }
274            if (xhr.aborted) {
275                deferred.reject();
276                return deferred;
277            }
278            sub = form.clk;
279            if (sub) {
280                n = sub.name;
281                if (n && !sub.disabled) {
282                    s.extraData = s.extraData || {};
283                    s.extraData[n] = sub.value;
284                    if (sub.type == "image") {
285                        s.extraData[n + '.x'] = form.clk_x;
286                        s.extraData[n + '.y'] = form.clk_y;
287                    }
288                }
289            }
290            var CLIENT_TIMEOUT_ABORT = 1;
291            var SERVER_ABORT = 2;
292
293            function getDoc(frame) {
294                var doc = null;
295                try {
296                    if (frame.contentWindow) {
297                        doc = frame.contentWindow.document;
298                    }
299                } catch (err) {
300                    log('cannot get iframe.contentWindow document: ' + err);
301                }
302                if (doc) {
303                    return doc;
304                }
305                try {
306                    doc = frame.contentDocument ? frame.contentDocument : frame.document;
307                } catch (err) {
308                    log('cannot get iframe.contentDocument: ' + err);
309                    doc = frame.document;
310                }
311                return doc;
312            }
313            var csrf_token = $('meta[name=csrf-token]').attr('content');
314            var csrf_param = $('meta[name=csrf-param]').attr('content');
315            if (csrf_param && csrf_token) {
316                s.extraData = s.extraData || {};
317                s.extraData[csrf_param] = csrf_token;
318            }
319
320            function doSubmit() {
321                var t = $form.attr2('target'),
322                    a = $form.attr2('action');
323                form.setAttribute('target', id);
324                if (!method) {
325                    form.setAttribute('method', 'POST');
326                }
327                if (a != s.url) {
328                    form.setAttribute('action', s.url);
329                }
330                if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {
331                    $form.attr({
332                        encoding: 'multipart/form-data',
333                        enctype: 'multipart/form-data'
334                    });
335                }
336                if (s.timeout) {
337                    timeoutHandle = setTimeout(function() {
338                        timedOut = true;
339                        cb(CLIENT_TIMEOUT_ABORT);
340                    }, s.timeout);
341                }
342
343                function checkState() {
344                    try {
345                        var state = getDoc(io).readyState;
346                        log('state = ' + state);
347                        if (state && state.toLowerCase() == 'uninitialized')
348                            setTimeout(checkState, 50);
349                    } catch (e) {
350                        log('Server abort: ', e, ' (', e.name, ')');
351                        cb(SERVER_ABORT);
352                        if (timeoutHandle)
353                            clearTimeout(timeoutHandle);
354                        timeoutHandle = undefined;
355                    }
356                }
357                var extraInputs = [];
358                try {
359                    if (s.extraData) {
360                        for (var n in s.extraData) {
361                            if (s.extraData.hasOwnProperty(n)) {
362                                if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
363                                    extraInputs.push($('<input type="hidden" name="' + s.extraData[n].name + '">').val(s.extraData[n].value).appendTo(form)[0]);
364                                } else {
365                                    extraInputs.push($('<input type="hidden" name="' + n + '">').val(s.extraData[n]).appendTo(form)[0]);
366                                }
367                            }
368                        }
369                    }
370                    if (!s.iframeTarget) {
371                        $io.appendTo('body');
372                        if (io.attachEvent)
373                            io.attachEvent('onload', cb);
374                        else
375                            io.addEventListener('load', cb, false);
376                    }
377                    setTimeout(checkState, 15);
378                    try {
379                        form.submit();
380                    } catch (err) {
381                        var submitFn = document.createElement('form').submit;
382                        submitFn.apply(form);
383                    }
384                } finally {
385                    form.setAttribute('action', a);
386                    if (t) {
387                        form.setAttribute('target', t);
388                    } else {
389                        $form.removeAttr('target');
390                    }
391                    $(extraInputs).remove();
392                }
393            }
394            if (s.forceSync) {
395                doSubmit();
396            } else {
397                setTimeout(doSubmit, 10);
398            }
399            var data, doc, domCheckCount = 50,
400                callbackProcessed;
401
402            function cb(e) {
403                if (xhr.aborted || callbackProcessed) {
404                    return;
405                }
406                doc = getDoc(io);
407                if (!doc) {
408                    log('cannot access response document');
409                    e = SERVER_ABORT;
410                }
411                if (e === CLIENT_TIMEOUT_ABORT && xhr) {
412                    xhr.abort('timeout');
413                    deferred.reject(xhr, 'timeout');
414                    return;
415                } else if (e == SERVER_ABORT && xhr) {
416                    xhr.abort('server abort');
417                    deferred.reject(xhr, 'error', 'server abort');
418                    return;
419                }
420                if (!doc || doc.location.href == s.iframeSrc) {
421                    if (!timedOut)
422                        return;
423                }
424                if (io.detachEvent)
425                    io.detachEvent('onload', cb);
426                else
427                    io.removeEventListener('load', cb, false);
428                var status = 'success',
429                    errMsg;
430                try {
431                    if (timedOut) {
432                        throw 'timeout';
433                    }
434                    var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
435                    log('isXml=' + isXml);
436                    if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
437                        if (--domCheckCount) {
438                            log('requeing onLoad callback, DOM not available');
439                            setTimeout(cb, 250);
440                            return;
441                        }
442                    }
443                    var docRoot = doc.body ? doc.body : doc.documentElement;
444                    xhr.responseText = docRoot ? docRoot.innerHTML : null;
445                    xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
446                    if (isXml)
447                        s.dataType = 'xml';
448                    xhr.getResponseHeader = function(header) {
449                        var headers = {
450                            'content-type': s.dataType
451                        };
452                        return headers[header];
453                    };
454                    if (docRoot) {
455                        xhr.status = Number(docRoot.getAttribute('status')) || xhr.status;
456                        xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
457                    }
458                    var dt = (s.dataType || '').toLowerCase();
459                    var scr = /(json|script|text)/.test(dt);
460                    if (scr || s.textarea) {
461                        var ta = doc.getElementsByTagName('textarea')[0];
462                        if (ta) {
463                            xhr.responseText = ta.value;
464                            xhr.status = Number(ta.getAttribute('status')) || xhr.status;
465                            xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
466                        } else if (scr) {
467                            var pre = doc.getElementsByTagName('pre')[0];
468                            var b = doc.getElementsByTagName('body')[0];
469                            if (pre) {
470                                xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
471                            } else if (b) {
472                                xhr.responseText = b.textContent ? b.textContent : b.innerText;
473                            }
474                        }
475                    } else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
476                        xhr.responseXML = toXml(xhr.responseText);
477                    }
478                    try {
479                        data = httpData(xhr, dt, s);
480                    } catch (err) {
481                        status = 'parsererror';
482                        xhr.error = errMsg = (err || status);
483                    }
484                } catch (err) {
485                    log('error caught: ', err);
486                    status = 'error';
487                    xhr.error = errMsg = (err || status);
488                }
489                if (xhr.aborted) {
490                    log('upload aborted');
491                    status = null;
492                }
493                if (xhr.status) {
494                    status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
495                }
496                if (status === 'success') {
497                    if (s.success)
498                        s.success.call(s.context, data, 'success', xhr);
499                    deferred.resolve(xhr.responseText, 'success', xhr);
500                    if (g)
501                        $.event.trigger("ajaxSuccess", [xhr, s]);
502                } else if (status) {
503                    if (errMsg === undefined)
504                        errMsg = xhr.statusText;
505                    if (s.error)
506                        s.error.call(s.context, xhr, status, errMsg);
507                    deferred.reject(xhr, 'error', errMsg);
508                    if (g)
509                        $.event.trigger("ajaxError", [xhr, s, errMsg]);
510                }
511                if (g)
512                    $.event.trigger("ajaxComplete", [xhr, s]);
513                if (g && !--$.active) {
514                    $.event.trigger("ajaxStop");
515                }
516                if (s.complete)
517                    s.complete.call(s.context, xhr, status);
518                callbackProcessed = true;
519                if (s.timeout)
520                    clearTimeout(timeoutHandle);
521                setTimeout(function() {
522                    if (!s.iframeTarget)
523                        $io.remove();
524                    xhr.responseXML = null;
525                }, 100);
526            }
527            var toXml = $.parseXML || function(s, doc) {
528                if (window.ActiveXObject) {
529                    doc = new ActiveXObject('Microsoft.XMLDOM');
530                    doc.async = 'false';
531                    doc.loadXML(s);
532                } else {
533                    doc = (new DOMParser()).parseFromString(s, 'text/xml');
534                }
535                return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
536            };
537            var parseJSON = $.parseJSON || function(s) {
538                return window['eval']('(' + s + ')');
539            };
540            var httpData = function(xhr, type, s) {
541                var ct = xhr.getResponseHeader('content-type') || '',
542                    xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
543                    data = xml ? xhr.responseXML : xhr.responseText;
544                if (xml && data.documentElement.nodeName === 'parsererror') {
545                    if ($.error)
546                        $.error('parsererror');
547                }
548                if (s && s.dataFilter) {
549                    data = s.dataFilter(data, type);
550                }
551                if (typeof data === 'string') {
552                    if (type === 'json' || !type && ct.indexOf('json') >= 0) {
553                        data = parseJSON(data);
554                    } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
555                        $.globalEval(data);
556                    }
557                }
558                return data;
559            };
560            return deferred;
561        }
562    };
563    $.fn.ajaxForm = function(options) {
564        options = options || {};
565        options.delegation = options.delegation && $.isFunction($.fn.on);
566        if (!options.delegation && this.length === 0) {
567            var o = {
568                s: this.selector,
569                c: this.context
570            };
571            if (!$.isReady && o.s) {
572                log('DOM not ready, queuing ajaxForm');
573                $(function() {
574                    $(o.s, o.c).ajaxForm(options);
575                });
576                return this;
577            }
578            log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
579            return this;
580        }
581        if (options.delegation) {
582            $(document).off('submit.form-plugin', this.selector, doAjaxSubmit).off('click.form-plugin', this.selector, captureSubmittingElement).on('submit.form-plugin', this.selector, options, doAjaxSubmit).on('click.form-plugin', this.selector, options, captureSubmittingElement);
583            return this;
584        }
585        return this.ajaxFormUnbind().bind('submit.form-plugin', options, doAjaxSubmit).bind('click.form-plugin', options, captureSubmittingElement);
586    };
587
588    function doAjaxSubmit(e) {
589        var options = e.data;
590        if (!e.isDefaultPrevented()) {
591            e.preventDefault();
592            $(this).ajaxSubmit(options);
593        }
594    }
595
596    function captureSubmittingElement(e) {
597        var target = e.target;
598        var $el = $(target);
599        if (!($el.is("[type=submit],[type=image]"))) {
600            var t = $el.closest('[type=submit]');
601            if (t.length === 0) {
602                return;
603            }
604            target = t[0];
605        }
606        var form = this;
607        form.clk = target;
608        if (target.type == 'image') {
609            if (e.offsetX !== undefined) {
610                form.clk_x = e.offsetX;
611                form.clk_y = e.offsetY;
612            } else if (typeof $.fn.offset == 'function') {
613                var offset = $el.offset();
614                form.clk_x = e.pageX - offset.left;
615                form.clk_y = e.pageY - offset.top;
616            } else {
617                form.clk_x = e.pageX - target.offsetLeft;
618                form.clk_y = e.pageY - target.offsetTop;
619            }
620        }
621        setTimeout(function() {
622            form.clk = form.clk_x = form.clk_y = null;
623        }, 100);
624    }
625    $.fn.ajaxFormUnbind = function() {
626        return this.unbind('submit.form-plugin click.form-plugin');
627    };
628    $.fn.formToArray = function(semantic, elements) {
629        var a = [];
630        if (this.length === 0) {
631            return a;
632        }
633        var form = this[0];
634        var els = semantic ? form.getElementsByTagName('*') : form.elements;
635        if (!els) {
636            return a;
637        }
638        var i, j, n, v, el, max, jmax;
639        for (i = 0, max = els.length; i < max; i++) {
640            el = els[i];
641            n = el.name;
642            if (!n || el.disabled) {
643                continue;
644            }
645            if (semantic && form.clk && el.type == "image") {
646                if (form.clk == el) {
647                    a.push({
648                        name: n,
649                        value: $(el).val(),
650                        type: el.type
651                    });
652                    a.push({
653                        name: n + '.x',
654                        value: form.clk_x
655                    }, {
656                        name: n + '.y',
657                        value: form.clk_y
658                    });
659                }
660                continue;
661            }
662            v = $.fieldValue(el, true);
663            if (v && v.constructor == Array) {
664                if (elements)
665                    elements.push(el);
666                for (j = 0, jmax = v.length; j < jmax; j++) {
667                    a.push({
668                        name: n,
669                        value: v[j]
670                    });
671                }
672            } else if (feature.fileapi && el.type == 'file') {
673                if (elements)
674                    elements.push(el);
675                var files = el.files;
676                if (files.length) {
677                    for (j = 0; j < files.length; j++) {
678                        a.push({
679                            name: n,
680                            value: files[j],
681                            type: el.type
682                        });
683                    }
684                } else {
685                    a.push({
686                        name: n,
687                        value: '',
688                        type: el.type
689                    });
690                }
691            } else if (v !== null && typeof v != 'undefined') {
692                if (elements)
693                    elements.push(el);
694                a.push({
695                    name: n,
696                    value: v,
697                    type: el.type,
698                    required: el.required
699                });
700            }
701        }
702        if (!semantic && form.clk) {
703            var $input = $(form.clk),
704                input = $input[0];
705            n = input.name;
706            if (n && !input.disabled && input.type == 'image') {
707                a.push({
708                    name: n,
709                    value: $input.val()
710                });
711                a.push({
712                    name: n + '.x',
713                    value: form.clk_x
714                }, {
715                    name: n + '.y',
716                    value: form.clk_y
717                });
718            }
719        }
720        return a;
721    };
722    $.fn.formSerialize = function(semantic) {
723        return $.param(this.formToArray(semantic));
724    };
725    $.fn.fieldSerialize = function(successful) {
726        var a = [];
727        this.each(function() {
728            var n = this.name;
729            if (!n) {
730                return;
731            }
732            var v = $.fieldValue(this, successful);
733            if (v && v.constructor == Array) {
734                for (var i = 0, max = v.length; i < max; i++) {
735                    a.push({
736                        name: n,
737                        value: v[i]
738                    });
739                }
740            } else if (v !== null && typeof v != 'undefined') {
741                a.push({
742                    name: this.name,
743                    value: v
744                });
745            }
746        });
747        return $.param(a);
748    };
749    $.fn.fieldValue = function(successful) {
750        for (var val = [], i = 0, max = this.length; i < max; i++) {
751            var el = this[i];
752            var v = $.fieldValue(el, successful);
753            if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
754                continue;
755            }
756            if (v.constructor == Array)
757                $.merge(val, v);
758            else
759                val.push(v);
760        }
761        return val;
762    };
763    $.fieldValue = function(el, successful) {
764        var n = el.name,
765            t = el.type,
766            tag = el.tagName.toLowerCase();
767        if (successful === undefined) {
768            successful = true;
769        }
770        if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || (t == 'checkbox' || t == 'radio') && !el.checked || (t == 'submit' || t == 'image') && el.form && el.form.clk != el || tag == 'select' && el.selectedIndex == -1)) {
771            return null;
772        }
773        if (tag == 'select') {
774            var index = el.selectedIndex;
775            if (index < 0) {
776                return null;
777            }
778            var a = [],
779                ops = el.options;
780            var one = (t == 'select-one');
781            var max = (one ? index + 1 : ops.length);
782            for (var i = (one ? index : 0); i < max; i++) {
783                var op = ops[i];
784                if (op.selected) {
785                    var v = op.value;
786                    if (!v) {
787                        v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
788                    }
789                    if (one) {
790                        return v;
791                    }
792                    a.push(v);
793                }
794            }
795            return a;
796        }
797        return $(el).val();
798    };
799    $.fn.clearForm = function(includeHidden) {
800        return this.each(function() {
801            $('input,select,textarea', this).clearFields(includeHidden);
802        });
803    };
804    $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
805        var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;
806        return this.each(function() {
807            var t = this.type,
808                tag = this.tagName.toLowerCase();
809            if (re.test(t) || tag == 'textarea') {
810                this.value = '';
811            } else if (t == 'checkbox' || t == 'radio') {
812                this.checked = false;
813            } else if (tag == 'select') {
814                this.selectedIndex = -1;
815            } else if (t == "file") {
816                if (/MSIE/.test(navigator.userAgent)) {
817                    $(this).replaceWith($(this).clone(true));
818                } else {
819                    $(this).val('');
820                }
821            } else if (includeHidden) {
822                if ((includeHidden === true && /hidden/.test(t)) || (typeof includeHidden == 'string' && $(this).is(includeHidden)))
823                    this.value = '';
824            }
825        });
826    };
827    $.fn.resetForm = function() {
828        return this.each(function() {
829            if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
830                this.reset();
831            }
832        });
833    };
834    $.fn.enable = function(b) {
835        if (b === undefined) {
836            b = true;
837        }
838        return this.each(function() {
839            this.disabled = !b;
840        });
841    };
842    $.fn.selected = function(select) {
843        if (select === undefined) {
844            select = true;
845        }
846        return this.each(function() {
847            var t = this.type;
848            if (t == 'checkbox' || t == 'radio') {
849                this.checked = select;
850            } else if (this.tagName.toLowerCase() == 'option') {
851                var $sel = $(this).parent('select');
852                if (select && $sel[0] && $sel[0].type == 'select-one') {
853                    $sel.find('option').selected(false);
854                }
855                this.selected = select;
856            }
857        });
858    };
859    $.fn.ajaxSubmit.debug = false;
860
861    function log() {
862        if (!$.fn.ajaxSubmit.debug)
863            return;
864        var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, '');
865        if (window.console && window.console.log) {
866            window.console.log(msg);
867        } else if (window.opera && window.opera.postError) {
868            window.opera.postError(msg);
869        }
870    }
871})(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.