This commit is contained in:
2020-10-27 01:41:50 +01:00
parent c709ca2166
commit 11aa131186
16 changed files with 2706 additions and 5 deletions

29
templates/history.hbs Normal file
View File

@ -0,0 +1,29 @@
<!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="">
<link rel="icon" type="image/png" href="/static/icon.png">
<link rel="stylesheet" href="/static/styles.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu|Ubuntu+Mono&display=swap">
<title>stl</title>
</head>
<body>
<h1 class="title">stl</h1>
<div class="history_list">
{{#each sessions}}
<div class="history_entry">
<span class="history_entry_category">{{this.0.name}}</span>
<span> from </span>
<span class="history_entry_started">{{pretty_datetime this.1.started}}</span>
<span> to </span>
<span class="history_entry_ended">{{pretty_datetime this.1.ended}}</span>
</div>
{{/each}}
</div>
</body>
</html>

65
templates/index.hbs Normal file
View File

@ -0,0 +1,65 @@
<!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="">
<link rel="icon" type="image/png" href="/static/icon.png">
<link rel="stylesheet" href="/static/styles.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu|Ubuntu+Mono&display=swap">
<title>stl</title>
<script>
function toggle_category(id) {
var url = "/toggle_category/" + id;
//var params = "lorem=ipsum&name=alpha";
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
//Send the proper header information along with the request
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send();
let toggled_class = "category_button_toggled";
let cl = document.getElementById("button-" + id).classList;
if(cl.contains(toggled_class)) {
cl.remove(toggled_class);
} else {
cl.add(toggled_class);
}
}
</script>
</head>
<body>
<h1 class="title">stl</h1>
{{#each categories}}
<form action="/toggle_category/{{this.0}}" method="post" id="{{this.0}}"></form>
{{/each}}
<ul class="category_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>
<div class="category_button_container">
<button
id="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>