misc: msg template 통합
This commit is contained in:
@@ -1,48 +0,0 @@
|
|||||||
<div
|
|
||||||
class="msg_plate msg_plate_<%msgType%> msg_plate_<%nationType%>"
|
|
||||||
id="msg_<%id%>"
|
|
||||||
data-id="<%id%>"
|
|
||||||
>
|
|
||||||
<div class="msg_icon">
|
|
||||||
<%if(src.icon){ %>
|
|
||||||
<img class='generalIcon' width='64' height='64' src="<%encodeURI(src.icon)%>">
|
|
||||||
<%} else {%>
|
|
||||||
<img class='generalIcon' width='64' height='64' src="<%encodeURI(defaultIcon)%>">
|
|
||||||
<%}%>
|
|
||||||
</div>
|
|
||||||
<div class="msg_body">
|
|
||||||
<div class="msg_header">
|
|
||||||
<%if(!this.option.action && src.id == myGeneralID && now <= last5min && invalidType == 'msg_valid' && !deletable){%>
|
|
||||||
<button type="button" data-erase_until="<%last5min%>" class="btn btn btn-outline-warning btn-sm btn-delete-msg" style='float:right'>❌</button>
|
|
||||||
<%}%>
|
|
||||||
<%if(msgType == 'private') {%>
|
|
||||||
<%if(src.name == generalName){%>
|
|
||||||
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;">나</span
|
|
||||||
><span class="msg_from_to">▶</span
|
|
||||||
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;"><%e(dest.name)%>:<%dest.nation%></span>
|
|
||||||
<%}else{%>
|
|
||||||
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%src.nation%></span
|
|
||||||
><span class="msg_from_to">▶</span
|
|
||||||
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;">나</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)%></span>
|
|
||||||
<%} else if(msgType == 'national' || msgType == 'diplomacy'){%>
|
|
||||||
<%if(src.nation_id == nationID){%>
|
|
||||||
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%></span
|
|
||||||
><span class="msg_from_to">▶</span
|
|
||||||
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;"><%dest.nation%></span>
|
|
||||||
<%}else{%>
|
|
||||||
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%src.nation%></span
|
|
||||||
><span class="msg_from_to"></span>
|
|
||||||
<%}%>
|
|
||||||
<%} else {%>
|
|
||||||
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%src.nation%></span>
|
|
||||||
<%} %>
|
|
||||||
<span class="msg_time"><<%e(time)%>></span>
|
|
||||||
</div>
|
|
||||||
<div class="msg_content <%invalidType%>"><%linkifyStr(text)%></div>
|
|
||||||
<%if(this.option && this.option.action) {%>
|
|
||||||
<div class="msg_prompt">
|
|
||||||
<button type="button" class="prompt_yes btn_prompt" <%allowButton?'':'disabled="disabled"'%>>수락</button> <button type="button" class="prompt_no btn_prompt" <%allowButton?'':'disabled="disabled"'%>>거절</button>
|
|
||||||
</div><%} %></div></div>
|
|
||||||
+52
-8
@@ -15,7 +15,55 @@ import { isNotNull } from './util/isNotNull';
|
|||||||
import { unwrap_any } from './util/unwrap_any';
|
import { unwrap_any } from './util/unwrap_any';
|
||||||
import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest';
|
import { setAxiosXMLHttpRequest } from './util/setAxiosXMLHttpRequest';
|
||||||
import { exportWindow } from './util/exportWindow';
|
import { exportWindow } from './util/exportWindow';
|
||||||
let messageTemplate: string | undefined;
|
|
||||||
|
const messageTemplate = `<div
|
||||||
|
class="msg_plate msg_plate_<%msgType%> msg_plate_<%nationType%>"
|
||||||
|
id="msg_<%id%>"
|
||||||
|
data-id="<%id%>"
|
||||||
|
>
|
||||||
|
<div class="msg_icon">
|
||||||
|
<%if(src.icon){ %>
|
||||||
|
<img class='generalIcon' width='64' height='64' src="<%encodeURI(src.icon)%>">
|
||||||
|
<%} else {%>
|
||||||
|
<img class='generalIcon' width='64' height='64' src="<%encodeURI(defaultIcon)%>">
|
||||||
|
<%}%>
|
||||||
|
</div>
|
||||||
|
<div class="msg_body">
|
||||||
|
<div class="msg_header">
|
||||||
|
<%if(!this.option.action && src.id == myGeneralID && now <= last5min && invalidType == 'msg_valid' && !deletable){%>
|
||||||
|
<button type="button" data-erase_until="<%last5min%>" class="btn btn btn-outline-warning btn-sm btn-delete-msg" style='float:right'>❌</button>
|
||||||
|
<%}%>
|
||||||
|
<%if(msgType == 'private') {%>
|
||||||
|
<%if(src.name == generalName){%>
|
||||||
|
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;">나</span
|
||||||
|
><span class="msg_from_to">▶</span
|
||||||
|
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;"><%e(dest.name)%>:<%dest.nation%></span>
|
||||||
|
<%}else{%>
|
||||||
|
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%src.nation%></span
|
||||||
|
><span class="msg_from_to">▶</span
|
||||||
|
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;">나</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)%></span>
|
||||||
|
<%} else if(msgType == 'national' || msgType == 'diplomacy'){%>
|
||||||
|
<%if(src.nation_id == nationID){%>
|
||||||
|
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%></span
|
||||||
|
><span class="msg_from_to">▶</span
|
||||||
|
><span class="msg_target msg_<%dest.colorType%>" style="background-color:<%dest.color%>;"><%dest.nation%></span>
|
||||||
|
<%}else{%>
|
||||||
|
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%src.nation%></span
|
||||||
|
><span class="msg_from_to"></span>
|
||||||
|
<%}%>
|
||||||
|
<%} else {%>
|
||||||
|
<span class="msg_target msg_<%src.colorType%>" style="background-color:<%src.color%>;"><%e(src.name)%>:<%src.nation%></span>
|
||||||
|
<%} %>
|
||||||
|
<span class="msg_time"><<%e(time)%>></span>
|
||||||
|
</div>
|
||||||
|
<div class="msg_content <%invalidType%>"><%linkifyStr(text)%></div>
|
||||||
|
<%if(this.option && this.option.action) {%>
|
||||||
|
<div class="msg_prompt">
|
||||||
|
<button type="button" class="prompt_yes btn_prompt" <%allowButton?'':'disabled="disabled"'%>>수락</button> <button type="button" class="prompt_no btn_prompt" <%allowButton?'':'disabled="disabled"'%>>거절</button>
|
||||||
|
</div><%} %></div></div>`;
|
||||||
let myGeneralID: number | undefined;
|
let myGeneralID: number | undefined;
|
||||||
//let isChief: boolean | undefined;
|
//let isChief: boolean | undefined;
|
||||||
let lastSequence: number | undefined;
|
let lastSequence: number | undefined;
|
||||||
@@ -623,9 +671,6 @@ function activateMessageForm() {
|
|||||||
$(async function ($) {
|
$(async function ($) {
|
||||||
setAxiosXMLHttpRequest();
|
setAxiosXMLHttpRequest();
|
||||||
|
|
||||||
//tmp_template.html은 추후 msg.js에 통합될 수 있음
|
|
||||||
const getTemplateP = axios('js/templates/message.html?12').then(obj=>{messageTemplate=obj.data});
|
|
||||||
|
|
||||||
//basic_info.json은 세션값에 따라 동적으로 바뀌는 데이터임.
|
//basic_info.json은 세션값에 따라 동적으로 바뀌는 데이터임.
|
||||||
const basicInfoP = axios({
|
const basicInfoP = axios({
|
||||||
url: 'j_basic_info.php',
|
url: 'j_basic_info.php',
|
||||||
@@ -642,13 +687,12 @@ $(async function ($) {
|
|||||||
|
|
||||||
const messageListP = fetchRecentMsg();
|
const messageListP = fetchRecentMsg();
|
||||||
|
|
||||||
|
await basicInfoP
|
||||||
void Promise.all([basicInfoP, senderListP]).then(([, senderList])=>{
|
const senderList = await senderListP;
|
||||||
refreshMailboxList(senderList);
|
refreshMailboxList(senderList);
|
||||||
activateMessageForm();
|
activateMessageForm();
|
||||||
});
|
|
||||||
|
|
||||||
const [messageList, ] = await Promise.all([messageListP, getTemplateP, basicInfoP, senderListP])
|
const messageList = await messageListP;
|
||||||
redrawMsg(messageList, true);
|
redrawMsg(messageList, true);
|
||||||
$('.load_old_message').click(function () {
|
$('.load_old_message').click(function () {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user