js2ts: entrance, webpack(entrance/dist_js)

This commit is contained in:
2021-08-26 01:25:58 +09:00
parent 5b2b01328a
commit 3b9884160b
21 changed files with 474 additions and 446 deletions
+2
View File
@@ -35,6 +35,8 @@ d_pic/uploaded_image
*/dist_js/*
*/dist_css/*
/dist_js/*
/dist_css/*
d_setting/*.php
*/d_setting/*.php
+2 -2
View File
@@ -12,8 +12,8 @@ require(__DIR__.'/../vendor/autoload.php');
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>설치</title>
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/common.js') ?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/common.js') ?>
<?=WebUtil::printJS('../e_lib/jquery.validate.min.js')?>
<?=WebUtil::printJS('../e_lib/sha512.min.js')?>
<?=WebUtil::printJS('../js/install.js')?>
+2 -4
View File
@@ -1,6 +1,6 @@
import { unwrap } from "./util/unwrap";
import jQuery from "jquery";
import $ from "jquery";
import 'bootstrap';
import axios from "axios";
@@ -308,10 +308,8 @@ export function errUnknown(): void {
alert('작업을 실패했습니다.');
}
export function errUnknownToast(): void {
jQuery.toast({
$.toast({
title: '에러!',
content: '작업을 실패했습니다.',
type: 'danger',
+2 -2
View File
@@ -17,8 +17,8 @@ require(__DIR__.'/../vendor/autoload.php');
<?=WebUtil::printCSS('../css/admin_member.css')?>
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/common.js') ?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/common.js') ?>
<?=WebUtil::printJS('../js/admin_member.js')?>
</head>
<body>
+6 -9
View File
@@ -28,18 +28,15 @@ $acl = $session->acl;
<?=WebUtil::printCSS('../d_shared/common.css')?>
<?=WebUtil::printCSS('../css/config.css')?>
<?=WebUtil::printCSS('../css/entrance.css')?>
<?=WebUtil::printCSS('../css/admin_server.css')?>
<!-- 액션 -->
<script>
var isAdmin = <?=($userGrade >= 5 || $acl)?'true':'false'?>;
</script>
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/common.js') ?>
<?=WebUtil::printJS('../js/entrance.js')?>
<?php if ($userGrade >= 5 || $acl): ?>
<!-- 운영자 -->
<?=WebUtil::printCSS('../css/admin_server.css')?>
<?=WebUtil::printJS('../js/admin_server.js')?>
<?php endif; ?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/entrance.js')?>
</head>
<body>
+67 -34
View File
@@ -1,4 +1,5 @@
<?php
namespace sammo;
require(__DIR__ . '/../vendor/autoload.php');
@@ -25,12 +26,13 @@ $session->setReadOnly();
if ($userGrade < 5 && !$acl) {
Json::die([
'result'=>'FAIL',
'msg'=>'운영자 권한이 없습니다.'
'result' => false,
'reason' => '운영자 권한이 없습니다.'
]);
}
function doServerModeSet($server, $action, &$response, $session){
function doServerModeSet($server, $action, Session $session): array
{
$serverList = ServConfig::getServerList();
$settingObj = $serverList[$server];
@@ -45,8 +47,7 @@ function doServerModeSet($server, $action, &$response, $session){
$doClose = false;
if ($userGrade >= 5) {
$doClose = true;
}
else if(in_array('openClose', $serverAcl)){
} else if (in_array('openClose', $serverAcl)) {
$doClose = true;
}
@@ -58,58 +59,90 @@ function doServerModeSet($server, $action, &$response, $session){
if ($localGameStorage->isunited) {
$doClose = true;
}
else if($localGameStorage->year < $localGameStorage->startyear + 2){
} else if ($localGameStorage->year < $localGameStorage->startyear + 2) {
$doClose = true;
} else{
return [
'result' => false,
'reason' => '서버 시작 직후, 또는 천하통일 이후에만 닫을 수 있습니다.'
];
}
}
if (!$doClose) {
if(in_array('reset', $serverAcl)){
$response['msg'] = '서버 시작 직후, 또는 천하통일 이후에만 닫을 수 있습니다.';
return [
'result' => false,
'reason' => '서버 닫기 권한이 부족합니다.'
];
}
else{
$response['msg'] = '서버 닫기 권한이 부족합니다.';
if (!$settingObj->closeServer()) {
return [
'result' => false,
'reason' => '닫기 실패'
];
}
return false;
return [
'result' => true,
'reason' => 'success'
];
}
return $settingObj->closeServer();
} elseif($action == 'reset' && $userGrade >= 6) {//리셋
if ($action == 'reset' && $userGrade >= 6) { //리셋
//FIXME: reset, reset_full 구현
if (file_exists($serverPath . '/d_setting/DB.php')) {
@unlink($serverPath . '/d_setting/DB.php');
}
$response['installURL'] = $serverDir."/install.php";
} elseif($action == 'open' && ($userGrade >= 5 || in_array('openClose', $serverAcl))) {//오픈
return $settingObj->openServer();
} else{
$response['msg'] = '올바르지 않은 요청입니다';
return false;
}
return true;
return [
'result' => true,
'reason' => 'success',
'installURL' => $serverDir . "/install.php"
];
}
function doAdminPost($action, $notice, $server, $session){
$response = ['result' => 'FAIL'];
if ($action == 'open') { //오픈
if($userGrade < 5 && !in_array('openClose', $serverAcl)){
return [
'result' => false,
'reason' => '서버 열기 권한이 부족합니다.'
];
}
if (!$settingObj->openServer()) {
return [
'result' => false,
'reason' => '오픈 실패'
];
}
return [
'result' => true,
'reason' => 'success'
];
}
return [
'result' => false,
'reason' => '올바르지 않은 요청입니다'
];
}
function doAdminPost($action, $notice, $server, Session $session): array
{
$response = ['result' => false];
$globalAcl = $session->acl['global'] ?? [];
$userGrade = $session->userGrade;
if ($action == 'notice' && ($userGrade >= 5 || in_array('notice', $globalAcl))) {
RootDB::db()->update('system', ['NOTICE' => $notice], true);
$response['result'] = 'SUCCESS';
return $response;
return [
'result' => true,
'reason' => 'success',
];
}
if(doServerModeSet($server, $action, $response, $session)){
$response['result'] = 'SUCCESS';
return $response;
}
return $response;
return doServerModeSet($server, $action, $session);
}
$response = doAdminPost($action, $notice, $server, $session);
+2 -2
View File
@@ -19,8 +19,8 @@ require(__DIR__.'/../vendor/autoload.php');
<!-- 액션 -->
<?=WebUtil::printJS('../d_shared/common_path.js') ?>
<?=WebUtil::printJS('../js/vendors.js') ?>
<?=WebUtil::printJS('../js/user_info.js')?>
<?=WebUtil::printJS('../dist_js/vendors.js') ?>
<?=WebUtil::printJS('../dist_js/user_info.js')?>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
+2 -2
View File
@@ -48,8 +48,8 @@ foreach(ServConfig::getServerList() as $setting){
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>삼국지 모의전투 HiDCHe</title>
<?= WebUtil::printJS('d_shared/common_path.js') ?>
<?= WebUtil::printJS('js/vendors.js') ?>
<?= WebUtil::printJS('js/common.js') ?>
<?= WebUtil::printJS('dist_js/vendors.js') ?>
<?= WebUtil::printJS('dist_js/common.js') ?>
<?= WebUtil::printCSS('d_shared/common.css') ?>
<?= WebUtil::printCSS('e_lib/bootstrap.min.css') ?>
-263
View File
@@ -1,263 +0,0 @@
var serverAdminTemplate = '\
<tr class="bg0 server_admin_<%name%>" data-server_name="<%name%>" data-is_root="<%isRoot%>" data-git-path="<%lastGitPath%>">\
<th style="color:<%color%>;"><%korName%>(<%name%>)</th>\
<td><%status%></td>\
<td><%version%></td>\
<td><button type="button" class="serv_act_close with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'close\');">폐쇄</button></td>\
<td><button type="button" class="serv_act_open with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'open\');">오픈</button></td>\
<td><a class="just_link" href="../<%name%>/install.php"><button type="button" class="serv_act_reset with_skin valid_if_set with_border obj_fill">리셋</button></a></td>\
<td><a class="just_link" href="../<%name%>/install_db.php"><button type="button" class="serv_act_hard_reset with_skin valid_if_installed only_admin with_border obj_fill">하드리셋</button></a></td>\
<td><button type="button" class="serv_act_login_close with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminClosedLogin(this);">폐쇄중 로그인</button></td>\
<td><button type="button" class="serv_act_119 with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminOpen119(this);">서버119</button></td>\
<td><button type="button" class="serv_act_update with_skin with_border obj_fill" onclick="serverUpdate(this);">업데이트</button></td>\
</tr>\
';
function serverUpdate(caller){
var $caller = $(caller);
var $tr = $caller.parents('tr');
var server = $tr.data('server_name');
var isRoot = $tr.data('is_root');
var target = $tr.data('gitPath');
if(typeof isRoot !== 'boolean'){
isRoot = (isRoot != 'false');
};
var allowFullUpdate = (server in window.aclList && window.aclList[server].indexOf('fullUpdate')>=0);
allowFullUpdate |= window.adminGrade > 5;
var allowUpdate = (server in window.aclList && window.aclList[server].indexOf('update')>=0);
allowUpdate |= window.adminGrade >= 5;
allowUpdate |= allowFullUpdate;
if(!allowUpdate){
alert('권한이 없습니다!');
return;
}
if(allowFullUpdate){
target = prompt('가져올 git tree-ish 명을 입력해주세요.', target)
if(!target){
return;
}
}
else if(isRoot){
if(!confirm('서버 라이브러리, 루트 서버에 대해 git pull을 실행합니다.')){
return;
}
}
else if (!confirm('다음 git tree-ish 주소로 업데이트를 시도합니다 : ' + target)) {
return;
}
$.ajax({
type:'post',
url:'../j_updateServer.php',
dataType:'json',
data:{
server: server,
target: target
}
}).then(function(response) {
if(response.result) {
var aux = '';
if(isRoot){
aux = ' (이미지 서버 갱신:{0}, {1})'.format(response.imgResult, response.imgDetail);
}
alert('{0} 서버가 {1} 버전으로 업데이트 되었습니다.{2}'.format(response.server, response.version, aux));
location.reload();
} else {
alert(response.reason);
}
}
);
}
function drawServerAdminList(serverList){
var $table = $('#server_admin_list');
var $showErrorLog = $('#showErrorLog');
if(serverList.grade >= 5){
$showErrorLog.show();
}
$.each(serverList.server, function(idx, server){
console.log(server);
var status = '';
if(!server.valid){
status = '에러, {0}'.format(server.reason);
}
else if(!server.run){
status = '폐쇄됨';
}
else{
status = '운영 중';
}
server.status = status;
var $tr = $(TemplateEngine(serverAdminTemplate, server));
$table.append($tr);
if(serverList.grade < 4){
$tr.find('button').prop('disabled', true);
}
if(!server.valid){
$tr.find('.valid_if_set').prop('disabled', true);
}
if(!server.installed){
$tr.find('.valid_if_installed').prop('disabled', true);
}
var aclByServer = serverList.acl[server.name];
$.each(aclByServer, function(idx, action){
console.log(action);
if(action == 'update' || action == 'fullUpdate'){
if(!server.installed){
return true;
}
$tr.find('.serv_act_update').prop('disabled', false);
$showErrorLog.show();
}
else if(action == 'openClose'){
if(!server.valid){
return true;
}
$tr.find('.serv_act_open, .serv_act_close').prop('disabled', false);
}
else if(action == 'reset'){
if(!server.installed){
return true;
}
$tr.find('.serv_act_reset, .serv_act_close').prop('disabled', false);
}
});
});
window.adminGrade = serverList.grade;
window.aclList = serverList.acl;
if(serverList.grade <= 5){
$table.find('.only_admin').prop('disabled', true);
}
}
$(function(){
Entrance_AdminImport();
Entrance_AdminInit();
Entrance_AdminUpdate();
$.ajax({
cache:false,
type:'post',
url:'j_server_get_admin_status.php',
dataType:'json'
}).then(drawServerAdminList);
});
function Entrance_AdminImport() {
}
function Entrance_AdminInit() {
console.log('adminInit');
$("#Entrance_000201").click(Entrance_Donation);
$("#Entrance_000202").click(Entrance_Member);
$("#notice_change_btn").click(Entrance_AdminChangeNotice);
}
function Entrance_AdminUpdate() {
}
function Entrance_Donation() {
$("#Entrance_00").hide();
$("#EntranceDonation_00").show();
EntranceDonation_Update();
}
function Entrance_Member() {
$("#Entrance_00").hide();
$("#EntranceMember_00").show();
EntranceMember_Update();
}
function Entrance_AdminChangeNotice() {
var notice = $("#notice_edit").val();
if(!confirm('정말 실행하시겠습니까?')){
return;
}
$.ajax({
type:'post',
url:'j_server_change_status.php',
dataType:'json',
data:{
action: 'notice',
notice: notice
}
}).then(function(response){
if(response.result == "SUCCESS") {
location.reload();
} else {
alert(response.msg);
}
});
}
function modifyServerStatus(caller, action) {
var $caller = $(caller);
var server = $caller.parents('tr').data('server_name');
if(!confirm('정말 실행하시겠습니까?')){
return;
}
$.ajax({
type:'post',
url:'j_server_change_status.php',
dataType:'json',
data:{
server: server,
action: action
}
}).then(function(response) {
if(response.result == "SUCCESS") {
if(action == 'reset') {
location.href = response.installURL;
} else {
location.reload();
}
} else {
alert(response.msg);
}
}
);
}
function Entrance_AdminNPCLogin(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/npc_login.php";
}
function Entrance_AdminNPCCreate(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/npc_join.php";
}
function Entrance_AdminClosedLogin(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/npc_login.php";
}
function Entrance_AdminOpen119(caller) {
var $caller = $(caller);
var serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir+"/_119.php";
}
function tryServerUpdateAndUpgrade(caller){
var $caller = $(caller);
}
-2
View File
File diff suppressed because one or more lines are too long
-1
View File
File diff suppressed because one or more lines are too long
-2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-2
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-3
View File
File diff suppressed because one or more lines are too long
-64
View File
@@ -1,64 +0,0 @@
/*
* [js-sha512]{@link https://github.com/emn178/js-sha512}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2018
* @license MIT
*/
/*!
* Bootstrap v4.6.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
/*!
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2021-02-16
*/
/*!
* jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2021-03-02T17:08Z
*/
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.1
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
File diff suppressed because one or more lines are too long
+332
View File
@@ -0,0 +1,332 @@
import $ from 'jquery';
import axios from 'axios';
import { setAxiosXMLHttpRequest } from '../hwe/ts/util/setAxiosXMLHttpRequest';
import { InvalidResponse } from '../hwe/ts/defs';
import { convertFormData } from '../hwe/ts/util/convertFormData';
import { TemplateEngine } from '../hwe/ts/common_legacy';
import { unwrap_any } from '../hwe/ts/util/unwrap_any';
import { unwrap } from '../hwe/ts/util/unwrap';
type ServerUpdateResponse = {
result: true,
version: string,
server: string,
imgResult: false,
}
type ServerRootUpdateResponse = {
result: true,
version: string,
server: string,
imgResult: true,
imgDetail: string,
}
type ServerStateItem = {
name: string,
korName: string,
color: string,
isRoot: boolean,
lastGitPath: string,
valid: boolean,
run: boolean,
installed: boolean,
version: string,
reason: string,
status?: string,
}
type ServerStateResponse = {
acl: Record<string, string[]>,
server: ServerStateItem[],
grade: number,
}
type ServerChangeResponse = {
result: true,
installURL?: string,
}
const serverAdminTemplate = '\
<tr class="bg0 server_admin_<%name%>" data-server_name="<%name%>" data-is_root="<%isRoot%>" data-git-path="<%lastGitPath%>">\
<th style="color:<%color%>;"><%korName%>(<%name%>)</th>\
<td><%status%></td>\
<td><%version%></td>\
<td><button type="button" class="serv_act_close with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'close\');">폐쇄</button></td>\
<td><button type="button" class="serv_act_open with_skin valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'open\');">오픈</button></td>\
<td><a class="just_link" href="../<%name%>/install.php"><button type="button" class="serv_act_reset with_skin valid_if_set with_border obj_fill">리셋</button></a></td>\
<td><a class="just_link" href="../<%name%>/install_db.php"><button type="button" class="serv_act_hard_reset with_skin valid_if_installed only_admin with_border obj_fill">하드리셋</button></a></td>\
<td><button type="button" class="serv_act_login_close with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminClosedLogin(this);">폐쇄중 로그인</button></td>\
<td><button type="button" class="serv_act_119 with_skin valid_if_set with_border obj_fill" onclick="Entrance_AdminOpen119(this);">서버119</button></td>\
<td><button type="button" class="serv_act_update with_skin with_border obj_fill" onclick="serverUpdate(this);">업데이트</button></td>\
</tr>\
';//TODO: npm install 관련 기능 추가, js/css output 경로 변경
declare global {
interface Window {
modifyServerStatus: (caller: HTMLElement, action: string) => void;
Entrance_AdminClosedLogin: (caller: HTMLElement) => void;
Entrance_AdminOpen119: (caller: HTMLElement) => void;
serverUpdate: (caller: HTMLElement) => void;
adminGrade: number;
aclList: Record<string, string[]>;
}
}
async function serverUpdate(caller: HTMLElement) {
const $caller = $(caller);
const $tr = $caller.parents('tr');
const server = unwrap_any<string>($tr.data('server_name'));
let isRoot: string | boolean = unwrap_any<string>($tr.data('is_root'));
let target = $tr.data('gitPath');
if (typeof isRoot !== 'boolean') {
isRoot = (isRoot != 'false');
}
let allowFullUpdate = (server in window.aclList && window.aclList[server].indexOf('fullUpdate') >= 0);
allowFullUpdate = allowFullUpdate || window.adminGrade > 5;
let allowUpdate = (server in window.aclList && window.aclList[server].indexOf('update') >= 0);
allowUpdate = allowUpdate || window.adminGrade >= 5;
allowUpdate = allowUpdate || allowFullUpdate;
if (!allowUpdate) {
alert('권한이 없습니다!');
return;
}
if (allowFullUpdate) {
target = prompt('가져올 git tree-ish 명을 입력해주세요.', target)
if (!target) {
return;
}
}
else if (isRoot) {
if (!confirm('서버 라이브러리, 루트 서버에 대해 git pull을 실행합니다.')) {
return;
}
}
else if (!confirm('다음 git tree-ish 주소로 업데이트를 시도합니다 : ' + target)) {
return;
}
let result: InvalidResponse | ServerUpdateResponse | ServerRootUpdateResponse;
try {
const response = await axios({
url: '../j_updateServer.php',
responseType: 'json',
method: 'post',
data: convertFormData({
server: server,
target: target
})
});
result = response.data;
} catch (e) {
console.error(e);
alert(`에러: ${e}`);
location.reload();
return;
}
if (!result.result) {
alert(`실패했습니다: ${result.reason}`);
return;
}
let aux = '';
if (result.imgResult) {
aux = ` (이미지 서버 갱신:${result.imgResult}, ${result.imgDetail})`;
}
alert(`${result.server} 서버가 ${result.version} 버전으로 업데이트 되었습니다.${aux}`);
}
function drawServerAdminList(serverList: ServerStateResponse) {
const $table = $('#server_admin_list');
const $showErrorLog = $('#showErrorLog');
if (serverList.grade >= 5) {
$showErrorLog.show();
}
$.each(serverList.server, function (idx, server) {
console.log(server);
let status: string;
if (!server.valid) {
status = '에러, {0}'.format(server.reason);
}
else if (!server.run) {
status = '폐쇄됨';
}
else {
status = '운영 중';
}
server.status = status;
const $tr = $(TemplateEngine(serverAdminTemplate, server));
$table.append($tr);
if (serverList.grade < 4) {
$tr.find('button').prop('disabled', true);
}
if (!server.valid) {
$tr.find('.valid_if_set').prop('disabled', true);
}
if (!server.installed) {
$tr.find('.valid_if_installed').prop('disabled', true);
}
const aclByServer = serverList.acl[server.name];
$.each(aclByServer, function (idx, action) {
console.log(action);
if (action == 'update' || action == 'fullUpdate') {
if (!server.installed) {
return true;
}
$tr.find('.serv_act_update').prop('disabled', false);
$showErrorLog.show();
}
else if (action == 'openClose') {
if (!server.valid) {
return true;
}
$tr.find('.serv_act_open, .serv_act_close').prop('disabled', false);
}
else if (action == 'reset') {
if (!server.installed) {
return true;
}
$tr.find('.serv_act_reset, .serv_act_close').prop('disabled', false);
}
});
});
window.adminGrade = serverList.grade;
window.aclList = serverList.acl;
if (serverList.grade <= 5) {
$table.find('.only_admin').prop('disabled', true);
}
}
export async function loadPlugin(): Promise<void> {
setAxiosXMLHttpRequest();
Entrance_AdminInit();
window.modifyServerStatus = modifyServerStatus;
window.Entrance_AdminClosedLogin = Entrance_AdminClosedLogin;
window.Entrance_AdminOpen119 = Entrance_AdminOpen119;
window.serverUpdate = serverUpdate;
const response = await axios({
url: 'j_server_get_admin_status.php',
method: 'post',
responseType: 'json'
});
drawServerAdminList(response.data);
}
function Entrance_AdminInit() {
console.log('adminInit');
$("#Entrance_000202").on('click', Entrance_Member);
$("#notice_change_btn").on('click', Entrance_AdminChangeNotice);
}
function Entrance_Member(e: JQuery.Event) {
e.preventDefault();
$("#Entrance_00").hide();
$("#EntranceMember_00").show();
}
async function Entrance_AdminChangeNotice(e: JQuery.Event) {
e.preventDefault();
const notice = unwrap_any<string>($("#notice_edit").val());
if (!confirm('정말 실행하시겠습니까?')) {
return;
}
let result: InvalidResponse | ServerChangeResponse;
try {
const response = await axios({
url: 'j_server_change_status.php',
method: 'post',
responseType: 'json',
data: convertFormData({
action: 'notice',
notice: notice
})
});
result = response.data;
}
catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
if (!result.result) {
alert(`실패했습니다: ${result.reason}`);
return;
}
location.reload();
}
async function modifyServerStatus(caller: HTMLElement, action: string) {
const $caller = $(caller);
const server = unwrap_any<string>($caller.parents('tr').data('server_name'));
if (!confirm('정말 실행하시겠습니까?')) {
return;
}
let result: InvalidResponse | ServerChangeResponse;
try {
const response = await axios({
url: 'j_server_change_status.php',
method: 'post',
responseType: 'json',
data: convertFormData({
server: server,
action: action
})
});
result = response.data;
}
catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
if (!result.result) {
alert(`실패했습니다: ${result.reason}`);
return;
}
if (action == 'reset') {
location.href = unwrap(result.installURL);
} else {
location.reload();
}
}
function Entrance_AdminClosedLogin(caller: HTMLElement) {
const $caller = $(caller);
const serverDir = $caller.parents('tr').data('server_name');
location.href = serverDir + "/npc_login.php";
}
function Entrance_AdminOpen119(caller: HTMLElement) {
const $caller = $(caller);
const serverDir = $caller.parents('tr').data('server_name');
location.href = `../${serverDir}/_119.php`;
}
+13 -7
View File
@@ -1,9 +1,12 @@
import axios from 'axios';
import $ from 'jquery';
import { initTooltip, TemplateEngine } from '../hwe/ts/common_legacy';
import { InvalidResponse } from './defs';
import { InvalidResponse } from '../hwe/ts/defs';
import { getDateTimeNow } from '../hwe/ts/util/getDateTimeNow';
import { setAxiosXMLHttpRequest } from '../hwe/ts/util/setAxiosXMLHttpRequest';
import { loadPlugin as loadAdminPlugin } from './admin_server';
declare const isAdmin: boolean;
const serverListTemplate = "\
<tr class='server_item bg0 server_name_<%name%>' data-server='<%name%>'>\
@@ -163,6 +166,9 @@ $(function ($) {
setAxiosXMLHttpRequest();
$("#btn_logout").on('click', Entrance_Logout);
void Entrance_UpdateServer();
if(isAdmin){
void loadAdminPlugin();
}
});
async function Entrance_UpdateServer() {
@@ -240,19 +246,19 @@ async function Entrance_drawServerList(serverInfos: ServerResponseItem[]) {
if (game.isUnited == 3) {
$serverHtml.find('.n_country').html('§이벤트 종료§');
$serverHtml.find('.server_date').html('{0} <br>~ {1}'.format(game.starttime, game.turntime));
$serverHtml.find('.server_date').html(`${game.starttime} <br>~ ${game.turntime}`);
} else if (game.isUnited == 1) {
$serverHtml.find('.n_country').html('§이벤트 진행중§');
$serverHtml.find('.server_date').html('{0} ~'.format(game.starttime));
$serverHtml.find('.server_date').html(`${game.starttime} ~`);
} else if (game.isUnited == 2) {
$serverHtml.find('.n_country').html('§천하통일§');
$serverHtml.find('.server_date').html('{0} <br>~ {1}'.format(game.starttime, game.turntime));
$serverHtml.find('.server_date').html(`${game.starttime} <br>~ ${game.turntime}`);
} else if (game.opentime <= now) {
$serverHtml.find('.n_country').html('<{0}국 경쟁중>'.format(game.nationCnt));
$serverHtml.find('.server_date').html('{0} ~'.format(game.starttime));
$serverHtml.find('.n_country').html(`<${game.nationCnt}국 경쟁중>`);
$serverHtml.find('.server_date').html(`${game.starttime} ~`);
} else {
$serverHtml.find('.n_country').html('-가오픈 중-');
$serverHtml.find('.server_date').html('{0} ~'.format(game.starttime));
$serverHtml.find('.server_date').html(`${game.starttime} ~`);
}
if (game.opentime <= now) {
+2 -2
View File
@@ -118,7 +118,7 @@ module.exports = (env) => {
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'js'),
path: path.resolve(__dirname, 'dist_js'),
},
mode: 'production',
devtool: 'source-map',
@@ -176,7 +176,7 @@ module.exports = (env) => {
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: '../css/[name].css'
filename: '../dist_css/[name].css'
}),
//new BundleAnalyzerPlugin()
],