From 41660932961b1f6e95cb843b8b1587719ae2a0b9 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 12 Feb 2018 01:55:55 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=88=EB=A9=94=EC=8B=9C=EC=A7=80.=20?= =?UTF-8?q?=EC=B4=88=EA=B8=B0=20=EB=B2=84=EC=A0=84=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmp_msg/msg.js | 50 ++++++++++++++++++++++++++++++++------- tmp_msg/tmp_template.html | 12 +++++----- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/tmp_msg/msg.js b/tmp_msg/msg.js index 1fa30996..12060396 100644 --- a/tmp_msg/msg.js +++ b/tmp_msg/msg.js @@ -21,10 +21,10 @@ var messageTemplate = ` > - <%if(src.iconPath !== null) { %> - + <%if(src.icon) { %> + <%} else {%> - /*NOTE: image 폴더는 어느 단에서 다뤄야하는가? */ + <%}%> @@ -49,12 +49,12 @@ var messageTemplate = ` <%e(src.name)%>:<%e(src.nation)%> ] <%} %> - <<%e($datetime)%>> + <<%e(time)%>>
- <%e(message)%> + <%e(text)%> <%if(this.option){ console.log('HasOption!!'); %>
- +
<%} %> @@ -68,8 +68,6 @@ var refreshMsg = (function(){ var sequence =null; return function(){ - - var deferred = $.ajax({ url: 'json_result.php', type: 'post', @@ -91,8 +89,42 @@ var refreshMsg = (function(){ return obj; } + function printTemplate(obj){ + var printList = [ + [obj.public, $('#message_board .public_message'), 'public'], + [obj.private, $('#message_board .private_message'), 'private'], + [obj.diplomacy, $('#message_board .diplomacy_message'), 'diplomacy'], + [obj.national, $('#message_board .national_message'), 'national'], + ]; + + $.each(printList, function(){ + var msgSource = this[0]; + var $msgBoard = this[1]; + var msgType = this[2]; + + if(!msgSource || $msgBoard.length == 0){ + console.log('No Items', msgSource, $msgBoard); + return true; + } + + //list의 맨 앞이 가장 최신 메시지임. + var msgHtmls = msgSource.map(function(msg){ + msg.msgType = msgType; + var msgHtml = TemplateEngine(messageTemplate, msg); + console.log(msgHtml); + return msgHtml; + }); + + var $items = $(msgHtmls.join('')); + console.log($items); + $msgBoard.prepend($items); + }); + + } + deferred - .then(registerGlobal); + .then(registerGlobal) + .then(printTemplate); diff --git a/tmp_msg/tmp_template.html b/tmp_msg/tmp_template.html index 9f0c7864..9fc46001 100644 --- a/tmp_msg/tmp_template.html +++ b/tmp_msg/tmp_template.html @@ -17,10 +17,10 @@ > - <%if(src.iconPath !== null) { %> - + <%if(src.icon !== null) { %> + <%} else {%> - /*NOTE: image 폴더는 어느 단에서 다뤄야하는가? */ + <%}%> @@ -45,12 +45,12 @@ <%e(src.name)%>:<%e(src.nation)%> ] <%} %> - <<%e($datetime)%>> + <<%e(time)%>>
- <%e(message)%> + <%e(text)%> <%if(this.option){ console.log('HasOption!!'); %>
- +
<%} %>