diff --git a/res/forum/admin/admin.html b/res/forum/admin/admin.html index 1ab2c8e..0772a94 100644 --- a/res/forum/admin/admin.html +++ b/res/forum/admin/admin.html @@ -38,26 +38,17 @@ $.ajax ({ url: "./res/forum/api/user_info.php?username=" + event.target.innerHTML, - success: function(result) + success: async function(result) { - var sex_codes = - { - 0: "Nespecifikováno", - 1: "Muž", - 2: "Žena", - 9: "Jiné", - default: "???" - }; - - let sex = sex_codes[result.sex] || sex_codes.default; - let admin = result.admin == 0 ? "Ne" : "Ano"; + let admin_select = await selection("admin", result.admin); + let sex_select = await selection("sex", result.sex); let output = - `Uživatelské jméno: ${result.username}
- Přezdívka: ${result.nickname}
- Admin: ${admin}
- Pohlaví: ${sex}
- Bio: ${result.bio}
`; + `Uživatelské jméno:
+ Přezdívka:
+ Admin: ${admin_select}
+ Pohlaví: ${sex_select}
+ Bio:
`; $("#right_panel").html(output + right_panel_buffer); } @@ -76,4 +67,20 @@ } }); } + + function selection(type, value) + { + return new Promise(function(resolve) + { + $.ajax + ({ + url: "./res/forum/admin/" + type + "_selection.html", + dataType: "html", + success: function(result) + { + resolve(result.replace("value=\"" + value, "selected value=\"" + value)); + } + }) + }); + } \ No newline at end of file