This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
swb6-it-sec/Lab01/app/templates/index.tmpl

106 lines
4.3 KiB
Cheetah
Raw Normal View History

2022-03-30 14:54:01 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ .title }}</title>
{{template "head" .}}
</head>
<body>
{{template "navbar" .}}
2022-04-04 08:06:09 +02:00
<div class="position-absolute top-50 start-50 translate-middle text-center">
<div>Welcome to the {{ .title }}.</div>
<div>
<a class="link-secondary" href="/login">Login</a> to continue.
</div>
2022-03-30 14:54:01 +02:00
</div>
2022-04-04 08:06:09 +02:00
{{template "scripts" .}}
2022-03-30 14:54:01 +02:00
</body>
</html>
{{define "head"}}
<link rel="apple-touch-icon" sizes="180x180" href="../static/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="../static/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="../static/icons/favicon-16x16.png">
<link rel="manifest" href="../static/icons/site.webmanifest">
<link rel="mask-icon" href="../static/icons/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
2022-04-04 08:06:09 +02:00
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
2022-03-30 14:54:01 +02:00
{{end}}
{{define "navbar"}}
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">SuperSave</a>
2022-04-04 08:06:09 +02:00
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
2022-03-30 14:54:01 +02:00
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="ms-auto navbar-nav mb-2 mb-lg-0">
<li class="nav-item">
<a class="btn btn-primary" href="/login">Login</a>
</li>
</ul>
</div>
</div>
</nav>
2022-04-04 08:06:09 +02:00
{{end}}
{{define "userForm"}}
<form class="row g-3 needs-validation mb-3" novalidate>
<div class="col-12">
<label for="username" class="form-label">Username</label>
<div class="input-group has-validation">
<span class="input-group-text" id="inputGroupPrepend">@</span>
<input type="text" class="form-control" id="username"
aria-describedby="inputGroupPrepend" required>
<div class="invalid-feedback">
Please choose a username.
</div>
</div>
</div>
<div class="col-12">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" aria-describedby="passwordHelp" required>
<div id="invalidPassword" class="invalid-feedback">
Please choose a password.
</div>
</div>
<div class="col-12">
<button class="btn btn-primary" id="button" type="submit">Submit form</button>
</div>
</form>
{{end}}
2022-04-04 08:06:09 +02:00
{{define "scripts"}}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<script>
let form = document.querySelector('.needs-validation')
if (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
} else {
document.getElementById("button").disabled = true;
event.preventDefault();
let data = new FormData();
let form_element = document.getElementsByClassName('form-control');
for (let i = 0; i < form_element.length; i++) {
data.append(form_element[i].id, form_element[i].value);
}
submitForm(data);
}
form.classList.add('was-validated');
}, false);
}
</script>
2022-04-04 08:06:09 +02:00
{{end}}