#!/bin/sh
if [ -z "$1" ]; then
        echo "Usage: `basename $0` <input> <output>"
	echo "Compresses the javascript file <input> and writes the compressed javascript to <output>"
        exit 1
fi

jarpath=`dirname $0`/custom_rhino.jar

cat $1 | sed -e "s/^\(\/\*@\|@end\)\(.*\)/window._iecond='\1\2';/g" >/tmp/tmp.js
java -jar $jarpath -c /tmp/tmp.js >/tmp/compressed.js
cat /tmp/compressed.js | sed -e "s/window._iecond=\"\(.*\)\";/\1/g" >$2
