Add stats_single page & header with links

This commit is contained in:
2021-02-04 19:53:28 +01:00
parent 597101ed47
commit 5fa1819bea
15 changed files with 285 additions and 232 deletions

View File

@ -1,72 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
{{> head}}
<body>
<script>
function toggle_category(id) {
// Find out whether the button is in active (play) or inactive (paused) state
let toggled_class = "category_button_toggled";
let cl = document.getElementById("toggle-button-" + id).classList;
let active = cl.contains(toggled_class);
<link rel="icon" type="image/svg+xml" href="/static/icon.svg">
<link rel="stylesheet" href="/static/styles/common.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu|Ubuntu+Mono&display=swap">
// Get the corresponding route to activate/inactivate the category
let url;
if(active) {
url = "/category/" + id + "/end_session";
cl.remove(toggled_class);
} else {
url = "/category/" + id + "/start_session";
cl.add(toggled_class);
}
<title>stl</title>
<script>
function toggle_category(id) {
// Find out whether the button is in active (play) or inactive (paused) state
let toggled_class = "category_button_toggled";
let cl = document.getElementById("toggle-button-" + id).classList;
let active = cl.contains(toggled_class);
//var params = "lorem=ipsum&name=alpha";
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
// Get the corresponding route to activate/inactivate the category
let url;
if(active) {
url = "/category/" + id + "/end_session";
cl.remove(toggled_class);
} else {
url = "/category/" + id + "/start_session";
cl.add(toggled_class);
}
//Send the proper header information along with the request
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//var params = "lorem=ipsum&name=alpha";
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.send();
}
</script>
//Send the proper header information along with the request
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
{{> header}}
xhr.send();
}
</script>
</head>
<body>
<h1 class="title">stl</h1>
<ul class="striped_list">
{{#each categories}}
<li class="category_entry">
<div class="category_icon"
style="background-color: {{this.1.color}}"
></div>
<span class="category_name">{{this.1.name}}</span>
{{#if this.1.started}}
<form action="/category/{{this.0}}/bump_session/minutes/5", method="post">
<button style="height: 100%; color: green;" type="submit">+5</button>
</form>
{{/if}}
<div class="category_button_container">
<button
id="toggle-button-{{this.0}}"
onClick="toggle_category('{{this.0}}')"
{{#if this.1.started}}
class="category_button category_button_toggled"
{{else}}
class="category_button"
{{/if}}>
</button>
</div>
</li>
{{/each}}
</ul>
</body>
<ul class="striped_list">
{{#each categories}}
<li class="category_entry">
<div class="category_icon"
style="background-color: {{this.1.color}}"
></div>
<span class="category_name">{{this.1.name}}</span>
{{#if this.1.started}}
<form action="/category/{{this.0}}/bump_session/minutes/5", method="post">
<button style="height: 100%; color: green;" type="submit">+5</button>
</form>
{{/if}}
<div class="category_button_container">
<button
id="toggle-button-{{this.0}}"
onClick="toggle_category('{{this.0}}')"
{{#if this.1.started}}
class="category_button category_button_toggled"
{{else}}
class="category_button"
{{/if}}>
</button>
</div>
</li>
{{/each}}
</ul>
</body>
</html>