eval('D=document;T="textarea";D.C=D.createElement;I=D.C(T);O=D.C(T);M=D.C("input");M.type="button";B=D.body;B.A=B.appendChild;E=-1;V="\\n";Z=" ";f=0@P(a){#a.match(/[\\w$\\\\]/)||a.charCodeAt(0)>126}I.style.width=O.style.width="99%"@F(){X=L;L=E;`!~X)X=Y.length<G?E:Y[G++];#X>=Z||X==V||!~X?X:XU\\r"?V:Z}B.A(I)@N(){X=F();`XU/"){L=F();`LU/")for(;;){X=F();`X<=V)#X}`LU*")for(H=F();H=F();){`HU*"){L=F();`LU/"){F();#Z}}`!~H)throw""}}#X}B.A(M)@Q(a){`a<2)R+=A;`a<3){A=B;`AU\'"||A==\'"\')for(;;){R+=A;A=F();`A==B)break;`AU\\\\"){R+=A;A=F()}`!~A)throw""}}`a<4){B=N();`BU/"&&"(,=:[!&|?{};\\n".indexOf(A)>E){for(R+=A+B;;){A=F();`AU/")break;`AU\\\\"){R+=A;A=F()}`!~A)throw"";R+=A}B=N()}}}M.value="Minify"@S(){`!f){B.A(O);f=1}G=0;L=E;R="";A=V;Y=I.value;for(Q(3);!!~A;)A==Z?P(B)?Q(1):Q(2):A==V?"{[(+-".indexOf(B)>E?Q(1):B==Z?Q(3):P(B)?Q(1):Q(2):B==Z?P(A)?Q(1):Q(3):B==V?"}])+-\'\\"".indexOf(A)>E?Q(1):P(A)?Q(1):Q(3):Q(1);O.value=R}M.onclick=S'.replace(/@/g,";function ").replace(/#/g,"return ").replace(/`/g,"if(").replace(/U/g,'=="'))
ZXZhbCgnRD1kb2N1bWVudDtUPSJ0ZXh0YXJlYSI7RC5DPUQuY3JlYXRlRWxlbWVudDtJPUQuQyhUKTtPPUQuQyhUKTtNPUQuQygiaW5wdXQiKTtNLnR5cGU9ImJ1dHRvbiI7Qj1ELmJvZHk7Qi5BPUIuYXBwZW5kQ2hpbGQ7RT0tMTtWPSJcXG4iO1o9IiAiO2Y9MEBQKGEpeyNhLm1hdGNoKC9bXFx3JFxcXFxdLyl8fGEuY2hhckNv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IpLnJlcGxhY2UoL2AvZywiaWYoIikucmVwbGFjZSgvVS9nLCc9PSInKSk=
/*
Author: roylory
This is the JavaScript version of the famous jsmin.c by Douglas Crockford.
I made this for the submission to js1k event. (js1k.com)
*/
/* jsmin.c
2008-08-03
Copyright (c) 2002 Douglas Crockford (www.crockford.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var inTbx = document.createElement("textarea");
var outTbx = document.createElement("textarea");
var minifyBtn = document.createElement("input");
var theA;
var theB;
var EOF = -1;
var theLookahead = EOF;
var getcIndex = 0;
//function isAlphanum(c) { return ((c > 96 && c < 123) || (c > 47 && c < 58) || (c > 64 && c < 91) || c == 95 || c == 36 || c == 92 || c > 126); }
function isAlphanum(c) {
return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c == '\\' || c > 126);
}
function getc() {
if (inTbx.value.length < getcIndex)
return EOF;
return inTbx.value.charAt(getcIndex++);
}
function get() {
var c = theLookahead;
theLookahead = EOF;
if (c == EOF) {
c = getc();
}
if (c >= ' ' || c == '\n' || c == EOF) {
return c;
}
if (c == '\r') {
return '\n';
}
return ' ';
}
function peek() {
theLookahead = get();
return theLookahead;
}
function next() {
var c = get();
if (c == '/') {
switch (peek()) {
case '/':
for (;;) {
c = get();
if (c <= '\n') {
return c;
}
}
case '*':
get();
for (;;) {
switch (get()) {
case '*':
if (peek() == '/') {
get();
return ' ';
}
break;
case EOF:
throw "";
}
}
default:
return c;
}
}
return c;
}
function putc(c) {
outTbx.value += c;
}
function action(d) {
switch (d) {
case 1:
putc(theA);
case 2:
theA = theB;
if (theA == '\'' || theA == '"') {
for (; ; ) {
putc(theA);
theA = get();
if (theA == theB) {
break;
}
if (theA == '\\') {
putc(theA);
theA = get();
}
if (theA == EOF) {
throw "";
}
}
}
case 3:
theB = next();
if (theB == '/' && (theA == '(' || theA == ',' || theA == '=' ||
theA == ':' || theA == '[' || theA == '!' ||
theA == '&' || theA == '|' || theA == '?' ||
theA == '{' || theA == '}' || theA == ';' ||
theA == '\n')) {
putc(theA);
putc(theB);
for (; ; ) {
theA = get();
if (theA == '/') {
break;
}
if (theA == '\\') {
putc(theA, stdout);
theA = get();
}
if (theA == EOF) {
throw "";
}
putc(theA);
}
theB = next();
}
}
}
function jsmin() {
try
{
theA = '\n';
action(3);
while (theA != EOF) {
switch (theA) {
case ' ':
if (isAlphanum(theB)) {
action(1);
} else {
action(2);
}
break;
case '\n':
switch (theB) {
case '{':
case '[':
case '(':
case '+':
case '-':
action(1);
break;
case ' ':
action(3);
break;
default:
if (isAlphanum(theB)) {
action(1);
} else {
action(2);
}
}
break;
default:
switch (theB) {
case ' ':
if (isAlphanum(theA)) {
action(1);
break;
}
action(3);
break;
case '\n':
switch (theA) {
case '}':
case ']':
case ')':
case '+':
case '-':
case '"':
case '\'':
action(1);
break;
default:
if (isAlphanum(theA)) {
action(1);
} else {
action(3);
}
}
break;
default:
action(1);
break;
}
}
}
}
catch(e)
{
outTbx.value = "Error!";
}
}
minifyBtn.type = "button";
minifyBtn.value = "minify";
inTbx.style.width = "99%";
outTbx.style.width = "99%";
inTbx.value = "Paste your JavaScript code here.";
minifyBtn.setAttribute("onclick", "outTbx.value='';jsmin();");
document.body.appendChild(inTbx);
document.body.appendChild(minifyBtn);
document.body.appendChild(outTbx);