let main_panel_buffer = null; function show(file) { if (main_panel_buffer == null) main_panel_buffer = document.getElementById("main_panel").innerHTML; $.ajax ({ url: "./res/forum/" + file + "/" + file + ".html", dataType: "html", success: function(data) { $("#main_panel").html(main_panel_buffer + data); } }); } 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)); } }) }); } async function inject_info(id, username, postfix) { let am_i_admin = await is_admin(); $.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 = ((am_i_admin) ? `Uživatelské jméno:
` : ``) + `Přezdívka:
` + ((am_i_admin) ? `Admin: ${admin_select}
` : ``) + `Pohlaví: ${sex_select}
Bio:
`; $(id).html(output + postfix); } }); } async function update_user(old_username, username, nickname, admin, sex, bio, refresh) { let am_i_admin = await is_admin(); $.ajax ({ url: "./res/forum/api/update_user.php" + "?old_username=" + old_username + "&nickname=" + nickname + "&sex=" + sex + "&bio=" + bio + ((am_i_admin) ? "&username=" + username + "&admin=" + admin : ""), success: function(result) { show(refresh); } }); } function is_admin() { return new Promise(function(resolve) { $.ajax ({ url: "./res/forum/api/is_admin.php", success: function(result) { resolve(result.admin); } }) }); }