var CHK_MessageDetail = {};

msgMap.messageDetailTopTitle = {ja:"プッシュメッセージ詳細", ko:"푸시 메시지 상세", en:"Push message details"};
msgMap.messageDetailHeaderTitle = {ja:"メッセージ詳細", ko:"메시지 상세", en:"Message Details"};
msgMap.messageDetailContentTitle = {ja:"件名", ko:"내용", en:"Content"};
msgMap.messageDetailSendDateTitle = {ja:"日時", ko:"일시", en:"Send Date"};
msgMap.messageDetailWorkingNameTitle = {ja:"作業名", ko:"작업명", en:"Operation Name"};
msgMap.messageDetailSenderTitle = {ja:"送信者", ko:"송신자", en:"Sender"};

CHK_MessageDetail.init = function() {
    CHK.initCommon();
    $("#footer").load("main-footer.html", function() {
        CHK_Footer.activeDashboardBottomNav();
    });
    var urlParam = CHK.getUrlParameter();
    if (typeof urlParam !== 'object' || typeof urlParam.pushMessageId === 'undefined') {
		return;
	}
    let messageId = urlParam.pushMessageId;
    CHK.loadJson(CHK.jsonPath.pushMessageList, function (json) {
        var messageList = json.pushMessageList;
        if (typeof messageList !== 'object') {
            return;
        }
        for (var i = 0; i < messageList.length; i++) {
            let message = messageList[i];
            if (message.pushMessageId == messageId) {
                CHK_MessageDetail.showMessage(message);
                if (!message.readingFlg) {
                    //update reading flag
                    var param = {};
                    param.cmd = CHK.getCommand('actionPushMessage');
                    param.pushMessageId = messageId;
                    param.pushMessageAction = 'read';
                    CHK.sendABookCheckApi(param);
                }
                break;
            }
        }
    });
}

CHK_MessageDetail.showMessage = function(message) {
    $('#messageDetail #message').text(message.pushMessage);
    var mDate = message.pushSendDate;
    if (CHK.isAndroid) 
    {
        mDate = CHK.getFormatDate(new Date(message.pushSendDate));
    }
    $('#messageDetail #sendDate').text(mDate);
    $('#messageDetail #operationName').text(message.operationName);
    $('#messageDetail #sender').text(message.pushSendLoginId);
}

CHK_MessageDetail.goBack = function() {
    history.back();
}
