From e79a12cbc6cfb979b2bdeb321d24010ab5469a04 Mon Sep 17 00:00:00 2001 From: hide_d Date: Thu, 1 Mar 2018 03:26:00 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=88=EB=A9=94=EC=8B=9C=EC=A7=80,=20?= =?UTF-8?q?=EC=A6=90=EA=B2=A8=EC=B0=BE=EA=B8=B0=20=EB=8C=80=EC=83=81?= =?UTF-8?q?=EC=9D=84=20=EB=8F=99=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmp_msg/msg.js | 37 +++++++++++++++++++++---------- tmp_msg/update_public_result.json | 21 +++++++++++++++++- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/tmp_msg/msg.js b/tmp_msg/msg.js index c9810e07..aa1698c0 100644 --- a/tmp_msg/msg.js +++ b/tmp_msg/msg.js @@ -27,6 +27,8 @@ var sequence =null; var myNation = null; var lastMsg = null; +var generalList = {}; + function responseMessage(msgID, response){ $.ajax({ url: 'prompt_dummy.php', @@ -118,10 +120,18 @@ function redrawMsg(deferred){ $msgBoard.empty(); } + + var needRefreshLastContact = (msgType == 'private'); + //list의 맨 앞이 가장 최신 메시지임. var $msgs = msgSource.map(function(msg){ - + var contactTarget = (msg.src.id != myGeneralID) ? msg.src.id : msg.dest.id; + if(needRefreshLastContact && contactTarget != myGeneralID) + { + needRefreshLastContact = false; + $('#last_contact').val(contactTarget).html(generalList[contactTarget].textName).show(); + } msg.msgType = msgType; var msgHtml = TemplateEngine(messageTemplate, msg); @@ -221,9 +231,7 @@ function refreshMailboxList(obj){ var generalName = this[1]; var isRuler = this.length>2; - if(generalID == lastMsg.id){ - lastMsg.name = generalName; - } + if(generalID == myGeneralID){ return true; @@ -234,6 +242,15 @@ function refreshMailboxList(obj){ textName = '*{0}*'.format(textName); } + generalList[generalID] = { + id:generalID, + name:generalName, + textName:textName, + isRuler:isRuler, + nation:nation.nationID, + color:nation.color + }; + var $item = $(''.format(generalID, textName)); $optgroup.append($item); }); @@ -250,12 +267,8 @@ function refreshMailboxList(obj){ $favorite.append($ourCountry); $favorite.append($toPublic); - //최근 대화상대 - if(lastMsg.id){ - var $lastContact = $(''.format(lastMsg.id, lastMsg.name)); - $favorite.append($lastContact); - } - + var $lastContact = $('').hide(); + $favorite.append($lastContact); //TODO:운영자를 추가하는 코드도 넣을 것. $mailboxList.prepend($favorite); @@ -361,11 +374,11 @@ jQuery(function($){ var MessageList = fetchMsg(); - $.when(senderList, basicInfo) + senderList = $.when(senderList, basicInfo) .then(refreshMailboxList) .then(activateMessageForm); - $.when(MessageList, getTemplate, basicInfo) + $.when(MessageList, getTemplate, basicInfo, senderList) .then(function(){ redrawMsg(MessageList); }); diff --git a/tmp_msg/update_public_result.json b/tmp_msg/update_public_result.json index dfc99f48..02080387 100644 --- a/tmp_msg/update_public_result.json +++ b/tmp_msg/update_public_result.json @@ -24,7 +24,26 @@ } ], "private":[ - + { + "id":1212, + "time":"2018-02-10 22:04:04", + "isSender":false, + "src":{ + "id":22, + "nation_id":2, + "name":"Hide_Dx3", + "nation":"연구소2", + "color":"#ff0000" + }, + "dest":{ + "id":11, + "nation_id":1, + "name":"Hide_D", + "nation":"연구소", + "color":"#ffd700" + }, + "text":"추가해라 더 많은 갠메!" + } ], "diplomacy":[