86 lines
2.5 KiB
HTML
86 lines
2.5 KiB
HTML
<div id="panels">
|
|
<div id="left_panel">
|
|
Zde budou uživatelé.
|
|
</div>
|
|
<div id="right_panel">
|
|
<div id="buttons">
|
|
<button 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;
|
|
|
|
$.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: <input class="editable" type="text" value="${result.username}"><br>
|
|
Přezdívka: <input class="editable" type="text" value="${result.nickname}"><br>
|
|
Admin: ${admin_select}<br>
|
|
Pohlaví: ${sex_select}<br>
|
|
Bio: <input class="editable" type="text" value="${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");
|
|
}
|
|
});
|
|
}
|
|
|
|
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> |