feat: GeneralList를 API로 이동

This commit is contained in:
2022-04-07 03:03:38 +09:00
committed by Hide_D
parent 9d9c66ba08
commit 29c3a933e9
6 changed files with 194 additions and 330 deletions
+26 -15
View File
@@ -270,7 +270,7 @@ function printGenerals(value: NPCToken) {
function printGeneralList(value: GeneralListResponse) {
console.log(value);
const tokenList = value.token;
const generalList:NPCPickPrintable[] = value.list.map((rawGeneral) => {
const generalList: NPCPickPrintable[] = value.list.map((rawGeneral) => {
const general: NPCPickPrintableR = {
no: rawGeneral[0],
picture: rawGeneral[1],
@@ -317,7 +317,7 @@ function printGeneralList(value: GeneralListResponse) {
}
if (general.reserved == 1) {
general.nameAux += `<br><small>(${tokenList[general.no]}회)</small>`;
general.nameAux += `<br><small>(${tokenList[general.no]}회)</small>`;
}
@@ -369,7 +369,7 @@ function printGeneralList(value: GeneralListResponse) {
_printGeneralList(true);
}
function _printGeneralList(clear?:boolean) {
function _printGeneralList(clear?: boolean) {
const $generalTable = $('#general_list');
if (clear) {
$generalTable.empty();
@@ -438,20 +438,31 @@ $(function ($) {
}, errUnknown);
});
$('#btn_load_general_list').click(function () {
$.post({
url: 'j_get_general_list.php',
dataType: 'json',
data: {
with_token: true
}
}).then(function (result) {
$('#btn_load_general_list').click(async function () {
let result: InvalidResponse | GeneralListResponse;
try {
const response = await axios({
url: "api.php",
method: "post",
responseType: "json",
data: {
path: "Global/GeneralList",
args: {
with_token: true,
},
},
});
result = response.data;
if (!result.result) {
alert(result.reason);
return false;
throw result.reason;
}
printGeneralList(result);
}, errUnknown);
} catch (e) {
console.error(e);
alert(`실패했습니다: ${e}`);
return;
}
printGeneralList(result);
});
$('#btn_print_more').click(function () {