87 lines
2.4 KiB
HTML
87 lines
2.4 KiB
HTML
<div id="panels">
|
|
<div id="left_panel">
|
|
Zde budou uživatelé.
|
|
</div>
|
|
<div id="right_panel">
|
|
<div id="buttons">
|
|
<button onclick="update_user()" class="btn">Uložit Změny</button>
|
|
<button onclick="remove_user()" class="btn">Odstranit Uživatele</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
var right_panel_buffer = null;
|
|
var username = null;
|
|
|
|
$.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)
|
|
{
|
|
$("#buttons").show();
|
|
if (right_panel_buffer == null) right_panel_buffer = document.getElementById("right_panel").innerHTML;
|
|
|
|
username = event.target.innerHTML;
|
|
|
|
inject_info("#right_panel", username, right_panel_buffer);
|
|
});
|
|
|
|
function remove_user()
|
|
{
|
|
$.ajax
|
|
({
|
|
url: "./res/forum/api/remove_user.php?username=" + username,
|
|
success: function(result)
|
|
{
|
|
//location.reload();
|
|
show("admin");
|
|
}
|
|
});
|
|
}
|
|
|
|
function update_user()
|
|
{
|
|
$.ajax
|
|
({
|
|
url: "./res/forum/api/update_user.php" +
|
|
"?old_username=" + username +
|
|
"&username=" + document.getElementById("username").value +
|
|
"&nickname=" + document.getElementById("nickname").value +
|
|
"&admin=" + document.getElementById("admin").value +
|
|
"&sex=" + document.getElementById("sex").value +
|
|
"&bio=" + document.getElementById("bio").value,
|
|
success: function(result)
|
|
{
|
|
show("admin");
|
|
}
|
|
});
|
|
}
|
|
|
|
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));
|
|
}
|
|
})
|
|
});
|
|
}
|
|
</script> |