|
| 1 | +/* |
| 2 | +<?php |
| 3 | +// if php is available, close the comment so PHP can echo the appropriate JS |
| 4 | +echo "*" . "/"; |
| 5 | + |
| 6 | +// initialize vars |
| 7 | +$output = ""; |
| 8 | +$version = ""; |
| 9 | + |
| 10 | +// extract vars from referrer to determine version |
| 11 | +if(isset($_SERVER['HTTP_REFERER'])){ |
| 12 | + $referrer = $_SERVER['HTTP_REFERER']; |
| 13 | + $referrer_query_string = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY ); |
| 14 | + parse_str($referrer_query_string, $referrer_params); |
| 15 | + |
| 16 | + if(isset($referrer_params['jquery'])){ |
| 17 | + $version = $referrer_params['jquery']; |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +// load up built versions of jquery |
| 22 | +if( $version === "min" ) { |
| 23 | + $output = @file_get_contents("../../dist/jquery.min.js"); |
| 24 | +}elseif( $version === "dist" ) { |
| 25 | + $output = @file_get_contents("../../dist/jquery.js"); |
| 26 | +}elseif( ctype_digit( substr( $version, 0, 1 )) || $version === "git" ) { |
| 27 | + $output = "document.write('<script src=\"http://code.jquery.com/jquery-" . $version . ".js\"><'+'/script>');"; |
| 28 | +} |
| 29 | + |
| 30 | +// the concatenated version of the the src files is both the default and the fallback |
| 31 | +// because it does not require you to "make" jquery for it to update |
| 32 | +if( $output === "" ) { |
| 33 | + $files = array( |
| 34 | + "intro", |
| 35 | + "core", |
| 36 | + "callbacks", |
| 37 | + "deferred", |
| 38 | + "support", |
| 39 | + "data", |
| 40 | + "queue", |
| 41 | + "attributes", |
| 42 | + "event", |
| 43 | + "sizzle/sizzle", |
| 44 | + "sizzle-jquery", |
| 45 | + "traversing", |
| 46 | + "manipulation", |
| 47 | + "css", |
| 48 | + "ajax", |
| 49 | + "ajax/jsonp", |
| 50 | + "ajax/script", |
| 51 | + "ajax/xhr", |
| 52 | + "effects", |
| 53 | + "offset", |
| 54 | + "dimensions", |
| 55 | + "exports", |
| 56 | + "outro" |
| 57 | + ); |
| 58 | + |
| 59 | + foreach ( $files as $file ) { |
| 60 | + $output .= file_get_contents( "../../src/" . $file . ".js" ); |
| 61 | + } |
| 62 | + |
| 63 | + $output = str_replace( "(function( jQuery ) {", "", $output ); |
| 64 | + $output = str_replace( "})( jQuery );", "", $output ); |
| 65 | +} |
| 66 | + |
| 67 | +echo $output; |
| 68 | +die(); |
| 69 | +?> |
| 70 | +*/ |
| 71 | + |
| 72 | +// javascript fallback using src files in case this is not run on a PHP server! |
| 73 | +var baseURL = document.location.href.replace( /\/test\/.+/, "/"), |
| 74 | + files = [ |
| 75 | + "core", |
| 76 | + "callbacks", |
| 77 | + "deferred", |
| 78 | + "support", |
| 79 | + "data", |
| 80 | + "queue", |
| 81 | + "attributes", |
| 82 | + "event", |
| 83 | + "sizzle/sizzle", |
| 84 | + "sizzle-jquery", |
| 85 | + "traversing", |
| 86 | + "manipulation", |
| 87 | + "css", |
| 88 | + "ajax", |
| 89 | + "ajax/jsonp", |
| 90 | + "ajax/script", |
| 91 | + "ajax/xhr", |
| 92 | + "effects", |
| 93 | + "offset", |
| 94 | + "dimensions", |
| 95 | + "exports" |
| 96 | + ], |
| 97 | + len = files.length, |
| 98 | + i = 0; |
| 99 | + |
| 100 | +for ( ; i < len; i++ ) { |
| 101 | + document.write("<script src=\"" + baseURL + "src/" + files[ i ] + ".js\"><"+"/script>"); |
| 102 | +} |
0 commit comments