#!/usr/bin/perl -w

#
#   Crush puny Javascript includes so that they can be assimilated netwise
#   at double plus speed.
#
#   Afternoon <noon at aftnn.org>, 2003
#

use strict;
use vars qw($i $j $l @qs $quotedString $quotedStringPost);

$i = "";

while (<>) {
    $l = $_;
    $l =~ s/\/\/.*$//;
    $i .= $l;
}

$i =~ s/\/\*.*?\*\///sg;
$i =~ s/\\"/ESCAPEDQUOTE______/sg;
$i =~ s/\\'/ESCAPEDSINGELL______/sg;

$i =~ s/(function|new|else|return|var) (\w)/$1____SAPCEoo$2/sg;

@qs = split(/"/, $i);

for ($j=1; $j<$#qs; $j=$j+2) {
    $quotedStringPost = $qs[$j];
    $quotedString = quotemeta($qs[$j]);

    $quotedStringPost =~ s/ /____SAPCEoo/sg;
    $quotedStringPost =~ s/\t/__EROFACTORKESTREL__/sg;
    $quotedStringPost =~ s/\n/_EROFACTORDOGSBODY_____/sg;
    $i =~ s/$quotedString/$quotedStringPost/sg;
}

$i =~ s/\s//sg;

$i =~ s/(}+)([^;])/$1;$2/sg;

$i =~ s/____SAPCEoo/ /sg;
$i =~ s/__EROFACTORKESTREL__/\t/sg;
$i =~ s/_EROFACTORDOGSBODY_____/\n/sg;

$i =~ s/ESCAPEDSINGELL______/\\'/g;
$i =~ s/ESCAPEDQUOTE______/\\"/g;

$i =~ s/\};else/\}else/g;

print $i;
		
aftnn.orgcontentcode → jspack