diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..79067b4 --- /dev/null +++ b/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "Task Manager", + "short_name": "TaskApp", + "description": "An app to manage tasks in Org mode format.", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#4CAF50", + "icons": [ + { + "src": "icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} + diff --git a/public/app.js b/public/app.js new file mode 100644 index 0000000..69e76b5 --- /dev/null +++ b/public/app.js @@ -0,0 +1,31 @@ +document.getElementById('taskForm').addEventListener('submit', function(e) { + e.preventDefault(); + + // Get form values + const subject = document.getElementById('subject').value; + const description = document.getElementById('description').value; + const deadline = document.getElementById('deadline').value; + + // Structure data for Org mode + const taskData = { + subject, + description, + deadline + }; + + // Send data to backend using fetch + fetch('/add-task', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(taskData) + }) + .then(response => response.json()) + .then(data => { + document.getElementById('responseMessage').textContent = data.message; + }) + .catch(error => { + document.getElementById('responseMessage').textContent = "Error saving task!"; + }); +}); diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..149a38d --- /dev/null +++ b/public/index.html @@ -0,0 +1,43 @@ + + + + + + Task Input App + + + + + + +
+

TODO

+
+ +

+ + +

+ + +

+ + +
+

+
+ + + + + diff --git a/public/style.css b/public/style.css new file mode 100644 index 0000000..7aa6c22 --- /dev/null +++ b/public/style.css @@ -0,0 +1,48 @@ +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + background-color: #f4f4f9; +} + +.container { + width: 300px; + padding: 20px; + background-color: #fff; + border-radius: 8px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +h1 { + text-align: center; +} + +input, textarea { + width: 90%; + padding: 8px; + margin-bottom: 10px; + border: 1px solid #ccc; + border-radius: 4px; +} + +button { + width: 100%; + padding: 10px; + background-color: #4CAF50; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; +} + +button:hover { + background-color: #45a049; +} + +#responseMessage { + text-align: center; + color: green; +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..51ce650 --- /dev/null +++ b/server.js @@ -0,0 +1,33 @@ +const express = require('express'); +const bodyParser = require('body-parser'); +const fs = require('fs'); +const path = require('path'); + +const app = express(); +const port = 3044; + +app.use(bodyParser.json()); +app.use(express.static('public')); + +// Endpoint to receive task data and append to file +app.post('/add-task', (req, res) => { + const { subject, description, deadline } = req.body; + + const orgFormattedData = ` +* TODO ${subject} + ${description} + SCHEDULED: <${deadline}> + `; + + const filePath = path.join(__dirname, 'tasks.org'); + fs.appendFile(filePath, orgFormattedData, (err) => { + if (err) { + return res.status(500).send('Error writing to file.'); + } + res.send({ message: 'Task added successfully!' }); + }); +}); + +app.listen(port, () => { + console.log(`Server running at http://localhost:${port}`); +}); diff --git a/service-worker.js b/service-worker.js new file mode 100644 index 0000000..bb93cb9 --- /dev/null +++ b/service-worker.js @@ -0,0 +1,23 @@ +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open('task-manager-cache').then((cache) => { + return cache.addAll([ + '/', + '/index.html', + '/style.css', + '/app.js', + '/manifest.json', + '/icons/icon-192x192.png', + '/icons/icon-512x512.png' + ]); + }) + ); +}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request).then((cachedResponse) => { + return cachedResponse || fetch(event.request); + }) + ); +});