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));
}
})
});
}
function inject_info(id, username, postfix)
{
$.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 + postfix);
}
});
}
function update_user(old_username, username, nickname, admin, sex, bio, refresh)
{
$.ajax
({
url: "./res/forum/api/update_user.php" +
"?old_username=" + old_username +
"&username=" + username +
"&nickname=" + nickname +
"&admin=" + admin +
"&sex=" + sex +
"&bio=" + bio,
success: function(result)
{
show(refresh);
}
});
}