You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
817 B

#!/usr/bin/perl
# Mangle names in SimpleAutocomplete code for better compression
use strict;
my $output = 'hinter.min.js';
my %whitelist = map { $_ => 1 } qw(input remove replaceItems show hide onChange selectItem options);
my %var = ();
my @names = 'a'..'ba';
local $/ = undef;
open FD, "hinter.js";
open OFD, "| yui-compressor --type js -o $output";
while(<FD>)
{
s/(this|self|SimpleAutocomplete(?:\.prototype)?)\.([a-zA-Z0-9_]+)/$1 . '.' . ($whitelist{$2} ? $2 : ($var{$2} ||= shift @names))/egs;
print OFD $_;
}
close FD;
close OFD;
open FD, "+<", $output;
$_ = <FD>;
seek FD, 0, 0;
print FD "// (c) Vitaliy Filippov 2011-2015
// \@license MPL 2.0 http://www.mozilla.org/MPL/2.0/
// http://yourcmc.ru/wiki/SimpleAutocomplete
$_";
close FD;
print "Compressed SimpleAutocomplete written to $output\n";