1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-30 00:59:48 +02:00

builder app improvements and bookmarklet

JSMin.php : + YUI and IE conditional comment preserving
This commit is contained in:
Steve Clay
2008-09-06 22:35:22 +00:00
parent 7bb535d79c
commit 9a5a67dfaf
11 changed files with 189 additions and 70 deletions

View File

@@ -32,4 +32,18 @@ if (is.ua.indexOf('opera') >= 0) {
if (is.ua.indexOf('gecko') >= 0) {
is.ie = is.ns = false;
is.gecko = true;
}
}
/*@cc_on
/*@if (@_win32)
document.write("OS is 32-bit, browser is IE.");
@else @*/
document.write("Browser is not IE (ie: is Firefox) or Browser is not 32 bit IE.");
/*@end
@*/
//@cc_on/*
alert("Hello !IE browser");
//@cc_on*/

View File

@@ -1,4 +1,3 @@
/* is.js
(c) 2001 Douglas Crockford
@@ -9,4 +8,9 @@ var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaE
* preserve this comment, too
*/
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}/*@cc_on
/*@if (@_win32)
document.write("OS is 32-bit, browser is IE.");
@else @*/document.write("Browser is not IE (ie: is Firefox) or Browser is not 32 bit IE.");/*@end
@*///@cc_on/*
alert("Hello !IE browser");//@cc_on*/

View File

@@ -1,3 +0,0 @@
var is={ie:navigator.appName=='Microsoft Internet Explorer',java:navigator.javaEnabled(),ns:navigator.appName=='Netscape',ua:navigator.userAgent.toLowerCase(),version:parseFloat(navigator.appVersion.substr(21))||parseFloat(navigator.appVersion),win:navigator.platform=='Win32'}
is.mac=is.ua.indexOf('mac')>=0;if(is.ua.indexOf('opera')>=0){is.ie=is.ns=false;is.opera=true;}
if(is.ua.indexOf('gecko')>=0){is.ie=is.ns=false;is.gecko=true;}

View File

@@ -243,3 +243,18 @@
/* 33 */ is.ie = is.ns = false;
/* 34 */ is.gecko = true;
/* 35 */ }
/* 36 */
/* 37 */ /*@cc_on
/* 38 *| /*@if (@_win32)
/* 39 *| document.write("OS is 32-bit, browser is IE.");
/* 40 *| @else @*/
/* 41 */ document.write("Browser is not IE (ie: is Firefox) or Browser is not 32 bit IE.");
/* 42 */ /*@end
/* 43 *| @*/
/* 44 */
/* 45 */ //@cc_on/*
/* 46 *|
/* 47 *| alert("Hello !IE browser");
/* 48 *|
/* 49 *| //@cc_on*/
/* 50 */

View File

@@ -18,20 +18,6 @@ function test_Javascript()
echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
}
//$src = file_get_contents($thisDir . '/_test_files/js/before.js');
$minExpected = file_get_contents($thisDir . '/_test_files/js/before_noComments.min.js');
$minOutput = Minify_Javascript::minify($src, array(
'preserveComments' => false
));
$passed = assertTrue($minExpected == $minOutput, 'Minify_Javascript');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " .strlen($minOutput). " bytes\n\n{$minOutput}\n\n";
echo "---Expected: " .strlen($minExpected). " bytes\n\n{$minExpected}\n\n";
echo "---Source: " .strlen($src). " bytes\n\n{$src}\n\n\n";
}
}
test_Javascript();