import Choices from "choices.js"; import { Sidebar } from './js/sidebar'; import './scss/app.scss' export interface choiceMap { [details: string]: Choices; } let choiceObjects: choiceMap = {}; document.addEventListener('DOMContentLoaded', function() { initSearch(); initSidebar(); initToggle(); replaceStrings(); initChoices(); initBoatActions(); selectBoatChange(); addRelationMagic(document.querySelector('body')); reloadPage(); setCurrentdate(document.querySelector('#departure')); }); function setCurrentdate(input: HTMLInputElement) { if(input) { const inputElement = document.getElementById("departure") as HTMLInputElement; const now = new Date(); const formattedDateTime = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}T${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`; inputElement.value = formattedDateTime; } } function selectBoatChange() { const boatSelect = document.querySelector('#boat_id'); if(boatSelect) { const boatChoice = new Choices(boatSelect, { loadingText: 'Wird geladen...', noResultsText: 'Keine Ergebnisse gefunden', noChoicesText: 'Keine Ergebnisse gefunden', itemSelectText: 'Zum Auswählen klicken', callbackOnCreateTemplates: function () { return { option: ({ label, value, customProperties, active, disabled, }: any) => { const opt: HTMLOptionElement = Choices.defaults.templates.option.call( this, { label, value, customProperties, active, disabled } ); // We get the original