새메시지, 즐겨찾기 대상을 동적으로 계산하도록 수정
This commit is contained in:
+25
-12
@@ -27,6 +27,8 @@ var sequence =null;
|
|||||||
var myNation = null;
|
var myNation = null;
|
||||||
var lastMsg = null;
|
var lastMsg = null;
|
||||||
|
|
||||||
|
var generalList = {};
|
||||||
|
|
||||||
function responseMessage(msgID, response){
|
function responseMessage(msgID, response){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'prompt_dummy.php',
|
url: 'prompt_dummy.php',
|
||||||
@@ -118,10 +120,18 @@ function redrawMsg(deferred){
|
|||||||
$msgBoard.empty();
|
$msgBoard.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var needRefreshLastContact = (msgType == 'private');
|
||||||
|
|
||||||
//list의 맨 앞이 가장 최신 메시지임.
|
//list의 맨 앞이 가장 최신 메시지임.
|
||||||
var $msgs = msgSource.map(function(msg){
|
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;
|
msg.msgType = msgType;
|
||||||
var msgHtml = TemplateEngine(messageTemplate, msg);
|
var msgHtml = TemplateEngine(messageTemplate, msg);
|
||||||
@@ -221,9 +231,7 @@ function refreshMailboxList(obj){
|
|||||||
var generalName = this[1];
|
var generalName = this[1];
|
||||||
var isRuler = this.length>2;
|
var isRuler = this.length>2;
|
||||||
|
|
||||||
if(generalID == lastMsg.id){
|
|
||||||
lastMsg.name = generalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(generalID == myGeneralID){
|
if(generalID == myGeneralID){
|
||||||
return true;
|
return true;
|
||||||
@@ -234,6 +242,15 @@ function refreshMailboxList(obj){
|
|||||||
textName = '*{0}*'.format(textName);
|
textName = '*{0}*'.format(textName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generalList[generalID] = {
|
||||||
|
id:generalID,
|
||||||
|
name:generalName,
|
||||||
|
textName:textName,
|
||||||
|
isRuler:isRuler,
|
||||||
|
nation:nation.nationID,
|
||||||
|
color:nation.color
|
||||||
|
};
|
||||||
|
|
||||||
var $item = $('<option value="{0}">{1}</option>'.format(generalID, textName));
|
var $item = $('<option value="{0}">{1}</option>'.format(generalID, textName));
|
||||||
$optgroup.append($item);
|
$optgroup.append($item);
|
||||||
});
|
});
|
||||||
@@ -250,12 +267,8 @@ function refreshMailboxList(obj){
|
|||||||
$favorite.append($ourCountry);
|
$favorite.append($ourCountry);
|
||||||
$favorite.append($toPublic);
|
$favorite.append($toPublic);
|
||||||
|
|
||||||
//최근 대화상대
|
var $lastContact = $('<option id="last_contact" value="-1"></option>').hide();
|
||||||
if(lastMsg.id){
|
$favorite.append($lastContact);
|
||||||
var $lastContact = $('<option value="{0}">{1}</option>'.format(lastMsg.id, lastMsg.name));
|
|
||||||
$favorite.append($lastContact);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO:운영자를 추가하는 코드도 넣을 것.
|
//TODO:운영자를 추가하는 코드도 넣을 것.
|
||||||
|
|
||||||
$mailboxList.prepend($favorite);
|
$mailboxList.prepend($favorite);
|
||||||
@@ -361,11 +374,11 @@ jQuery(function($){
|
|||||||
|
|
||||||
var MessageList = fetchMsg();
|
var MessageList = fetchMsg();
|
||||||
|
|
||||||
$.when(senderList, basicInfo)
|
senderList = $.when(senderList, basicInfo)
|
||||||
.then(refreshMailboxList)
|
.then(refreshMailboxList)
|
||||||
.then(activateMessageForm);
|
.then(activateMessageForm);
|
||||||
|
|
||||||
$.when(MessageList, getTemplate, basicInfo)
|
$.when(MessageList, getTemplate, basicInfo, senderList)
|
||||||
.then(function(){
|
.then(function(){
|
||||||
redrawMsg(MessageList);
|
redrawMsg(MessageList);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,26 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"private":[
|
"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":[
|
"diplomacy":[
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user