forked from devsam/core
js2ts-fix: install
This commit is contained in:
+13
-13
@@ -45,7 +45,7 @@ if($session->userGrade < 5 && !$allowReset){
|
||||
<h3 class="card-header">
|
||||
설치(환경 설정)
|
||||
<!--턴시간, 시간동기화, 시나리오, 상성, 확장장수, NPC유저, 이미지설정-->
|
||||
</h3>
|
||||
</h3>
|
||||
<div class="card-body">
|
||||
<form id="game_form" method="post" action="#">
|
||||
<div class="form-group row">
|
||||
@@ -80,7 +80,7 @@ if($session->userGrade < 5 && !$allowReset){
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="sync" class="col-sm-3 col-form-label">시간 동기화</label>
|
||||
<div class="col-sm-9" style="display: inline-flex;">
|
||||
@@ -91,7 +91,7 @@ if($session->userGrade < 5 && !$allowReset){
|
||||
<label class="btn btn-secondary">
|
||||
<input type="radio" name="sync" value="0">N
|
||||
</label>
|
||||
|
||||
|
||||
</div>
|
||||
<small class="text-muted">
|
||||
시간 단위에 맞게 년/월이 설정됩니다. <br>예: 120분(오전1시=1월), 60분(오전/오후 1시=1월)
|
||||
@@ -104,7 +104,7 @@ if($session->userGrade < 5 && !$allowReset){
|
||||
<div class="col-sm-9">
|
||||
<select class="form-control" name="scenario" size="1" id="scenario_sel">
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -168,30 +168,30 @@ if($session->userGrade < 5 && !$allowReset){
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-3 col-form-label">휴식 턴 시 장수 턴</label>
|
||||
<label class="col-sm-3 col-form-label" id="autorun_set_label">휴식 턴 시 장수 턴</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend btn-group btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="develop" name="autorun_develop" id="autorun_develop">내정
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="develop" name="autorun_user[]" value="develop">내정
|
||||
</label>
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="warp" name="autorun_warp" id="autorun_warp">순간이동
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="warp" name="autorun_user[]" value="warp">순간이동
|
||||
</label>
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="recruit" name="autorun_recruit" id="autorun_recruit">징병
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="recruit" name="autorun_user[]" value="recruit">징병
|
||||
</label>
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="recruit_high" name="autorun_recruit_high" id="autorun_recruit_high">모병
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="recruit_high" name="autorun_user[]" value="recruit_high">모병
|
||||
</label>
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="train" name="autorun_train" id="autorun_train">훈사
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="train" name="autorun_user[]" value="train">훈사
|
||||
</label>
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="battle" name="autorun_battle" id="autorun_battle">출병
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="battle" name="autorun_user[]" value="battle">출병
|
||||
</label>
|
||||
<label class="btn btn-secondary">
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="chief" name="autorun_chief" id="autorun_chief">기본 사령턴
|
||||
<input type="checkbox" class="autorun_user_chk" data-key="chief" name="autorun_user[]" value="chief">기본 사령턴
|
||||
</label>
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
@@ -366,7 +366,7 @@ if($session->userGrade < 5 && !$allowReset){
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><td colspan="2">
|
||||
|
||||
|
||||
</td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+46
-43
@@ -4,9 +4,7 @@ import { setAxiosXMLHttpRequest } from "./util/setAxiosXMLHttpRequest";
|
||||
import axios from "axios";
|
||||
import { InvalidResponse } from "./defs";
|
||||
import { Rules } from "async-validator";
|
||||
import { isArray } from "lodash";
|
||||
import { JQValidateForm } from "./util/jqValidateForm";
|
||||
import { unwrap } from "./util";
|
||||
import { convertFormData } from "./util/convertFormData";
|
||||
|
||||
type ResponseScenarioItem = {
|
||||
@@ -121,95 +119,97 @@ function scenarioPreview() {
|
||||
if (scenario.npcEx_cnt == 0) {
|
||||
$npcEx.html('');
|
||||
} else {
|
||||
$npcEx.html('+{0}명'.format(scenario.npcEx_cnt));
|
||||
$npcEx.html(`+${scenario.npcEx_cnt}명`);
|
||||
}
|
||||
|
||||
$nation.html('');
|
||||
$.each(scenario.nation, function (idx, nation) {
|
||||
$nation.append('<span style="color:{0}">{1}</span> {2}명. {3}<br>'.format(
|
||||
nation.color, nation.name, nation.generals, nation.cities.join(', ')
|
||||
));
|
||||
$nation.append(`<span style="color:${nation.color}">${nation.name}</span> ${nation.generals}명. ${nation.cities.join(', ')}<br>`);
|
||||
});
|
||||
}
|
||||
|
||||
const descriptor: Rules = {
|
||||
turnterm: {
|
||||
required: true,
|
||||
type: "enum",
|
||||
enum: [1, 2, 5, 10, 20, 30, 60, 120],
|
||||
transform: parseInt,
|
||||
},
|
||||
sync: {
|
||||
required: true,
|
||||
type: "enum",
|
||||
enum: [1, 0],
|
||||
transform: parseInt,
|
||||
},
|
||||
scenario: {
|
||||
required: true,
|
||||
},
|
||||
fiction: {
|
||||
required: true,
|
||||
type: "integer",
|
||||
transform: parseInt,
|
||||
},
|
||||
extend: {
|
||||
required: true,
|
||||
type: "integer",
|
||||
transform: parseInt,
|
||||
},
|
||||
npcmode: {
|
||||
required: true,
|
||||
type: "integer",
|
||||
transform: parseInt,
|
||||
},
|
||||
show_img_level: {
|
||||
required: true,
|
||||
type: "integer",
|
||||
transform: parseInt,
|
||||
},
|
||||
tournament_trig: {
|
||||
required: true,
|
||||
type: "integer",
|
||||
transform: parseInt,
|
||||
},
|
||||
join_mode: {
|
||||
required: true,
|
||||
type: "enum",
|
||||
enum: ["full", "onlyRandom"]
|
||||
},
|
||||
autorun_user: {
|
||||
type: 'array',
|
||||
required: false,
|
||||
defaultField: {
|
||||
type: 'enum',
|
||||
enum: ['develop', 'warp', 'recruit', 'recruit-high', 'train', 'battle']
|
||||
enum: ['develop', 'warp', 'recruit', 'recruit_high', 'train', 'battle']
|
||||
},
|
||||
},
|
||||
autorun_user_minutes: {
|
||||
type: 'number',
|
||||
type: 'integer',
|
||||
required: true,
|
||||
transform: parseInt,
|
||||
min: 0,
|
||||
validator: (rule, value, _callback, source) => {
|
||||
if (!isArray(source.autorun_user)) {
|
||||
return new Error('옵션이 올바른 타입이 아닙니다.');
|
||||
if(value == 0 && !source.autorun_user?.length){
|
||||
return true;
|
||||
}
|
||||
if (source.autorun_user.length == 0 && parseInt(value) > 0) {
|
||||
return new Error('유효 시간과 옵션은 동시에 설정해야합니다.');
|
||||
if(value != 0 && source.autorun_user?.length){
|
||||
return true;
|
||||
}
|
||||
return new Error('유효 시간과 옵션은 동시에 설정해야합니다.');
|
||||
}
|
||||
},
|
||||
reserve_open: {
|
||||
type: 'pattern',
|
||||
pattern: new RegExp(/\d{4,4}-\d{2,2}-\d{2,2} \d{2,2}:\d{2,2}/)
|
||||
},
|
||||
pre_reserve_open: {
|
||||
type: 'pattern',
|
||||
pattern: new RegExp(/\d{4,4}-\d{2,2}-\d{2,2} \d{2,2}:\d{2,2}/)
|
||||
}
|
||||
};
|
||||
|
||||
function formSetup() {
|
||||
|
||||
const autorunMap: Map<string, string> = new Map([
|
||||
['autorun_develop', 'develop'],
|
||||
['autorun_warp', 'warp'],
|
||||
['autorun_recruit', 'recruit'],
|
||||
['autorun_recruit_high', 'recruit_high'],
|
||||
['autorun_train', 'train'],
|
||||
['autorun_battle', 'battle'],
|
||||
['autorun_chief', 'chief'],
|
||||
]);
|
||||
const validator = new JQValidateForm($('#game_form'), descriptor, {
|
||||
postParse: (values) => {
|
||||
const newValues: Record<string, string | string[]> & { autorun_user: string[] } = {
|
||||
autorun_user: []
|
||||
};
|
||||
for (const [key, value] of Object.entries(values)) {
|
||||
if (!autorunMap.has(key)) {
|
||||
newValues[key] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
const convValue = unwrap(autorunMap.get(key));
|
||||
newValues.autorun_user.push(convValue);
|
||||
}
|
||||
return newValues;
|
||||
}
|
||||
});
|
||||
const validator = new JQValidateForm($('#game_form'), descriptor);
|
||||
validator.installChangeHandler();
|
||||
|
||||
$('#game_form').on('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
@@ -219,7 +219,7 @@ function formSetup() {
|
||||
}
|
||||
|
||||
let result: InvalidResponse;
|
||||
try{
|
||||
try {
|
||||
const response = await axios({
|
||||
url: 'j_install.php',
|
||||
method: 'post',
|
||||
@@ -228,12 +228,12 @@ function formSetup() {
|
||||
});
|
||||
result = response.data;
|
||||
}
|
||||
catch(e){
|
||||
catch (e) {
|
||||
alert(`알수 없는 에러: ${e}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!result.result){
|
||||
if (!result.result) {
|
||||
alert(result.reason);
|
||||
return;
|
||||
}
|
||||
@@ -248,4 +248,7 @@ $(async function () {
|
||||
void loadScenarios();
|
||||
$('#scenario_sel').on('change', scenarioPreview);
|
||||
formSetup();
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
window.$ = $;
|
||||
@@ -20,9 +20,9 @@ jQuery(async function ($) {
|
||||
},
|
||||
db_port: {
|
||||
type: 'integer',
|
||||
validator: (rule, value: string) => {
|
||||
const num = parseInt(value);
|
||||
if (num <= 0 || num >= 65535) {
|
||||
transform: parseInt,
|
||||
validator: (rule, value: number) => {
|
||||
if (value <= 0 || value >= 65535) {
|
||||
return new Error('올바른 포트 범위가 아닙니다.');
|
||||
}
|
||||
return true;
|
||||
@@ -43,7 +43,6 @@ jQuery(async function ($) {
|
||||
};
|
||||
const validator = new JQValidateForm($('#db_form'), descriptor);
|
||||
validator.installChangeHandler();
|
||||
|
||||
$('#db_form').on('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -67,7 +66,6 @@ jQuery(async function ($) {
|
||||
alert(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!data.result){
|
||||
alert(`에러: ${data.reason}`);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user