This commit is contained in:
relikd
2023-05-29 15:20:07 +02:00
commit 1380b156d8
126 changed files with 3612 additions and 0 deletions

34
app/base/static/js/forms.js Executable file
View File

@@ -0,0 +1,34 @@
function dateTimeSetNow(theId) {
const now = new Date();
const localNow = new Date(Date.UTC(
now.getFullYear(), now.getMonth(), now.getDate(),
now.getHours(), now.getMinutes()));
dateFieldSet(theId, localNow);
dateFieldSet(theId + '_day', localNow);
dateFieldSet(theId + '_time', localNow);
}
function dateTimeReset(theId) {
dateFieldSet(theId, null);
dateFieldSet(theId + '_day', null);
dateFieldSet(theId + '_time', null);
}
function dateFieldSet(theId, value = null) {
const el = document.getElementById(theId);
if (el) el.valueAsDate = value;
}
$(document).ready(function () {
$('select').select2({
width: '100%',
placeholder: ' nicht ausgewählt ',
allowClear: true,
// minimumResultsForSearch: 7,
// minimumInputLength: 1,
});
});
$(document).on('select2:open', () => {
document.querySelector('.select2-search__field').focus();
});

22
app/base/static/js/main.js Executable file
View File

@@ -0,0 +1,22 @@
function toggleMenu(theId) {
const menu = document.getElementById(theId);
menu.classList.toggle('show');
if (menu.classList.contains('show')) {
setTimeout(() => {
document.addEventListener('click', () => {
menu.classList.remove('show');
}, { once: true });
}, 50); // timeout to not immediately close
}
}
function highlight(div) {
const prev = div.style;
div.style.transition = 'background-color 0.5s';
div.style.backgroundColor = 'yellow';
setTimeout(() => {
div.style.transition = 'background-color 4s';
div.style.backgroundColor = 'unset';
}, 500);
setTimeout(() => div.style = prev, 600);
}

8
app/base/static/js/onload.js Executable file
View File

@@ -0,0 +1,8 @@
document.querySelectorAll('.table[data-onclick]').forEach((tbl) => {
tbl.classList.add('clickable');
const callback = new Function(tbl.dataset.onclick);
tbl.onclick = (event) => {
const entry = event.target.closest('tbody>tr');
if (entry) { callback.call(tbl, row=entry); }
};
});

View File

@@ -0,0 +1,27 @@
window.onload = function () {
const timer = document.getElementById('checkin-timer');
if (timer) {
updateTimer(timer);
setInterval(function () { updateTimer(timer); }, 1000);
}
}
function updateTimer(timer) {
let diff = (new Date() - new Date(timer.dataset.since)) / 1000;
const hh = Math.floor(diff / 60 / 60);
diff -= hh * 60 * 60;
const mm = Math.floor(diff / 60);
const ss = Math.floor(diff - mm * 60);
timer.textContent = `${hh}h ${mm}min ${ss}s`;
}
function showNoteModal(show) {
const div = document.getElementById('note-modal');
if (show) {
div.style.display = 'block';
setTimeout(() => div.classList.add('show'), 10);
} else {
div.classList.remove('show');
setTimeout(() => div.style.display = null, 200); // wait for fade
}
}