<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	layout:decorator="mob/common/layout/AppLayoutMob">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--
 *******************************************************************************
 * @source  : NoticeFormMob.html
 * @desc    : 알림함 Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2021 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2021.05.21   jsshin     최초 작성
 *******************************************************************************
 -->
<body>
<th:block layout:fragment="content">
<main class="container app-only">
	<!-- ★ 컨텐츠 시작 -->
	<section id="notice" class="notice nodata">
	</section>
	<!-- ★ 컨텐츠 종료 -->
</main>
<script th:inline="javascript">


	$(document).ready(function(){
		$('#htopTitle').text('알림함');
			if (_isApp === 'true') {
				if (_osType === 'A') {
					 window.style24.getPushList();
				} else if (_osType === 'I') {
					window.webkit.messageHandlers.getPushList.postMessage({"dummy":"dummy"});
				}
			} else {
				$('#notice').addClass('nodata');
			}
	});

	var pushListInfo = function (pushList) {
		let orgPushList;
		if (_osType === 'I') { //IOS는 앱에서 BASE64로 인코딩 한후 전달 한다. 아래와같이 해줘야 한글 안깨짐
  			orgPushList = decodeURIComponent(escape(window.atob(pushList)));
		} else if (_osType === 'A') {
			orgPushList = pushList;
		}

		if (!gagajf.isNull(orgPushList)) {
			let pushListJosn = JSON.parse(orgPushList);
			let html = '';
			$.each(pushListJosn.pushList, function(idx, item) {
				html += '<div class="inner">\n';
				html += '    <a href="'+item.link+'">\n';
				html += '        <dl>\n';
				html += '            <dt class="tit">\n';
				html += item.title;
				html += '            </dt>\n'
				html += '            <dd class="cont_txt">\n';
				html += item.content;
				html += '            </dd>\n';
				if (!gagajf.isNull(item.imgUrl)) {
					html += '            <dd class="cont_img">\n';
					html += '                <img src="'+ item.imgUrl +'" />\n';
					html += '            </dd>\n';
				}
				html += '            <dd class="cont_data">\n';
				html += '                <span>\n';
				html += fnDisplayDate(item.date);
				html += '                </span>\n';
				html += '            </dd>\n'
				html += '        </dl>\n'
				html += '    </a>';
				html += '</div>\n'
			});
			$('#notice').removeClass('nodata');
			$('#notice').html(html);
		} else {
			$('#notice').addClass('nodata');
		}
	}

	var fnDisplayDate = function (date) {
		let resultDate = '';
		if(!gagajf.isNull(date)) {
			let year = date.substring(0, 4);
			let month = date.substring(4, 6);
			let day = date.substring(6, 8);
			resultDate = year+'.'+month+'.'+day;
		}
		return resultDate;
	}


</script>

</th:block>
</body>
</html>