added login

This commit is contained in:
didier amyot committed 2023-12-11 11:59:30 -05:00
1 parent 171657d616
commit 0cb2d25a62
3 files changed
+137 -26

No files matched your search

+29 -2
View File
@@ -12,17 +12,44 @@
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" href="https://bulma.io">
<a class="navbar-item" href="#" hx-post="/api/v1/logout">
<img src="images/js_logo.svg" alt="js logo" style="height: 100%">
<h2 class="title is-3 ml-1">Reading Exercices</h2>
</a>
</div>
</div>
</nav>
<div hx-get="/api/v1/random-questions/dsdsddsf/4"
<div hx-get="/api/v1/random-questions/:seed/:defaultIndex"
hx-trigger="load"
id="question-body">
</div>
<script>
function getDefaultIndex(){
if(document.location.hash.length > 1){
return document.location.hash.substr(1)
}
return localStorage.getItem("defaultIndex") || '0';
}
document.body.addEventListener('htmx:configRequest', function(evt) {
evt.detail.headers.session = localStorage.getItem("seed");
evt.detail.path = evt.detail.path.replace(":seed", localStorage.getItem("seed"));
evt.detail.path = evt.detail.path.replace(":defaultIndex", getDefaultIndex());
});
document.body.addEventListener('logout', function (evt) {
window.localStorage.clear();
document.location.href = "/login.html";
});
document.body.addEventListener('set-question-id', function (evt) {
if(isNaN(evt.detail.value)){
return;
}
document.location.hash = evt.detail.value
localStorage.setItem("defaultIndex", evt.detail.value);
});
</script>
</body>
</html>