Initial commit

This commit is contained in:
MaxJa4
2024-01-14 22:06:53 +01:00
commit fe92068ad3
30 changed files with 1067 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
{{ define "add_clan" }}
<div class="modal fade" id="addClanModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-3 text-success fw-bold" id="addClanModalLabel">Clan hinzufügen</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="form-floating mb-3">
<input type="text" class="form-control form-control-lg" id="clanName" placeholder="Clan-Name">
<label for="clanName">Clan-Name</label>
</div>
<div class="form-floating">
<input type="text" class="form-control form-control-lg" id="clanTag" placeholder="Clan-Tag">
<label for="clanTag">Clan-Tag</label>
</div>
<div class="form-check form-check-inline mt-3 fs-5">
<input class="form-check-input" type="checkbox" id="keepUpdated" value="keepUpdated">
<label class="form-check-label" for="keepUpdated">Immer aktuell halten</label>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="submit" class="btn btn-lg btn-primary">Hinzufügen</button>
<button type="button" class="btn btn-lg btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
</div>
</div>
</div>
</div>
<script lang="javascript">
document.addEventListener('DOMContentLoaded', function() {
const addClanModal = document.getElementById('addClanModal');
const addClanModalBS = new bootstrap.Modal('#addClanModal');
if (addClanModal) {
addClanModal.addEventListener('shown.bs.modal', event => {
const submitButton = addClanModal.querySelector('button[name="submit"]');
submitButton.addEventListener('click', function () {
const button = event.relatedTarget;
const clanListId = button.getAttribute('data-bs-list');
const clanList = document.querySelector(clanListId);
const clanName = addClanModal.querySelector('#clanName');
const clanTag = addClanModal.querySelector('#clanTag');
const keepUpdated = addClanModal.querySelector('#keepUpdated');
fetch("/clan", {
method: "POST",
body: JSON.stringify({
name: clanName.value,
tag: clanTag.value,
keep_updated: keepUpdated.checked
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then((response) => {
if (response.ok) {
const opt = document.createElement('option');
opt.innerText = "[" + clanTag.value + "]" + " " + clanName.value;
opt.value = response.json()['ID'];
clanList.appendChild(opt);
clanList.selectedIndex = clanList.children.length - 1;
clanList.dispatchEvent(new Event('change'));
addClanModalBS.hide();
clanName.value = "";
clanTag.value = "";
keepUpdated.checked = false;
} else
throw new Error(response.error)
});
})
});
}
});
</script>
{{ end }}