infopage/public/home.html

78 lines
2.4 KiB
HTML
Raw Permalink Normal View History

2024-02-26 17:33:35 -05:00
<!DOCTYPE html>
<html>
<head>
<title>Home - InfoPage</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="/css/base.css">
<link rel="stylesheet" href="/css/home.css">
<script src="/js/base.js"></script>
<script>
if (localStorage.getItem("token")) {
setCookie("token", localStorage.getItem("token"));
} else {
window.location.href = "/logout";
}
let public = eval("{{PUBLIC}}");
</script>
</head>
<body>
<h1>Welcome, {{DISPL_NAME}}!</h1>
<div tabindex="1" onclick="window.location.href = '/editor'" class="home-container">
2024-02-26 17:33:35 -05:00
<p>Edit your profile</p>
{{DISPL_NAME}} (@{{USERNAME}})<br>
</div>
<div tabindex="2" onclick="toggleVisibility()" class="home-container">
2024-02-26 17:33:35 -05:00
<p>Toggle visibility</p>
Visibility: <span id="public-thing"></span>Public
</div>
<div tabindex="3" onclick="window.location.href = '/browse'" class="home-container">
2024-02-26 17:33:35 -05:00
<p>Browse other profiles</p>
Total public profiles: <span id="total">{{TOTAL}}</span>
</div>
<div tabindex="4" onclick="window.location.href = '/u/{{USERNAME}}'" class="home-container">
2024-02-26 17:33:35 -05:00
<p>Preview your profile</p>
Shortened url:<br>
https://infopg.web.app/u/{{USERNAME}}
</div>
<div tabindex="5" onclick="window.location.href = '/logout'" class="home-container">
<p>Log out</p>
You can always log back in
</div>
<div tabindex="6" onclick="window.location.href = '/settings'" class="home-container">
<p>User Settings</p>
Change password, delete acc, etc.
</div>
2024-02-26 17:33:35 -05:00
<script>
[...document.querySelectorAll("[onclick][tabindex]")].forEach(function(val, index) {
val.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode === 13 || event.keyCode === 32) {
val.click();
}
});
})
2024-02-26 17:33:35 -05:00
dom("public-thing").innerText = public ? "" : "Not "
function toggleVisibility() {
public = !public;
dom("public-thing").innerText = public ? "" : "Not ";
dom("total").innerText = +dom("total").innerText + (public ? 1 : -1);
fetch( "/api/save", {
"method": "PATCH",
"body": JSON.stringify({
"public": public
})
});
}
</script>
</body>
</html>