80 lines
2.1 KiB
HTML

<div id="panels">
<div id="left_panel">
Zde budou uživatelé.
</div>
<div id="right_panel">
<button onclick="remove_user()" id="remove_btn">Odstranit Uživatele</button>
</div>
</div>
<script>
var right_panel_buffer = null;
var username = null;
$(document).ready(function()
{
$("#remove_btn").hide();
});
$.ajax
({
url: "./res/forum/api/list_users.php",
success: function(result)
{
let users = "";
for (let i in result.users)
{
users += "<div class=\"output\">" + result.users[i] + "</div>";
}
$("#left_panel").html(users);
}
});
$("#left_panel").on("click", ".output", function(event)
{
$("#remove_btn").show();
if (right_panel_buffer == null) right_panel_buffer = document.getElementById("right_panel").innerHTML;
username = event.target.innerHTML;
$.ajax
({
url: "./res/forum/api/user_info.php?username=" + event.target.innerHTML,
success: 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 output =
`Uživatelské jméno: ${result.username}<br>
Přezdívka: ${result.nickname}<br>
Admin: ${result.admin}<br>
Pohlaví: ${sex}<br>
Bio: ${result.bio}<br>`;
$("#right_panel").html(output + right_panel_buffer);
}
});
});
function remove_user()
{
$.ajax
({
url: "./res/forum/api/remove_user.php?username=" + username,
success: function(result)
{
//location.reload();
show("admin");
}
});
}
</script>