diff --git a/public/app.js b/public/app.js index 70e0957..b74bc14 100644 --- a/public/app.js +++ b/public/app.js @@ -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 diff --git a/public/index.html b/public/index.html index 2e31f96..aea40dd 100644 --- a/public/index.html +++ b/public/index.html @@ -55,6 +55,10 @@ +
+ + +