5 if ($x !~ /^-p/) { unshift(@ARGV, $x); }
7 my $injs = shift(@ARGV);
8 my $outjs = shift(@ARGV);
10 if ($injs eq '' or $outjs eq '') {
11 print "Please use this script like this: makemini.pl [-p] in.js out.js\n";
17 open(OUTJS
, ">$outjs");
24 if ($line =~ /^\/\
//) {
25 # Remove lines that aren't important: //\
26 $line = "" if ($line !~ /^\/\
/\\/);
27 $line = "\n//\\ THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL!\n\n" if ($line =~ /\/\
/\\mini/);
31 $line =~ s/, /,/g unless ($line =~ /'\], '/); # ,{sp} -> ,
32 $line =~ s/; /;/g; # ;{sp} -> ;
33 $line =~ s/ = /=/g; # {sp}={sp} -> =
34 $line =~ s/ == /==/g; # {sp}=={sp} -> ==
35 $line =~ s/ < /</g; # {sp}<{sp} -> <
36 $line =~ s/ > />/g; # {sp}>{sp} -> >
37 $line =~ s/ & /&/g; # {sp}&{sp} -> &
38 $line =~ s/ \| /\|/g; # {sp}|{sp} -> |
39 $line =~ s/ <= /<=/g; # {sp}<={sp} -> <=
40 $line =~ s/ >= />=/g; # {sp}>={sp} -> >=
41 $line =~ s/ \+ /\+/g; # {sp}+{sp} -> +
42 $line =~ s/ - /-/g; # {sp}-{sp} -> -
44 $line =~ s/ \|\| /\|\|/g; # {sp}||{sp} -> ||
45 $line =~ s/ && /&&/g; # {sp}&&{sp} -> &&
46 $line =~ s/ \? /\?/g; # {sp?{sp} -> ?
47 $line =~ s/ \: /\:/g; # {sp}:{sp} -> :
48 $line =~ s/ != /!=/g; # {sp}!={sp} -> !=
49 $line =~ s/ += /+=/g; # {sp}+={sp} -> +=
50 $line =~ s/ -= /-=/g; # {sp}-={sp} -> -=
51 $line =~ s/ \*= /\*=/g; # {sp}*={sp} -> *=
52 $line =~ s/ \|= /\|=/g; # {sp}|={sp} -> |=
53 $line =~ s/ \^= /\^=/g; # {sp}^={sp} -> ^=
54 $line =~ s/= /=/g; # ={sp} -> =
55 $line =~ s/ =/=/g; # {sp}= -> =
61 $line =~ s/\/\/(.*)$//g if ($line !~ /\/\
/-->(.*)$/ && $line !~ /http:\/\
/(.*)$/); # remove trailing comments unless its part of a javascript insert or web address
62 $line = '' if $line =~ /^[\n|\/\
/]/; # skip blank lines or any line starting with //
66 $line =~ s/(.+)\s+(.+)/$1 $2/g;
67 $line =~ s/\{ (\w)/\{$1/g;
68 $line =~ s/\) (\w)/\)$1/g;
69 $line =~ s/\) var/\)var/g;
70 $line =~ s/[ ]+\(/\(/g;
71 $line =~ s/\) \{/\)\{/g;
72 $line =~ s/\} else/\}else/g;
73 $line =~ s/else \{/else\{/g;
74 if ($line =~ /^\}$/) {
75 if ($output =~ /;$/) {
78 $output = substr($output,0,length($output)-1) . "}";
84 $output .= $line if ($line ne '');
85 $output .= "\n" unless ($line =~ /;\n*$/ or $line =~ /{\n*$/);
88 $output =~ s/\n+/\n/g;
89 $output .= "}\n" if ($doPlugin && $output !~ /\}\s+$/);
90 # replace multiple ;var xx to ,xx if the line contains var
91 @lines = split(/^/,$output);
92 foreach $line (@lines) {
93 $line =~ s/;var /,/g if ($line =~ /^\s*var / && $line !~ /(turn|ment|Capture\(\)|Div'\)|1000\));var /);