#!/bin/sh
#

#DIR=`dirname $0`/..
DIR="$(dirname $(realpath $0))/.."

TARGET0=""
TARGET1=""
TARGET2=""
# ABookCheck WEB viewer
# check_web
TARGET11=""
TARGET12=""
# check_webpreview
TARGET21=""
TARGET22=""



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

# abvw/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 share.js stview.js contentview_Streaming.js contentview_Getits.js'
elif [ "$TARGET0" = "check_web" ]; then
# ABookCheck web/abweb/js/*/*.js
	TARGET11='pushMessageDetail/pushMessageDetail.js reportForm/reportForm.js dashboard/dashboard.js sendMessage/sendMessage.js pickup/pickup.js agreementToTerms/agreementToTerms.js topPage/topPage.js operationSelect/operationSelect.js notificationContent/notificationContent.js operationList/operationList.js setting/settings.js pdfPrint/pdfPrint.js dashboardSetting/dashboardSetting.js reportList/reportList.js login/login.js pushMessageList/pushMessageList.js template/template.js fileSelect/fileSelect.js '
elif [ "$TARGET0" = "check_webpreview" ]; then
# ABookCheck webpreview/abvw/js/*.js
	TARGET21='contentview_Paint.js contentview_ContentTypeNone.js contentview_Marking.js contentview_Pen.js contentview_Getits.js stview.js history.js contentview_ImagePreview.js contentpreview.js contentview_General.js contentview_Streaming.js Limit_Access_Content.js share.js contentview_Gomu.js contentview_InitObjects.js contentview_Quiz.js login.js contentview_3d.js detail.js contentview_Anket.js contentview_CallApi.js contentview.js contentview_PopupText.js home.js contentview_OpenUri.js contentview_Exam.js contentview_GetData.js contentview_Events.js contentview_CreateObjects.js header.js bookmark.js contentview_Maker.js contentview_Memo.js settings.js contentsearch.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
if [ "$TARGET0" = "abvw" ]; then
   TARGET2='avweb.js common.js i18n.js screenLock.js script.js tab.js textObject.js zoomDetector.js'
elif [ "$TARGET0" = "check_web" ]; then
# ABookCheck web/abweb/common/js/*.js
	TARGET12='validation.js event.js common.js i18n.js header.js constant.js jquery/jquery.toastmessage.js '
elif [ "$TARGET0" = "check_webpreview" ]; then
# ABookCheck webpreview/abvw/common/js/*.js
	TARGET22='jquery.powertip.js html2canvas.js zoomDetector.js scrolltopcontrol.js script.js tab.js jquery.cookie.js htmlparser.js jquery.treeview.js screenLock.js common.js i18n.js jquery.toastmessage.js thickbox.js uuid.js function.js avweb.js gotop.js textObject.js jquery.treeview.edit.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

###
# ABookCheck web
#
for f in ${TARGET11}
do
	ORG=$DIR/abweb/js/$f
	TARGET=$DIR/ob/abweb/js/$f
	$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done

for f in ${TARGET12}
do
	ORG=$DIR/abweb/common/js/$f
	TARGET=$DIR/ob/abweb/common/js/$f
	$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done

###
# ABookCheck webpreview
#
for f in ${TARGET21}
do
	ORG=$DIR/abvw/js/$f
	TARGET=$DIR/ob/abvw/js/$f
	$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done

for f in ${TARGET22}
do
	ORG=$DIR/abvw/common/js/$f
	TARGET=$DIR/ob/abvw/common/js/$f
	$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done



# EOF