새메시지, 클라이언트 단 메시지 시스템 1차 완성
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
require('../twe/lib.php');
|
||||||
|
use utilphp\util as util;
|
||||||
|
|
||||||
|
$jsonPost = parseJsonPost();
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'success',
|
||||||
|
'msgID'=>1997
|
||||||
|
], JSON_UNESCAPED_UNICODE);
|
||||||
+10
-10
@@ -187,7 +187,7 @@
|
|||||||
],
|
],
|
||||||
"public":[
|
"public":[
|
||||||
{
|
{
|
||||||
"id":1013,
|
"id":1103,
|
||||||
"time":"2018-02-10 22:05:02",
|
"time":"2018-02-10 22:05:02",
|
||||||
"isSender":false,
|
"isSender":false,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
"text":"전메놀이3, 특수"
|
"text":"전메놀이3, 특수"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id":1012,
|
"id":1102,
|
||||||
"time":"2018-02-10 22:05:01",
|
"time":"2018-02-10 22:05:01",
|
||||||
"isSender":false,
|
"isSender":false,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -232,7 +232,7 @@
|
|||||||
},
|
},
|
||||||
"text":"최대한많은길이의텍스트를전메에넣어보려고시도하는중입니다글자수기준이니띄어쓰기나숫자알파벳이없도록해야꽉꽉밀어넣을수있습니다어디까지들어가려나얼마나더적어야하는거지잘모르겠다의외로칸이꽤길구나메시지"
|
"text":"최대한많은길이의텍스트를전메에넣어보려고시도하는중입니다글자수기준이니띄어쓰기나숫자알파벳이없도록해야꽉꽉밀어넣을수있습니다어디까지들어가려나얼마나더적어야하는거지잘모르겠다의외로칸이꽤길구나메시지"
|
||||||
},{
|
},{
|
||||||
"id":1010,
|
"id":1100,
|
||||||
"time":"2018-02-10 22:05:00",
|
"time":"2018-02-10 22:05:00",
|
||||||
"isSender":false,
|
"isSender":false,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
],
|
],
|
||||||
"private":[
|
"private":[
|
||||||
{
|
{
|
||||||
"id":1025,
|
"id":1205,
|
||||||
"time":"2018-02-10 22:04:04",
|
"time":"2018-02-10 22:04:04",
|
||||||
"isSender":false,
|
"isSender":false,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -273,7 +273,7 @@
|
|||||||
"action":"scout"
|
"action":"scout"
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
"id":1024,
|
"id":1204,
|
||||||
"time":"2018-02-10 22:04:04",
|
"time":"2018-02-10 22:04:04",
|
||||||
"isSender":false,
|
"isSender":false,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -290,7 +290,7 @@
|
|||||||
},
|
},
|
||||||
"text":"재야로부터 갠메(수신)"
|
"text":"재야로부터 갠메(수신)"
|
||||||
},{
|
},{
|
||||||
"id":1023,
|
"id":1203,
|
||||||
"time":"2018-02-10 22:04:03",
|
"time":"2018-02-10 22:04:03",
|
||||||
"isSender":true,
|
"isSender":true,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -309,7 +309,7 @@
|
|||||||
},
|
},
|
||||||
"text":"타국 갠메(송신)"
|
"text":"타국 갠메(송신)"
|
||||||
},{
|
},{
|
||||||
"id":1022,
|
"id":1202,
|
||||||
"time":"2018-02-10 22:04:02",
|
"time":"2018-02-10 22:04:02",
|
||||||
"isSender":true,
|
"isSender":true,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -328,7 +328,7 @@
|
|||||||
},
|
},
|
||||||
"text":"아국 갠메(수신)"
|
"text":"아국 갠메(수신)"
|
||||||
},{
|
},{
|
||||||
"id":1021,
|
"id":1201,
|
||||||
"time":"2018-02-10 22:04:01",
|
"time":"2018-02-10 22:04:01",
|
||||||
"isSender":true,
|
"isSender":true,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -347,7 +347,7 @@
|
|||||||
},
|
},
|
||||||
"text":"아국 갠메(수신)"
|
"text":"아국 갠메(수신)"
|
||||||
},{
|
},{
|
||||||
"id":1020,
|
"id":1200,
|
||||||
"time":"2018-02-10 22:04:00",
|
"time":"2018-02-10 22:04:00",
|
||||||
"isSender":true,
|
"isSender":true,
|
||||||
"src":{
|
"src":{
|
||||||
@@ -369,7 +369,7 @@
|
|||||||
],
|
],
|
||||||
"diplomacy":[
|
"diplomacy":[
|
||||||
{
|
{
|
||||||
"id":1030,
|
"id":1300,
|
||||||
"time":"2018-02-10 22:05:04",
|
"time":"2018-02-10 22:05:04",
|
||||||
"isSender":false,
|
"isSender":false,
|
||||||
"src":{
|
"src":{
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ switch($reqSequence){
|
|||||||
relayJson('update_private_result.json');
|
relayJson('update_private_result.json');
|
||||||
break;
|
break;
|
||||||
case 1366:
|
case 1366:
|
||||||
relayJson('update_public_result.json');
|
relayJson('update_national_result.json');
|
||||||
break;
|
break;
|
||||||
case 1811:
|
case 1811:
|
||||||
relayJson('update_national_result.json');
|
relayJson('update_public_result.json');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
</select>
|
</select>
|
||||||
<input type="textarea" id="msg_input" maxlength="99">
|
<input type="textarea" id="msg_input" maxlength="99">
|
||||||
<button>서신전달&갱신</button>
|
<button id="msg_submit">서신전달&갱신</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="message_board">
|
<div id="message_board">
|
||||||
<div class="board_side">
|
<div class="board_side">
|
||||||
|
|||||||
+100
-5
@@ -27,6 +27,18 @@ var sequence =null;
|
|||||||
var myNation = null;
|
var myNation = null;
|
||||||
var lastMsg = null;
|
var lastMsg = null;
|
||||||
|
|
||||||
|
function responseMessage(msgID, response){
|
||||||
|
$.ajax({
|
||||||
|
url: 'prompt_dummy.php',
|
||||||
|
type: 'post',
|
||||||
|
dataType:'json',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({
|
||||||
|
msgID:msgID,
|
||||||
|
response:response
|
||||||
|
})
|
||||||
|
}).then(refreshMsg);
|
||||||
|
}
|
||||||
|
|
||||||
function refreshMsg(){
|
function refreshMsg(){
|
||||||
return redrawMsg(fetchMsg());
|
return redrawMsg(fetchMsg());
|
||||||
@@ -107,14 +119,47 @@ function redrawMsg(deferred){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//list의 맨 앞이 가장 최신 메시지임.
|
//list의 맨 앞이 가장 최신 메시지임.
|
||||||
var msgHtmls = msgSource.map(function(msg){
|
var $msgs = msgSource.map(function(msg){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
msg.msgType = msgType;
|
msg.msgType = msgType;
|
||||||
var msgHtml = TemplateEngine(messageTemplate, msg);
|
var msgHtml = TemplateEngine(messageTemplate, msg);
|
||||||
return msgHtml;
|
|
||||||
|
|
||||||
|
//만약 이전 메시지가 변경된 것인가 확인한다.
|
||||||
|
var $existMsg = $('#msg_{0}'.format(msg.id));
|
||||||
|
var $msg = $(msgHtml);
|
||||||
|
if($existMsg.length){
|
||||||
|
$existMsg.html($msg.html());
|
||||||
|
$msg = $existMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
$msg.find('button.prompt_yes').click(function(){
|
||||||
|
if(!confirm("수락하시겠습니까?")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
responseMessage(msg.id, true);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$msg.find('button.prompt_no').click(function(){
|
||||||
|
if(!confirm("거절하시겠습니까?")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
responseMessage(msg.id, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
if($existMsg.length){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var $items = $(msgHtmls.join(''));
|
$msgBoard.prepend($msgs);
|
||||||
$msgBoard.prepend($items);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -145,6 +190,8 @@ function refreshMailboxList(obj){
|
|||||||
|
|
||||||
$mailboxList.empty();
|
$mailboxList.empty();
|
||||||
|
|
||||||
|
//TODO:수뇌인 경우 각국에 대해 외교 국메를 넣을 수 있어야함.
|
||||||
|
|
||||||
$.each(obj.nation, function(){
|
$.each(obj.nation, function(){
|
||||||
var nation = this;
|
var nation = this;
|
||||||
//console.log(nation);
|
//console.log(nation);
|
||||||
@@ -228,6 +275,53 @@ function registerGlobal(basicInfo){
|
|||||||
isChief = basicInfo.isChief;
|
isChief = basicInfo.isChief;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activateMessageForm(){
|
||||||
|
var $msgInput = $('#msg_input');
|
||||||
|
var $msgSubmit = $('#msg_submit');
|
||||||
|
var $mailboxList = $('#mailbox_list');
|
||||||
|
|
||||||
|
$msgInput.keypress(function (e) {
|
||||||
|
var code = (e.keyCode ? e.keyCode : e.which);
|
||||||
|
if (code == 13) {
|
||||||
|
$msgSubmit.trigger('click');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$msgSubmit.click(function(){
|
||||||
|
|
||||||
|
var text = $.trim($msgInput.val());
|
||||||
|
$msgInput.val('').focus();
|
||||||
|
|
||||||
|
var targetMailbox = $mailboxList.val();
|
||||||
|
console.log(targetMailbox, text);
|
||||||
|
|
||||||
|
var deferred;
|
||||||
|
|
||||||
|
if(text){
|
||||||
|
deferred = $.ajax({
|
||||||
|
url:'add_msg_dummy.php',
|
||||||
|
type: 'post',
|
||||||
|
dataType:'json',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify({
|
||||||
|
mailbox:targetMailbox,
|
||||||
|
text:text
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
deferred = $.Deferred();
|
||||||
|
deferred.resolve({
|
||||||
|
result:true,
|
||||||
|
reason:'no_text'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
deferred.then(refreshMsg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(function($){
|
jQuery(function($){
|
||||||
|
|
||||||
//tmp_template.html은 추후 msg.js에 통합될 수 있음
|
//tmp_template.html은 추후 msg.js에 통합될 수 있음
|
||||||
@@ -260,7 +354,8 @@ jQuery(function($){
|
|||||||
var MessageList = fetchMsg();
|
var MessageList = fetchMsg();
|
||||||
|
|
||||||
$.when(senderList, basicInfo)
|
$.when(senderList, basicInfo)
|
||||||
.then(refreshMailboxList);
|
.then(refreshMailboxList)
|
||||||
|
.then(activateMessageForm);
|
||||||
|
|
||||||
$.when(MessageList, getTemplate, basicInfo)
|
$.when(MessageList, getTemplate, basicInfo)
|
||||||
.then(function(){
|
.then(function(){
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
require('../twe/lib.php');
|
require('../twe/lib.php');
|
||||||
use utilphp\util as util;
|
use utilphp\util as util;
|
||||||
|
|
||||||
return json_encode([
|
$jsonPost = parseJsonPost();
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
'result'=>true,
|
'result'=>true,
|
||||||
'reason'=>'success'
|
'reason'=>'success'
|
||||||
], JSON_UNESCAPED_UNICODE);
|
], JSON_UNESCAPED_UNICODE);
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<div
|
<div
|
||||||
class="msg_plate msg_plate_<%msgType%>"
|
class="msg_plate msg_plate_<%msgType%>"
|
||||||
id="msg_<%id%>"
|
id="msg_<%id%>"
|
||||||
|
data-id="<%id%>"
|
||||||
>
|
>
|
||||||
<div class="msg_icon">
|
<div class="msg_icon">
|
||||||
<%if(src.icon) { %>
|
<%if(src.icon) { %>
|
||||||
|
|||||||
@@ -1,9 +1,48 @@
|
|||||||
{
|
{
|
||||||
"result":true,
|
"result":true,
|
||||||
"server":"d1af658a-f094-4303-9496-9a27a8180b0b",
|
"server":"d1af658a-f094-4303-9496-9a27a8180b0b",
|
||||||
"sequence":1357,
|
"sequence":1811,
|
||||||
"national":[
|
"national":[
|
||||||
|
{
|
||||||
|
"id":1210,
|
||||||
|
"time":"2018-02-10 22:05:09",
|
||||||
|
"isSender":false,
|
||||||
|
"src":{
|
||||||
|
"id":11,
|
||||||
|
"nation_id":1,
|
||||||
|
"name":"Hide_D",
|
||||||
|
"icon":"pic_781.jpg",
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"dest":{
|
||||||
|
"id":9001,
|
||||||
|
"nation_id":1,
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"text":"새롭게 추가된 나의 텍스트!"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":1209,
|
||||||
|
"time":"2018-02-10 22:05:08",
|
||||||
|
"isSender":false,
|
||||||
|
"src":{
|
||||||
|
"id":11,
|
||||||
|
"nation_id":1,
|
||||||
|
"name":"Hide_D",
|
||||||
|
"icon":"pic_781.jpg",
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"dest":{
|
||||||
|
"id":9001,
|
||||||
|
"nation_id":1,
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"text":"외교를 거절해버렸당"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"public":[
|
"public":[
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,75 @@
|
|||||||
|
|
||||||
],
|
],
|
||||||
"private":[
|
"private":[
|
||||||
|
{
|
||||||
|
"id":1205,
|
||||||
|
"time":"2018-02-10 22:06:00",
|
||||||
|
"isSender":false,
|
||||||
|
"src":{
|
||||||
|
"id":21,
|
||||||
|
"nation_id":2,
|
||||||
|
"name":"Hide_Dx2",
|
||||||
|
"nation":"연구소2",
|
||||||
|
"color":"#ff0000"
|
||||||
|
},
|
||||||
|
"dest":{
|
||||||
|
"id":11,
|
||||||
|
"nation_id":1,
|
||||||
|
"name":"Hide_D",
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"text":"연구소2로 망명 권유 서신을 거절"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id":1206,
|
||||||
|
"time":"2018-02-10 22:04:04",
|
||||||
|
"isSender":false,
|
||||||
|
"src":{
|
||||||
|
"id":21,
|
||||||
|
"nation_id":2,
|
||||||
|
"name":"Hide_Dx2",
|
||||||
|
"nation":"연구소2",
|
||||||
|
"color":"#ff0000"
|
||||||
|
},
|
||||||
|
"dest":{
|
||||||
|
"id":11,
|
||||||
|
"nation_id":1,
|
||||||
|
"name":"Hide_D",
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"text":"추가해라 더 많은 갠메!"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"diplomacy":[
|
"diplomacy":[
|
||||||
|
{
|
||||||
|
"id":1300,
|
||||||
|
"time":"2018-02-10 22:05:04",
|
||||||
|
"isSender":false,
|
||||||
|
"src":{
|
||||||
|
"id":21,
|
||||||
|
"nation_id":2,
|
||||||
|
"name":"Hide_Dx2",
|
||||||
|
"nation":"연구소2",
|
||||||
|
"color":"#ff0000",
|
||||||
|
"icon":"pic_1.jpg"
|
||||||
|
},
|
||||||
|
"dest":{
|
||||||
|
"id":9001,
|
||||||
|
"nation_id":1,
|
||||||
|
"nation":"연구소",
|
||||||
|
"color":"#ffd700"
|
||||||
|
},
|
||||||
|
"text":"타국->아국",
|
||||||
|
"option":{
|
||||||
|
"used":false,
|
||||||
|
"result":false,
|
||||||
|
"until":[210, 9],
|
||||||
|
"action":"ally",
|
||||||
|
"allyYear":20,
|
||||||
|
"allyText":"메롱"
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,27 @@
|
|||||||
{
|
{
|
||||||
"result":true,
|
"result":true,
|
||||||
"server":"d1af658a-f094-4303-9496-9a27a8180b0b",
|
"server":"d1af658a-f094-4303-9496-9a27a8180b0b",
|
||||||
"sequence":1811,
|
"sequence":1997,
|
||||||
"national":[
|
"national":[
|
||||||
|
|
||||||
],
|
],
|
||||||
"public":[
|
"public":[
|
||||||
|
{
|
||||||
|
"id":1106,
|
||||||
|
"time":"2018-02-10 22:05:02",
|
||||||
|
"isSender":false,
|
||||||
|
"src":{
|
||||||
|
"id":41,
|
||||||
|
"nation_id":3,
|
||||||
|
"name":"Hide_Dz1",
|
||||||
|
"nation":"연구소3",
|
||||||
|
"color":"#000080"
|
||||||
|
},
|
||||||
|
"dest":{
|
||||||
|
"id":9999
|
||||||
|
},
|
||||||
|
"text":"나는 전메를 입력했당"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"private":[
|
"private":[
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user