#!/bin/sh
DIR=`dirname $0`/..

TARGET0=""
TARGET1=""
TARGET2=""

if [ $# -eq 1 ]; then
  TARGET0=$1
else
  TARGET0="abvw"
fi

# abvw/js/*
#TARGET1='bookmark.js contentsearch.js contentview.js contentview_Gomu.js contentview_Maker.js contentview_Marking.js contentview_Memo.js contentview_Paint.js contentview_Pen.js contentview_PopupText.js detail.js header.js history.js home.js login.js settings.js'
if [ "$TARGET0" = "abvw" ]; then
   TARGET1='Limit_Access_Content.js bookmark.js contentsearch.js contentview.js contentview_3d.js contentview_Anket.js contentview_CallApi.js contentview_ContentTypeNone.js contentview_CreateObjects.js contentview_Events.js contentview_General.js contentview_GetData.js contentview_Gomu.js contentview_ImagePreview.js contentview_InitObjects.js contentview_Maker.js contentview_Marking.js contentview_Memo.js contentview_Paint.js contentview_Pen.js contentview_PopupText.js detail.js header.js history.js home.js login.js settings.js contentview_FileSystem.js'
else
   TARGET1='contentview.js contentview_3d.js contentview_Anket.js contentview_CallApi.js contentview_ContentTypeNone.js contentview_CreateObjects.js contentview_Events.js contentview_General.js contentview_GetData.js contentview_ImagePreview.js contentview_InitObjects.js contentview_PopupText.js contentview_initDefautValue.js'
fi

# abvw/common/js
#TARGET2='avweb.js common.js i18n.js screenLock.js slideshow.js textObject.js zoomDetector.js'
if [ "$TARGET0" = "abvw" ]; then
   TARGET2='avweb.js common.js i18n.js screenLock.js script.js tab.js textObject.js zoomDetector.js'
else
   TARGET2='avweb.js common.js i18n.js script.js textObject.js zoomDetector.js'
fi

OBFUSCATE_EXECUTABLE="$DIR/packer/jsPacker.pl -e10"

for f in $TARGET1
do
		ORG=$DIR/$TARGET0/js/$f
		TARGET=$DIR/ob/abvw/js/$f
		$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done

for f in $TARGET2
do
		ORG=$DIR/$TARGET0/common/js/$f
		TARGET=$DIR/ob/abvw/common/js/$f
		$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done
