// 名前空間
var CHK_iOS = {};

// iOS用
function callNativeApp(iosKey, jsonData) {
	console.log("callNativeApp called jsonData %s", jsonData);
	var result;
	try {
	  var key = iosKey;
	  var data = jsonData;
	  var payload = { key: key, data: data };
	  // payloadの形 {"type":"SJbridge","data":{"name":"abc","role":"dev"}}
	  // resにObjective-cからのレスポンスが返る
	  result = prompt(JSON.stringify(payload));
	  console.log(result);
	} catch (err) {
	  console.log("The native context does not exist yet");
	}
	return result;
}
  
CHK_iOS.getCachePath = function () {
	return callNativeApp(NATIVE_KEY_IOS.getCachePath, {});
};

CHK_iOS.getOperationListJson = function () {
	return JSON.parse(
		 callNativeApp(NATIVE_KEY_IOS.getOperationListJson, {})
	);
};

CHK_iOS.getOperationGroupMasterListJson = function () {
	return JSON.parse(
		callNativeApp(NATIVE_KEY_IOS.getOperationGroupMasterListJson, {})
	);
};

CHK_iOS.getOperationGroupMasterRelationListJson = function () {
	return JSON.parse(
		callNativeApp(NATIVE_KEY_IOS.getOperationGroupMasterRelationListJson, {})
	);
};

CHK_iOS.getPushMessageListJson = function () {
	return JSON.parse(
		callNativeApp(NATIVE_KEY_IOS.getPushMessageListJson, {})
	);
};

CHK_iOS.searchOperationList = function (searchKeyword, searchStartDate, searchEndDate, operationGroupMasterId) {
	return JSON.parse(
		callNativeApp(NATIVE_KEY_IOS.searchOperationList, {
			operationName: searchKeyword,
			operationStartDate: searchStartDate,
			operationEndDate: searchEndDate,
			operationGroupMasterId: operationGroupMasterId
		})
	);
};

CHK_iOS.getSortType = function () {
	return parseInt(callNativeApp(NATIVE_KEY_IOS.getSortType, {}));
}

CHK_iOS.getDashboardSettingJson = function () {
	return JSON.parse(
		callNativeApp(NATIVE_KEY_IOS.getDashboardSettingJson, {})
	);
};
