From 66b2ffb37a07b33df41a9bc331c51d52e52558ca Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 22 May 2024 18:09:05 +0200 Subject: [PATCH] moved info injection into new function --- res/forum/admin/admin.html | 41 +++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/res/forum/admin/admin.html b/res/forum/admin/admin.html index ceea4fe..3a532c1 100644 --- a/res/forum/admin/admin.html +++ b/res/forum/admin/admin.html @@ -35,24 +35,7 @@ username = event.target.innerHTML; - $.ajax - ({ - url: "./res/forum/api/user_info.php?username=" + event.target.innerHTML, - success: async function(result) - { - let admin_select = await selection("admin", result.admin); - let sex_select = await selection("sex", result.sex); - - let output = - `Uživatelské jméno:
- Přezdívka:
- Admin: ${admin_select}
- Pohlaví: ${sex_select}
- Bio:
`; - - $("#right_panel").html(output + right_panel_buffer); - } - }); + inject_info("#right_panel", username); }); function remove_user() @@ -101,4 +84,26 @@ }) }); } + + function inject_info(id, username) + { + $.ajax + ({ + url: "./res/forum/api/user_info.php?username=" + username, + success: async function(result) + { + let admin_select = await selection("admin", result.admin); + let sex_select = await selection("sex", result.sex); + + let output = + `Uživatelské jméno:
+ Přezdívka:
+ Admin: ${admin_select}
+ Pohlaví: ${sex_select}
+ Bio:
`; + + $(id).html(output + right_panel_buffer); + } + }); + } \ No newline at end of file