Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / admin / overlib / makemini.pl
blob3d29ebbeb6883a545071b30ffed328c401e97c68
1 #!/usr/bin/perl
3 my $doPlugin = 0;
4 my $x = shift(@ARGV);
5 if ($x !~ /^-p/) { unshift(@ARGV, $x); }
6 else { $doPlugin=1; }
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";
12 exit(0);
16 open(INJS, $injs);
17 open(OUTJS, ">$outjs");
19 my $output = '';
21 while (<INJS>) {
22 my $line = $_;
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/);
28 } else {
29 chop $line;
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} -> -
43 $line =~ s/ \/ /\//g;
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}= -> =
56 $line =~ s/\+ /\+/g;
57 $line =~ s/ \+/\+/g;
58 $line =~ s/- /-/g;
59 $line =~ s/ -/-/g;
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 //
64 $line =~ s/^\s+//g;
65 $line =~ s/\s+$//g;
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 =~ /;$/) {
76 $output .= "}";
77 } else {
78 $output = substr($output,0,length($output)-1) . "}";
80 $line = '';
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 /);
94 print OUTJS $line;