| @@ 7745-7827 (lines=83) @@ | ||
| 7742 | } |
|
| 7743 | ||
| 7744 | // Chain conversions given the request and the original response |
|
| 7745 | function ajaxConvert( s, response ) { |
|
| 7746 | ||
| 7747 | // Apply the dataFilter if provided |
|
| 7748 | if ( s.dataFilter ) { |
|
| 7749 | response = s.dataFilter( response, s.dataType ); |
|
| 7750 | } |
|
| 7751 | ||
| 7752 | var dataTypes = s.dataTypes, |
|
| 7753 | converters = {}, |
|
| 7754 | i, |
|
| 7755 | key, |
|
| 7756 | length = dataTypes.length, |
|
| 7757 | tmp, |
|
| 7758 | // Current and previous dataTypes |
|
| 7759 | current = dataTypes[ 0 ], |
|
| 7760 | prev, |
|
| 7761 | // Conversion expression |
|
| 7762 | conversion, |
|
| 7763 | // Conversion function |
|
| 7764 | conv, |
|
| 7765 | // Conversion functions (transitive conversion) |
|
| 7766 | conv1, |
|
| 7767 | conv2; |
|
| 7768 | ||
| 7769 | // For each dataType in the chain |
|
| 7770 | for ( i = 1; i < length; i++ ) { |
|
| 7771 | ||
| 7772 | // Create converters map |
|
| 7773 | // with lowercased keys |
|
| 7774 | if ( i === 1 ) { |
|
| 7775 | for ( key in s.converters ) { |
|
| 7776 | if ( typeof key === "string" ) { |
|
| 7777 | converters[ key.toLowerCase() ] = s.converters[ key ]; |
|
| 7778 | } |
|
| 7779 | } |
|
| 7780 | } |
|
| 7781 | ||
| 7782 | // Get the dataTypes |
|
| 7783 | prev = current; |
|
| 7784 | current = dataTypes[ i ]; |
|
| 7785 | ||
| 7786 | // If current is auto dataType, update it to prev |
|
| 7787 | if ( current === "*" ) { |
|
| 7788 | current = prev; |
|
| 7789 | // If no auto and dataTypes are actually different |
|
| 7790 | } else if ( prev !== "*" && prev !== current ) { |
|
| 7791 | ||
| 7792 | // Get the converter |
|
| 7793 | conversion = prev + " " + current; |
|
| 7794 | conv = converters[ conversion ] || converters[ "* " + current ]; |
|
| 7795 | ||
| 7796 | // If there is no direct converter, search transitively |
|
| 7797 | if ( !conv ) { |
|
| 7798 | conv2 = undefined; |
|
| 7799 | for ( conv1 in converters ) { |
|
| 7800 | tmp = conv1.split( " " ); |
|
| 7801 | if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { |
|
| 7802 | conv2 = converters[ tmp[1] + " " + current ]; |
|
| 7803 | if ( conv2 ) { |
|
| 7804 | conv1 = converters[ conv1 ]; |
|
| 7805 | if ( conv1 === true ) { |
|
| 7806 | conv = conv2; |
|
| 7807 | } else if ( conv2 === true ) { |
|
| 7808 | conv = conv1; |
|
| 7809 | } |
|
| 7810 | break; |
|
| 7811 | } |
|
| 7812 | } |
|
| 7813 | } |
|
| 7814 | } |
|
| 7815 | // If we found no converter, dispatch an error |
|
| 7816 | if ( !( conv || conv2 ) ) { |
|
| 7817 | jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); |
|
| 7818 | } |
|
| 7819 | // If found converter is not an equivalence |
|
| 7820 | if ( conv !== true ) { |
|
| 7821 | // Convert with 1 or 2 converters accordingly |
|
| 7822 | response = conv ? conv( response ) : conv2( conv1(response) ); |
|
| 7823 | } |
|
| 7824 | } |
|
| 7825 | } |
|
| 7826 | return response; |
|
| 7827 | } |
|
| 7828 | ||
| 7829 | ||
| 7830 | ||
| @@ 6817-6888 (lines=72) @@ | ||
| 6814 | } |
|
| 6815 | ||
| 6816 | // Chain conversions given the request and the original response |
|
| 6817 | function ajaxConvert( s, response ) { |
|
| 6818 | ||
| 6819 | // Apply the dataFilter if provided |
|
| 6820 | if ( s.dataFilter ) { |
|
| 6821 | response = s.dataFilter( response, s.dataType ); |
|
| 6822 | } |
|
| 6823 | ||
| 6824 | var dataTypes = s.dataTypes, |
|
| 6825 | converters = s.converters, |
|
| 6826 | i, |
|
| 6827 | length = dataTypes.length, |
|
| 6828 | tmp, |
|
| 6829 | // Current and previous dataTypes |
|
| 6830 | current = dataTypes[ 0 ], |
|
| 6831 | prev, |
|
| 6832 | // Conversion expression |
|
| 6833 | conversion, |
|
| 6834 | // Conversion function |
|
| 6835 | conv, |
|
| 6836 | // Conversion functions (transitive conversion) |
|
| 6837 | conv1, |
|
| 6838 | conv2; |
|
| 6839 | ||
| 6840 | // For each dataType in the chain |
|
| 6841 | for( i = 1; i < length; i++ ) { |
|
| 6842 | ||
| 6843 | // Get the dataTypes |
|
| 6844 | prev = current; |
|
| 6845 | current = dataTypes[ i ]; |
|
| 6846 | ||
| 6847 | // If current is auto dataType, update it to prev |
|
| 6848 | if( current === "*" ) { |
|
| 6849 | current = prev; |
|
| 6850 | // If no auto and dataTypes are actually different |
|
| 6851 | } else if ( prev !== "*" && prev !== current ) { |
|
| 6852 | ||
| 6853 | // Get the converter |
|
| 6854 | conversion = prev + " " + current; |
|
| 6855 | conv = converters[ conversion ] || converters[ "* " + current ]; |
|
| 6856 | ||
| 6857 | // If there is no direct converter, search transitively |
|
| 6858 | if ( !conv ) { |
|
| 6859 | conv2 = undefined; |
|
| 6860 | for( conv1 in converters ) { |
|
| 6861 | tmp = conv1.split( " " ); |
|
| 6862 | if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { |
|
| 6863 | conv2 = converters[ tmp[1] + " " + current ]; |
|
| 6864 | if ( conv2 ) { |
|
| 6865 | conv1 = converters[ conv1 ]; |
|
| 6866 | if ( conv1 === true ) { |
|
| 6867 | conv = conv2; |
|
| 6868 | } else if ( conv2 === true ) { |
|
| 6869 | conv = conv1; |
|
| 6870 | } |
|
| 6871 | break; |
|
| 6872 | } |
|
| 6873 | } |
|
| 6874 | } |
|
| 6875 | } |
|
| 6876 | // If we found no converter, dispatch an error |
|
| 6877 | if ( !( conv || conv2 ) ) { |
|
| 6878 | jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); |
|
| 6879 | } |
|
| 6880 | // If found converter is not an equivalence |
|
| 6881 | if ( conv !== true ) { |
|
| 6882 | // Convert with 1 or 2 converters accordingly |
|
| 6883 | response = conv ? conv( response ) : conv2( conv1(response) ); |
|
| 6884 | } |
|
| 6885 | } |
|
| 6886 | } |
|
| 6887 | return response; |
|
| 6888 | } |
|
| 6889 | ||
| 6890 | ||
| 6891 | ||