MCPcopy Create free account
hub / github.com/TruthHun/BookStack / ajaxConvert

Function ajaxConvert

static/wangEditor/js/lib/jquery-2.2.1.js:8166–8260  ·  view source on GitHub ↗
( s, response, jqXHR, isSuccess )

Source from the content-addressed store, hash-verified

8164 * Also sets the responseXXX fields on the jqXHR instance
8165 */
8166function ajaxConvert( s, response, jqXHR, isSuccess ) {
8167 var conv2, current, conv, tmp, prev,
8168 converters = {},
8169
8170 // Work with a copy of dataTypes in case we need to modify it for conversion
8171 dataTypes = s.dataTypes.slice();
8172
8173 // Create converters map with lowercased keys
8174 if ( dataTypes[ 1 ] ) {
8175 for ( conv in s.converters ) {
8176 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8177 }
8178 }
8179
8180 current = dataTypes.shift();
8181
8182 // Convert to each sequential dataType
8183 while ( current ) {
8184
8185 if ( s.responseFields[ current ] ) {
8186 jqXHR[ s.responseFields[ current ] ] = response;
8187 }
8188
8189 // Apply the dataFilter if provided
8190 if ( !prev && isSuccess && s.dataFilter ) {
8191 response = s.dataFilter( response, s.dataType );
8192 }
8193
8194 prev = current;
8195 current = dataTypes.shift();
8196
8197 if ( current ) {
8198
8199 // There's only work to do if current dataType is non-auto
8200 if ( current === "*" ) {
8201
8202 current = prev;
8203
8204 // Convert response if prev dataType is non-auto and differs from current
8205 } else if ( prev !== "*" && prev !== current ) {
8206
8207 // Seek a direct converter
8208 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8209
8210 // If none found, seek a pair
8211 if ( !conv ) {
8212 for ( conv2 in converters ) {
8213
8214 // If conv2 outputs current
8215 tmp = conv2.split( " " );
8216 if ( tmp[ 1 ] === current ) {
8217
8218 // If prev can be converted to accepted input
8219 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8220 converters[ "* " + tmp[ 0 ] ];
8221 if ( conv ) {
8222
8223 // Condense equivalence converters

Callers 1

doneFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected