把基本的javscript代码也复用了

This commit is contained in:
2023-12-17 01:16:30 +00:00
parent 5d120e7439
commit eceace3785
7 changed files with 44 additions and 180 deletions

View File

@ -79,43 +79,8 @@
<script src="/socket.io/socket.io.js"></script>
<script src="/communication.js"></script>
<script src="/basic.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 () => {
await UpdateUserInfo();
if((await GetMyPrivilege())<3)