Add timepicker initialization and combine scheduled date with time input

This commit is contained in:
2025-01-29 21:43:06 +01:00
parent 5413323a3c
commit 502938b8cf
2 changed files with 27 additions and 2 deletions

View File

@@ -40,15 +40,32 @@ document.addEventListener('DOMContentLoaded', function() {
firstDay: 1
});
// Initialize timepicker
M.Timepicker.init(document.querySelectorAll('.timepicker'), {
twelveHour: false // Use 24-hour format
});
// Check if user is already logged in
fetch('/check-session')
.then(response => response.json())
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.loggedIn) {
loginContainer.style.display = 'none';
appContainer.style.display = 'block';
loadTags();
} else {
loginContainer.style.display = 'block';
appContainer.style.display = 'none';
}
})
.catch(error => {
console.error('Error checking session:', error);
loginMessage.textContent = 'Error checking session. Please try again later.';
});
loginForm.addEventListener('submit', function(e) {
@@ -103,14 +120,18 @@ document.addEventListener('DOMContentLoaded', function() {
const subject = document.getElementById('subject').value;
const description = document.getElementById('description').value;
const scheduled = document.getElementById('scheduled').value;
const time = document.getElementById('time').value;
const tagsInput = document.getElementById('tags').value;
const tags = tagsInput.split(',').map(tag => tag.trim()).filter(tag => tag).join(':');
// Combine scheduled date and time if time is provided
const scheduledDateTime = time ? `${scheduled}T${time}:00` : scheduled;
// Structure data for Org mode
const taskData = {
subject: tags ? `${subject} :${tags}:` : subject,
description,
scheduled
scheduled: scheduledDateTime
};
// Save tags to server

View File

@@ -55,6 +55,10 @@
<input type="text" id="scheduled" class="datepicker" required>
<label for="scheduled">Planerat datum</label>
</div>
<div class="input-field">
<input type="text" id="time" class="timepicker">
<label for="time">Tid (valfritt)</label>
</div>
<div class="input-field">
<input type="text" id="tags" placeholder="Taggar">
<label for="tags">Taggar</label>