87 lines
2.6 KiB
HTML
87 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>ZYM's Book Store</title>
|
|
<link rel="stylesheet" href="basic.css">
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<h1>ZYM's Book Store</h1>
|
|
<div class="user-bar">
|
|
<span>Welcome, <span id="username">[Guest]</span></span>
|
|
<div class="action-button-container" onmouseover="showDropdown()" onmouseout="hideDropdown()">
|
|
<div class="action-button">Actions</div>
|
|
<div class="dropdown">
|
|
<div class="dropdown-content">
|
|
<a href="/login">Login</a>
|
|
<a href="#" onclick="(async () => { await Request('logout'); await UpdateUserInfo(); location.reload();})(); return false;">Logout</a>
|
|
<a href="/register">Register</a>
|
|
<a href="/passwd">Change Password</a>
|
|
<a href="/admin">Admin Panel</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="main-content">
|
|
<nav>
|
|
<a href="#">Search Books</a>
|
|
<a href="#">Purchase Books</a>
|
|
</nav>
|
|
<div class="content">
|
|
<!-- Your content goes here -->
|
|
<p>FBI warning: This is a homework demo, not a real bookstore system. Data privacy and safety is not guaranteed as any bug could happen.</p>
|
|
<p>User mannual can be found at <a href="https://github.com/happyZYM/BH-Bookstore-2023/" target="_blank">here</a></p>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/socket.io/socket.io.js"></script>
|
|
<script src="/communication.js"></script>
|
|
<script>
|
|
function showDropdown() {
|
|
document.querySelector('.dropdown-content').style.display = 'block';
|
|
}
|
|
|
|
function hideDropdown() {
|
|
document.querySelector('.dropdown-content').style.display = 'none';
|
|
}
|
|
function ChangeUsername(newUsername) {
|
|
document.getElementById('username').textContent = newUsername;
|
|
}
|
|
async function UpdateUserInfo(){
|
|
let nm=await GetMyName();
|
|
let pri=await GetMyPrivilege();
|
|
if(nm=='')
|
|
{
|
|
await RefreshSession();
|
|
nm=await GetMyName();
|
|
pri=await GetMyPrivilege();
|
|
}
|
|
if(pri==0)
|
|
{
|
|
ChangeUsername("[Guest]");
|
|
}
|
|
else if(pri==1)
|
|
{
|
|
ChangeUsername(nm);
|
|
}
|
|
else if(pri==3)
|
|
{
|
|
ChangeUsername(nm+" [Worker]");
|
|
}
|
|
else if(pri==7)
|
|
{
|
|
ChangeUsername(nm+" [Admin]");
|
|
}
|
|
}
|
|
document.addEventListener('SessionReady', async () => {
|
|
console.log("receive event session ready");
|
|
await UpdateUserInfo();
|
|
});
|
|
</script>
|
|
<script src="/sessioninit.js"></script>
|
|
</body>
|
|
</html> |