made the index webpage into two parts

added register/login links when not logged in
when logged in, chat and profile links are shown
This commit is contained in:
Mystikfluu 2022-05-26 14:37:13 +02:00
parent eee57759f9
commit 69790c32d5
2 changed files with 32 additions and 12 deletions

8
js/index.js Normal file
View File

@ -0,0 +1,8 @@
window.addEventListener("load",async function(){
let data = await(await fetch("/api/getuser")).json()
if(data["username"] != undefined) {
document.getElementById("HasAccount").style=""
} else {
document.getElementById("NoAccount").style=""
}
})

View File

@ -1,27 +1,39 @@
<head>
<style media="screen">
a {
color: red;
text-decoration: none;
}
</style>
<link rel="stylesheet" href="/css/logon.css">
<script src="/js/index.js" charset="utf-8"></script>
</head>
<body>
<header>
<h1>Auth website</h1>
<h1>IPost</h1>
</header>
<main>
<form id="login_form" class="form_class" action="login" method="post">
<div class="info_div">
IPost is a revolutionary chatting website <br>
featuring an innovative design <br>
<br>
<br>
<div id="NoAccount" style="display:none;">
<span>Do you not have an account? <a href="register">Register now!</a></span>
<br>
<br>
<span>Do you already have an account? <a href="login">Login now!</a></span>
<br>
<br>
<span>This is open source, find more about this project <a href="https://github.com/Mystikfluu/authwebsite">on github</a></span>
</div>
<div id="HasAccount" style="display:none;">
<span>Here to chat? <a href="posts">Chat now!</a></span>
<br>
<br>
<span>Just want a quick look at your profile? <a href="user">your profile</a></span>
<br>
<br>
</div>
<span>This is open source, find more about this project <a href="https://github.com/002Hub/IPost">on github</a></span>
<br>
<br>
</div>