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!!'); %>
- +
<%} %>