메시지 첫 동작

This commit is contained in:
2018-04-16 01:09:43 +09:00
parent c87cbaa0a6
commit 0c9099c868
6 changed files with 99 additions and 64 deletions
+1
View File
@@ -66,6 +66,7 @@
color:white;
background-color:black;
font-size:12px;
width:160px;
}
.board_header{
+30 -41
View File
@@ -68,6 +68,7 @@ $scenario = $admin['scenario_text'];
<script src="js/main.js"></script>
<script src="js/base_map.js"></script>
<script src="js/map.js"></script>
<script src="js/msg.js"></script>
<script>
$(function(){
reloadWorldMap({
@@ -80,14 +81,15 @@ $(function(){
<link href="css/common.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<link href="css/map.css" rel="stylesheet">
<link href="css/msg.css" rel="stylesheet">
</head>
<body class="img_back">
<div id="container">
<div><?=allButton()?></div>
<table align=center width=1000 border=1 cellspacing=0 cellpadding=0 style=font-size:13px;word-break:break-all; id=bg0>
<tr><td colspan=5><?=allButton()?></td></tr>
<tr height=50>
<td colspan=5 align=center><font size=4>삼국지 모의전투 HiDCHe (<font color=cyan><?=$scenario?></font>)</font></td>
</tr>
@@ -271,52 +273,39 @@ if ($session->userGrade >= 5) {
<tr><td width=998 colspan=2 align=center id=bg1><b>중원 정세</b></td></tr>
<tr><td width=998 colspan=2><?=getWorldHistoryRecent(15)?></td></tr>
</table>
<table align=center width=1000 border=1 cellspacing=0 cellpadding=0 style=font-size:13px;word-break:break-all; id=bg0>
<tr>
<td colspan=2>
<div class="message_input_form bg0">
<select id="mailbox_list" size="1">
<div class="message_input_form bg0">
<select id="mailbox_list" size="1">
<select name="genlist" size="1" style="color:white;background-color:black;font-size:13">
</select>
<input type="textarea" id="msg_input" maxlength="99">
<button id="msg_submit">서신전달&amp;갱신</button>
</div>
</td>
</tr>
<tr><td colspan=2><?=allButton()?></td></tr>
<tr><td colspan=2>
<div id="message_board">
<div class="board_side">
<div class="board_header bg0">전체 메시지(최고99자)</div>
<section class="public_message">
<select name="genlist" size="1" style="color:white;background-color:black;font-size:13">
</section>
<div class="board_header bg0">개인 메시지(최고99자)</div>
<section class="private_message">
</section>
</div>
<div class="board_side">
<section class="diplomacy_message">
</section>
<div class="board_header bg0">국가 메시지(최고99자)</div>
<section class="national_message">
</section>
</div>
</div>
</td></tr>
<tr><td colspan=2>
</select>
<input type="textarea" id="msg_input" maxlength="99">
<button id="msg_submit">서신전달&amp;갱신</button>
</div>
<div id="message_board">
<div class="board_side">
<div class="board_header bg0">전체 메시지(최고99자)</div>
<section class="public_message">
<?php
echo allButton();
echo banner();
?>
</section>
<div class="board_header bg0">개인 메시지(최고99자)</div>
<section class="private_message">
</section>
</div>
<div class="board_side">
<section class="diplomacy_message">
</td></tr>
</table>
</section>
<div class="board_header bg0">국가 메시지(최고99자)</div>
<section class="national_message">
</section>
</div>
</div>
<div style="clear:left;"><?=allButton()?><?=banner()?></div>
<?php PrintElapsedTime(); ?>
</div>
<?php
+22 -16
View File
@@ -8,7 +8,7 @@ $session = Session::requireGameLogin([])->setReadOnly();
$userID = Session::getUserID();
$jsonPost = WebUtil::parseJsonPost();
$reqSequence = Util::toInt(Util::array_get($jsonPost['sequence'], 0));
$reqSequence = (int)Util::array_get($jsonPost['sequence'], 0);
list($generalID, $nationID) = DB::db()->queryFirstList(
@@ -24,18 +24,24 @@ if($nationID === null){
]);
}
Json::die([
'result'=>true,
'private'=>array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox($generalID, Message::MSGTYPE_PRIVATE, 10, $reqSequence)),
'public'=>array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox(Message::MAILBOX_PUBLIC, Message::MSGTYPE_PUBLIC, 20, $reqSequence)),
'national'=>array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_NATIONAL, 20, $reqSequence)),
'diplomacy'=>array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 10, 0)),
]);
$result = [];
$result['result'] = true;
$result['private'] = array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox($generalID, Message::MSGTYPE_PRIVATE, 10, $reqSequence));
$result['public'] = array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox(Message::MAILBOX_PUBLIC, Message::MSGTYPE_PUBLIC, 20, $reqSequence));
$result['national'] = array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_NATIONAL, 20, $reqSequence));
$result['diplomacy']= array_map(function(Message $msg){
return $msg->toArray();
}, Message::getMessagesFromMailBox(Message::MAILBOX_NATIONAL + $nationID, Message::MSGTYPE_DIPLOMACY, 10, 0));
Json::die($result);
+7 -6
View File
@@ -48,7 +48,7 @@ function refreshMsg(){
function fetchMsg(){
return $.ajax({
url: 'json_result.php',
url: 'j_msg_get_recent.php',
type: 'post',
dataType:'json',
contentType: 'application/json',
@@ -221,7 +221,7 @@ function refreshMailboxList(obj){
$.each(obj.nation, function(){
var nation = this;
//console.log(nation);
var $optgroup = $('<optgroup label="{0}"></optgroup>'.format(nation.nation));
var $optgroup = $('<optgroup label="{0}"></optgroup>'.format(nation.name));
$optgroup.css('background-color', nation.color);
if(myNation.mailbox == nation.mailbox){
@@ -238,7 +238,8 @@ function refreshMailboxList(obj){
$.each(nation.general, function(){
var generalID = this[0];
var generalName = this[1];
var isRuler = this.length>2;
var isNPC = !!(this[2] & 0x2);
var isRuler = !!(this[2] & 0x1);
@@ -358,13 +359,13 @@ function activateMessageForm(){
jQuery(function($){
//tmp_template.html은 추후 msg.js에 통합될 수 있음
var getTemplate = $.get('tmp_template.html',function(obj){
var getTemplate = $.get('js/templates/message.html',function(obj){
messageTemplate = obj;
});
//basic_info.json은 세션값에 따라 동적으로 바뀌는 데이터임.
var basicInfo = $.ajax({
url:'basic_info.json',
url:'j_basic_info.php',
type: 'post',
dataType:'json',
contentType: 'application/json',
@@ -375,7 +376,7 @@ jQuery(function($){
//sender_list.json 은 서버측에선 캐시 가능한 데이터임.
var senderList = $.ajax({
url: 'sender_list.json',
url: 'j_msg_contact_list.php',
type: 'post',
dataType:'json',
contentType: 'application/json',
+38
View File
@@ -0,0 +1,38 @@
<div
class="msg_plate msg_plate_<%msgType%>"
id="msg_<%id%>"
data-id="<%id%>"
>
<div class="msg_icon">
<%if(src.icon) { %>
<img width='64' height='64' src="<%encodeURI(src.icon)%>">
<%} else {%>
<img width='64' height='64' src="<%encodeURI(defaultIcon)%>">
<%}%>
</div>
<div class="msg_body">
<div class="msg_header">
<%if(msgType == 'private') {%>
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%e(src.nation)%></span
><span class="msg_from_to"></span
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;"><%e(dest.name)%>:<%e(dest.nation)%></span>
<%} else if(msgType == 'national' && src.nation_id == dest.nation_id){%>
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%e(src.nation)%></span>
<%} else if(msgType == 'national' || msgType == 'diplomacy'){%>
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%e(src.nation)%></span
><span class="msg_from_to"></span
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;"><%e(dest.nation)%></span>
<%} else {%>
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%e(src.nation)%></span>
<%} %>
<span class="msg_time">&lt;<%e(time)%>&gt;</span>
</div>
<div class="msg_content"><%e(text)%></div>
<%if(this.option && this.option.action) {%>
<div class="msg_prompt">
<button class="prompt_yes btn_prompt">수락</button> <button class="prompt_no btn_prompt">거절</button>
</div>
<%} %>
</div>
</div>
+1 -1
View File
@@ -192,7 +192,7 @@ class Message
* @param int $fromSeq 가져오고자 하는 위치. $fromSeq보다 '큰' seq만 가져온다. 따라서 0 이하이면 모두 가져옴.
* @return Message[]
*/
protected static function getMessagesFromMailBox(int $mailbox, string $msgType, int $limit=30, int $fromSeq = 0)
public static function getMessagesFromMailBox(int $mailbox, string $msgType, int $limit=30, int $fromSeq = 0)
{
$db = DB::db();