MCPcopy Create free account
hub / github.com/apache/cloudstack / ajaxConvert

Function ajaxConvert

tools/ngui/static/js/lib/jquery-1.7.2.js:7884–7966  ·  view source on GitHub ↗
( s, response )

Source from the content-addressed store, hash-verified

7882
7883// Chain conversions given the request and the original response
7884function ajaxConvert( s, response ) {
7885
7886 // Apply the dataFilter if provided
7887 if ( s.dataFilter ) {
7888 response = s.dataFilter( response, s.dataType );
7889 }
7890
7891 var dataTypes = s.dataTypes,
7892 converters = {},
7893 i,
7894 key,
7895 length = dataTypes.length,
7896 tmp,
7897 // Current and previous dataTypes
7898 current = dataTypes[ 0 ],
7899 prev,
7900 // Conversion expression
7901 conversion,
7902 // Conversion function
7903 conv,
7904 // Conversion functions (transitive conversion)
7905 conv1,
7906 conv2;
7907
7908 // For each dataType in the chain
7909 for ( i = 1; i < length; i++ ) {
7910
7911 // Create converters map
7912 // with lowercased keys
7913 if ( i === 1 ) {
7914 for ( key in s.converters ) {
7915 if ( typeof key === "string" ) {
7916 converters[ key.toLowerCase() ] = s.converters[ key ];
7917 }
7918 }
7919 }
7920
7921 // Get the dataTypes
7922 prev = current;
7923 current = dataTypes[ i ];
7924
7925 // If current is auto dataType, update it to prev
7926 if ( current === "*" ) {
7927 current = prev;
7928 // If no auto and dataTypes are actually different
7929 } else if ( prev !== "*" && prev !== current ) {
7930
7931 // Get the converter
7932 conversion = prev + " " + current;
7933 conv = converters[ conversion ] || converters[ "* " + current ];
7934
7935 // If there is no direct converter, search transitively
7936 if ( !conv ) {
7937 conv2 = undefined;
7938 for ( conv1 in converters ) {
7939 tmp = conv1.split( " " );
7940 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7941 conv2 = converters[ tmp[1] + " " + current ];

Callers 1

doneFunction · 0.85

Calls 2

replaceMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected