1/**�� 2 * @author Kyle Florence <kyle[dot]florence[at]gmail[dot]com>�� 3 * @website https://github.com/kflorence/jquery-deserialize/�� 4 * @version 1.2.1�� 5 *�� 6 * Dual licensed under the MIT and GPLv2 licenses.�� 7 */�� 8(function( jQuery, undefined ) {�� 9�� 10var push = Array.prototype.push,�� 11 rcheck = /^(?:radio|checkbox)$/i,�� 12 rplus = /\+/g,�� 13 rselect = /^(?:option|select-one|select-multiple)$/i,�� 14 rvalue = /^(?:button|color|date|datetime|datetime-local|email|hidden|month|number|password|range|reset|search|submit|tel|text|textarea|time|url|week)$/i;�� 15�� 16function getElements( elements ) {�� 17 return elements.map(function() {�� 18 return this.elements ? jQuery.makeArray( this.elements ) : this;�� 19 }).filter( ":input:not(:disabled)" ).get();�� 20}�� 21�� 22function getElementsByName( elements ) {�� 23 var current,�� 24 elementsByName = {};�� 25�� 26 jQuery.each( elements, function( i, element ) {�� 27 current = elementsByName[ element.name ];�� 28 elementsByName[ element.name ] = current === undefined ? element :�� 29 ( jQuery.isArray( current ) ? current.concat( element ) : [ current, element ] );�� 30 });�� 31�� 32 return elementsByName;�� 33}�� 34�� 35jQuery.fn.deserialize = function( data, options ) {�� 36 var i, length,�� 37 elements = getElements( this ),�� 38 normalized = [];�� 39�� 40 if ( !data || !elements.length ) {�� 41 return this;�� 42 }�� 43�� 44 if ( jQuery.isArray( data ) ) {�� 45 normalized = data;�� 46�� 47 } else if ( jQuery.isPlainObject( data ) ) {�� 48 var key, value;�� 49�� 50 for ( key in data ) {�� 51 jQuery.isArray( value = data[ key ] ) ?�� 52 push.apply( normalized, jQuery.map( value, function( v ) {�� 53 return { name: key, value: v };�� 54 })) : push.call( normalized, { name: key, value: value } );�� 55 }�� 56�� 57 } else if ( typeof data === "string" ) {�� 58 var parts;�� 59�� 60 data = data.split( "&" );�� 61�� 62 for ( i = 0, length = data.length; i < length; i++ ) {�� 63 parts = data[ i ].split( "=" );�� 64 push.call( normalized, {�� 65 name: decodeURIComponent( parts[ 0 ].replace( rplus, "%20" ) ),�� 66 value: decodeURIComponent( parts[ 1 ].replace( rplus, "%20" ) )�� 67 });�� 68 }�� 69 }�� 70�� 71 if ( !( length = normalized.length ) ) {�� 72 return this;�� 73 }�� 74�� 75 var current, element, j, len, name, property, type, value,�� 76 change = jQuery.noop,�� 77 complete = jQuery.noop,�� 78 names = {};�� 79�� 80 options = options || {};�� 81 elements = getElementsByName( elements );�� 82�� 83 // Backwards compatible with old arguments: data, callback�� 84 if ( jQuery.isFunction( options ) ) {�� 85 complete = options;�� 86�� 87 } else {�� 88 change = jQuery.isFunction( options.change ) ? options.change : change;�� 89 complete = jQuery.isFunction( options.complete ) ? options.complete : complete;�� 90 }�� 91�� 92 for ( i = 0; i < length; i++ ) {�� 93 current = normalized[ i ];�� 94�� 95 name = current.name;�� 96 value = current.value;�� 97�� 98 if ( !( element = elements[ name ] ) ) {�� 99 continue;�� 100 }�� 101�� 102 type = ( len = element.length ) ? element[ 0 ] : element;�� 103 type = ( type.type || type.nodeName ).toLowerCase();�� 104 property = null;�� 105�� 106 if ( rvalue.test( type ) ) {�� 107 if ( len ) {�� 108 j = names[ name ];�� 109 element = element[ names[ name ] = ( j == undefined ) ? 0 : ++j ];�� 110 }�� 111�� 112 change.call( element, ( element.value = value ) );�� 113�� 114 } else if ( rcheck.test( type ) ) {�� 115 property = "checked";�� 116�� 117 } else if ( rselect.test( type ) ) {�� 118 property = "selected";�� 119 }�� 120�� 121 if ( property ) {�� 122 if ( !len ) {�� 123 element = [ element ];�� 124 len = 1;�� 125 }�� 126�� 127 for ( j = 0; j < len; j++ ) {�� 128 current = element[ j ];�� 129�� 130 if ( current.value == value ) {�� 131 change.call( current, ( current[ property ] = true ) && value );�� 132 }�� 133 }�� 134 }�� 135 }�� 136�� 137 complete.call( this );�� 138�� 139 return this;�� 140};�� 141�� 142})( 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.