Ticket #916: jquery.diff
| File jquery.diff, 4.5 KB (added by anonymous, 6 years ago) |
|---|
-
.js
old new 7 7 * Dual licensed under the MIT (MIT-LICENSE.txt) 8 8 * and GPL (GPL-LICENSE.txt) licenses. 9 9 * 10 * $Date: 2007 -01-22 00:27:54 -0500 (Mon, 22 Jan 2007)$10 * $Date: 2007/02/02 19:06:52 $ 11 11 * $Rev: 1153 $ 12 12 */ 13 13 … … 1857 1857 data: params, 1858 1858 ifModified: ifModified, 1859 1859 complete: function(res, status){ 1860 if ( status == "success" || !ifModified && status == "notmodified" )1860 if ( status.split(" ")[0] != "error" || !ifModified && status == "notmodified" ) { 1861 1861 // Inject the HTML into all the matched elements 1862 self.attr("innerHTML", res.responseText) 1862 self.attr("innerHTML", res.responseText); 1863 1863 // Execute all the scripts inside of the newly-injected HTML 1864 .evalScripts() 1864 //if(jQuery.browser.msie) 1865 jQuery.evalInlineScripts(res.responseText); 1866 //else 1867 // self.evalScripts(); 1865 1868 // Execute callback 1866 .each( callback, [res.responseText, status, res] );1867 else1869 self.each( callback, [res.responseText, status, res] ); 1870 } else 1868 1871 callback.apply( self, [res.responseText, status, res] ); 1869 1872 } 1870 1873 }); … … 2016 2019 requestDone = true; 2017 2020 var status; 2018 2021 try { 2019 status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ? 2020 s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error"; 2022 status = jQuery.httpSuccess( xml ); 2023 if(status.split(" ")[0] != "error" && 2024 isTimeout != "timeout" && 2025 s.ifModified && 2026 jQuery.httpNotModified( xml, s.url )) { 2027 status = "redirect 304"; 2028 } 2021 2029 // Make sure that the request was successful or notmodified 2022 if ( status != "error" ) {2030 if ( status.split(" ")[0] != "error" ) { 2023 2031 // Cache Last-Modified header, if ifModified mode. 2024 2032 var modRes; 2025 2033 try { … … 2042 2050 } else 2043 2051 jQuery.handleError(s, xml, status); 2044 2052 } catch(e) { 2045 status = "error ";2053 status = "error exception"; 2046 2054 jQuery.handleError(s, xml, status, e); 2047 2055 } 2048 2056 … … 2102 2110 2103 2111 // Fire the global callback 2104 2112 if ( s.global ) 2105 jQuery.event.trigger( "ajaxError", [xml, s, e ] );2113 jQuery.event.trigger( "ajaxError", [xml, s, e, status] ); 2106 2114 }, 2107 2115 2108 2116 // Counter for holding the number of active queries … … 2110 2118 2111 2119 // Determines if an XMLHttpRequest was successful or not 2112 2120 httpSuccess: function( r ) { 2121 var status; 2113 2122 try { 2114 return !r.status && location.protocol == "file:" || 2115 ( r.status >= 200 && r.status < 300 ) || r.status == 304 || 2116 jQuery.browser.safari && r.status == undefined; 2117 } catch(e){} 2118 return false; 2123 var status_code = r.status; 2124 status = "error unknow"; 2125 if(!r.status && location.protocol == "file:" || 2126 jQuery.browser.safari && r.status == undefined) { 2127 status = "success" 2128 } else if(status_code >= 600) { 2129 if(status_code == 12029 || status_code == 12152) { 2130 status = "error connection"; 2131 } else if(status_code == 1223) { 2132 status = "success 204"; 2133 } 2134 } else if(status_code >= 200 && status_code < 300) { 2135 status = "success " + status_code; 2136 } else if(status_code >= 300 && status_code < 400) { 2137 status = "redirect " + status_code; 2138 } else if(status_code >= 400 && status_code < 600) { 2139 status = "error " + status_code; 2140 } 2141 } catch(e){ 2142 status = "error connection"; 2143 } 2144 return status; 2119 2145 }, 2120 2146 2121 2147 // Determines if an XMLHttpRequest returns NotModified … … 2195 2221 window.setTimeout( data, 0 ); 2196 2222 else 2197 2223 eval.call( window, data ); 2198 } 2199 2224 }, 2225 2226 evalInlineScripts: function(data) { 2227 var frags = []; 2228 2229 while((sts = data.search(/<[ ]*script(>|[^>]*>)/ig)) >= 0) { 2230 data = data.substring(sts); 2231 var sub = data.substring(0, data.search(">")); 2232 var url, i; 2233 2234 if(sub.search(/src=/i) >= 0) { 2235 url = sub.replace(/.*[\n\t\r ]src=("[^"]+"|'[^']+').*/i, "$1"); // "); 2236 src = src.substring(1, src.length - 1); 2237 url = data.substring(7); 2238 jQuery.getScript(url); 2239 } else { 2240 var i; 2241 if(data.search(/<[ ]*script(>|[^>]*>)[\n\t\r ]*<!--/i) != 0) { 2242 data = data.substring(data.search(">") + 1); 2243 i = data.search(/<\/[ ]*script[ ]*>/i); 2244 } else { 2245 data = data.substring(data.search("<!--") + 4); 2246 i = data.search("-->"); 2247 } 2248 jQuery.globalEval(data.substring(0, i)); 2249 data = data.substring(i); 2250 } 2251 } 2252 } 2253 2200 2254 }); 2201 2255 }
