1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link href="http://yui.yahooapis.com/3.4.0/build/cssreset/cssreset.css" type="text/css" rel="stylesheet">
<link href="http://yui.yahooapis.com/3.4.0/build/cssbase/cssbase.css" type="text/css" rel="stylesheet">
<style>
body {
padding:10px;
}
pre {
width:90%;
padding:10px;
overflow:auto;
background-color:#eee;
}
#testFile {
margin:2em;
}
#notsupportedmsg.hidden {
display:none;
}
#notsupportedmsg {
color:red;
}
</style>
<script src="../ports/js/cssmin.js"></script>
</head>
<body>
<h1>Use This Page to Debug cssmin.js</h1>
<h1 id="notsupportedmsg" class="hidden">Your browser does not support the local file access apis used by this page.</h1>
<p>Select a css file to compress. You can then step through the cssmin.js implementation using your browser's script debugger.</p>
<p><input type="file" id="testFile"></p>
<h2>Compressed</h2>
<pre id="out"></pre>
<h2>Original</h2>
<pre id="in"></pre>
<script>
(function() {
var dumpContents = function(node, str) {
node.innerHTML = "";
node.appendChild(document.createTextNode(str));
},
testFile,
changeHandler;
if (window.File && window.FileReader) {
testFile = document.getElementById('testFile');
changeHandler = function(e) {
var file = this.files[0],
fr = new FileReader(),
input = document.getElementById("in"),
output = document.getElementById("out"),
contents;
fr.onload = function(e) {
dumpContents(input, e.target.result);
var min = YAHOO.compressor.cssmin(e.target.result);
dumpContents(output, min);
};
fr.readAsText(file, "utf-8");
}
if (testFile.addEventListener) {
testFile.addEventListener('change', changeHandler, false);
} else {
testFile.attachEvent('onChange', changeHandler);
}
} else {
document.getElementById("notsupportedmsg").removeClass("hidden");
}
})();
</script>
</body>
</html>
|