taskflow-rag / index.html
Ragnarucem's picture
el Sort no funciona - Follow Up Deployment
6ded1ec verified
Raw History Blame Contribute Delete
32.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaskFlow - Task Management App</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#3B82F6',
secondary: '#10B981',
dark: '#1F2937',
}
}
}
}
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
min-height: 100vh;
}
.task-card {
transition: all 0.3s ease;
transform-origin: top;
animation: fadeIn 0.5s ease-out;
}
.task-card:hover {
transform: translateY(-3px);
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}
.priority-high { border-left: 4px solid #EF4444; }
.priority-medium { border-left: 4px solid #F59E0B; }
.priority-low { border-left: 4px solid #10B981; }
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.modal {
animation: modalFade 0.3s ease-out;
}
@keyframes modalFade {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
.completed-task {
opacity: 0.5;
background-color: #f8fafc;
}
.pending-task {
border-left: 4px solid #3B82F6;
}
</style>
</head>
<body class="bg-gray-50">
<!-- Header -->
<header class="bg-white shadow-sm">
<div class="container mx-auto px-4 py-6 flex flex-col md:flex-row justify-between items-center">
<div class="flex items-center mb-4 md:mb-0">
<div class="bg-primary p-3 rounded-lg mr-3">
<i class="fas fa-tasks text-white text-xl"></i>
</div>
<h1 class="text-3xl font-bold text-gray-800">Task<span class="text-primary">Flow</span></h1>
</div>
<div class="flex items-center space-x-4">
<div class="relative">
<input type="text" placeholder="Search tasks..." class="pl-10 pr-4 py-2 rounded-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
</div>
<button class="bg-primary hover:bg-blue-700 text-white px-6 py-2 rounded-full transition duration-300">
<i class="fas fa-plus mr-2"></i>New Task
</button>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Task Form -->
<div class="lg:col-span-1">
<div class="bg-white rounded-xl shadow-md p-6 sticky top-6">
<h2 class="text-2xl font-bold text-gray-800 mb-6">Create New Task</h2>
<form id="taskForm" class="space-y-4">
<div>
<label for="title" class="block text-sm font-medium text-gray-700 mb-1">Task Title</label>
<input type="text" id="title" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="What needs to be done?" required>
</div>
<div>
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="description" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" placeholder="Add details..."></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="dueDate" class="block text-sm font-medium text-gray-700 mb-1">Due Date</label>
<input type="date" id="dueDate" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
</div>
<div>
<label for="priority" class="block text-sm font-medium text-gray-700 mb-1">Priority</label>
<select id="priority" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
<option value="low">Low</option>
<option value="medium" selected>Medium</option>
<option value="high">High</option>
</select>
</div>
</div>
<div>
<label for="category" class="block text-sm font-medium text-gray-700 mb-1">Category</label>
<select id="category" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
<option value="work">Work</option>
<option value="personal">Personal</option>
<option value="shopping">Shopping</option>
<option value="health">Health</option>
<option value="other">Other</option>
</select>
</div>
<div class="pt-4">
<button type="submit" class="w-full bg-primary hover:bg-blue-700 text-white font-medium py-3 rounded-lg transition duration-300">
<i class="fas fa-plus-circle mr-2"></i>Add Task
</button>
</div>
</form>
</div>
</div>
<!-- Task List -->
<div class="lg:col-span-2">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold text-gray-800">My Tasks</h2>
<div class="flex space-x-2">
<button id="filterPending" class="px-4 py-2 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50">
<i class="fas fa-filter mr-2"></i>Show Pending
</button>
<div class="relative">
<button id="sortButton" class="px-4 py-2 rounded-lg border border-gray-300 text-gray-700 hover:bg-gray-50 flex items-center">
<i class="fas fa-sort mr-2"></i>Sort
<i class="fas fa-chevron-down ml-2 text-xs"></i>
</button>
<div id="sortDropdown" class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg z-10 hidden">
<div class="py-1">
<a href="#" class="sort-option block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" data-sort="date-asc">Date (Oldest First)</a>
<a href="#" class="sort-option block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" data-sort="date-desc">Date (Newest First)</a>
<a href="#" class="sort-option block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" data-sort="priority">Priority</a>
<a href="#" class="sort-option block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" data-sort="category">Category</a>
</div>
</div>
</div>
</div>
</div>
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
<div class="bg-white rounded-xl shadow-sm p-4">
<div class="flex justify-between">
<div>
<p class="text-sm text-gray-500">Total Tasks</p>
<h3 id="totalTasks" class="text-2xl font-bold text-gray-800">3</h3>
</div>
<div class="bg-blue-100 p-3 rounded-lg">
<i class="fas fa-tasks text-primary text-xl"></i>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-4">
<div class="flex justify-between">
<div>
<p class="text-sm text-gray-500">Completed</p>
<h3 id="completedTasks" class="text-2xl font-bold text-gray-800">1</h3>
</div>
<div class="bg-green-100 p-3 rounded-lg">
<i class="fas fa-check-circle text-secondary text-xl"></i>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-4">
<div class="flex justify-between">
<div>
<p class="text-sm text-gray-500">Pending</p>
<h3 id="pendingTasks" class="text-2xl font-bold text-gray-800">2</h3>
</div>
<div class="bg-yellow-100 p-3 rounded-lg">
<i class="fas fa-exclamation-circle text-yellow-500 text-xl"></i>
</div>
</div>
</div>
</div>
<!-- Task List Content -->
<div id="taskList" class="space-y-4">
<!-- Task cards will be added here dynamically -->
</div>
<!-- Empty State -->
<div id="emptyState" class="text-center py-12 hidden">
<div class="mx-auto bg-gray-100 p-6 rounded-full w-24 h-24 flex items-center justify-center mb-4">
<i class="fas fa-check-circle text-gray-400 text-4xl"></i>
</div>
<h3 class="text-xl font-semibold text-gray-700 mb-2">No tasks yet</h3>
<p class="text-gray-500 max-w-md mx-auto">Get started by creating your first task. Click the "New Task" button to add a task.</p>
</div>
</div>
</div>
</main>
<!-- Edit Task Modal -->
<div id="editModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md mx-4 modal">
<div class="p-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-gray-800">Edit Task</h3>
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<form id="editForm" class="space-y-4">
<input type="hidden" id="editId">
<div>
<label for="editTitle" class="block text-sm font-medium text-gray-700 mb-1">Task Title</label>
<input type="text" id="editTitle" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent" required>
</div>
<div>
<label for="editDescription" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="editDescription" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent"></textarea>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="editDueDate" class="block text-sm font-medium text-gray-700 mb-1">Due Date</label>
<input type="date" id="editDueDate" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
</div>
<div>
<label for="editPriority" class="block text-sm font-medium text-gray-700 mb-1">Priority</label>
<select id="editPriority" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high">High</option>
</select>
</div>
</div>
<div>
<label for="editCategory" class="block text-sm font-medium text-gray-700 mb-1">Category</label>
<select id="editCategory" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent">
<option value="work">Work</option>
<option value="personal">Personal</option>
<option value="shopping">Shopping</option>
<option value="health">Health</option>
<option value="other">Other</option>
</select>
</div>
<div class="pt-4 flex space-x-3">
<button type="button" id="deleteTask" class="flex-1 bg-red-100 hover:bg-red-200 text-red-700 font-medium py-3 rounded-lg transition duration-300">
<i class="fas fa-trash mr-2"></i>Delete
</button>
<button type="submit" class="flex-1 bg-primary hover:bg-blue-700 text-white font-medium py-3 rounded-lg transition duration-300">
<i class="fas fa-save mr-2"></i>Save Changes
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-white border-t mt-12">
<div class="container mx-auto px-4 py-6">
<div class="flex flex-col md:flex-row justify-between items-center">
<p class="text-gray-600">© 2023 TaskFlow. All rights reserved.</p>
<div class="flex space-x-4 mt-4 md:mt-0">
<a href="#" class="text-gray-500 hover:text-primary">
<i class="fab fa-twitter"></i>
</a>
<a href="#" class="text-gray-500 hover:text-primary">
<i class="fab fa-facebook"></i>
</a>
<a href="#" class="text-gray-500 hover:text-primary">
<i class="fab fa-github"></i>
</a>
</div>
</div>
</div>
</footer>
<script>
// Sample initial tasks
let tasks = [
{
id: 1,
title: "Complete project proposal",
description: "Finish and submit the project proposal document to the client",
dueDate: "2023-06-15",
priority: "high",
category: "work",
completed: false
},
{
id: 2,
title: "Grocery shopping",
description: "Milk, eggs, bread, fruits, and vegetables",
dueDate: "2023-06-10",
priority: "medium",
category: "shopping",
completed: false
},
{
id: 3,
title: "Morning jog",
description: "5km run in the park",
dueDate: "2023-06-08",
priority: "low",
category: "health",
completed: true
}
];
// DOM Elements
const taskForm = document.getElementById('taskForm');
const editForm = document.getElementById('editForm');
const taskList = document.getElementById('taskList');
const emptyState = document.getElementById('emptyState');
const editModal = document.getElementById('editModal');
const closeModal = document.getElementById('closeModal');
const deleteButton = document.getElementById('deleteTask');
// Initialize app
document.addEventListener('DOMContentLoaded', () => {
renderTasks();
setupEventListeners();
// Add filter event listener
document.getElementById('filterPending').addEventListener('click', () => {
const filteredTasks = tasks.filter(task => !task.completed);
renderFilteredTasks(filteredTasks);
});
// Sort functionality
const sortButton = document.getElementById('sortButton');
const sortDropdown = document.getElementById('sortDropdown');
sortButton.addEventListener('click', () => {
sortDropdown.classList.toggle('hidden');
});
// Close dropdown when clicking outside
document.addEventListener('click', (e) => {
if (!sortButton.contains(e.target) && !sortDropdown.contains(e.target)) {
sortDropdown.classList.add('hidden');
}
});
// Handle sort option selection
document.querySelectorAll('.sort-option').forEach(option => {
option.addEventListener('click', (e) => {
e.preventDefault();
const sortType = e.target.dataset.sort;
sortTasks(sortType);
sortDropdown.classList.add('hidden');
});
});
});
// Sort tasks based on selected criteria
function sortTasks(sortType) {
let sortedTasks = [...tasks];
switch(sortType) {
case 'date-asc':
sortedTasks.sort((a, b) => {
if (!a.dueDate && !b.dueDate) return 0;
if (!a.dueDate) return 1;
if (!b.dueDate) return -1;
return new Date(a.dueDate) - new Date(b.dueDate);
});
break;
case 'date-desc':
sortedTasks.sort((a, b) => {
if (!a.dueDate && !b.dueDate) return 0;
if (!a.dueDate) return 1;
if (!b.dueDate) return -1;
return new Date(b.dueDate) - new Date(a.dueDate);
});
break;
case 'priority':
const priorityOrder = { high: 3, medium: 2, low: 1 };
sortedTasks.sort((a, b) => priorityOrder[b.priority] - priorityOrder[a.priority]);
break;
case 'category':
sortedTasks.sort((a, b) => a.category.localeCompare(b.category));
break;
}
renderFilteredTasks(sortedTasks);
showNotification(`Tasks sorted by ${sortType.replace('-', ' ')}`);
}
// Set up event listeners
function setupEventListeners() {
taskForm.addEventListener('submit', addTask);
editForm.addEventListener('submit', updateTask);
closeModal.addEventListener('click', () => editModal.classList.add('hidden'));
deleteButton.addEventListener('click', deleteTask);
// Close modal when clicking outside
editModal.addEventListener('click', (e) => {
if (e.target === editModal) {
editModal.classList.add('hidden');
}
});
}
// Add new task
function addTask(e) {
e.preventDefault();
const title = document.getElementById('title').value;
const description = document.getElementById('description').value;
const dueDate = document.getElementById('dueDate').value;
const priority = document.getElementById('priority').value;
const category = document.getElementById('category').value;
const newTask = {
id: Date.now(),
title,
description,
dueDate,
priority,
category,
completed: false
};
tasks.push(newTask);
renderTasks();
// Reset form
taskForm.reset();
// Show notification
showNotification('Task added successfully!');
}
// Update task
function updateTask(e) {
e.preventDefault();
const id = parseInt(document.getElementById('editId').value);
const title = document.getElementById('editTitle').value;
const description = document.getElementById('editDescription').value;
const dueDate = document.getElementById('editDueDate').value;
const priority = document.getElementById('editPriority').value;
const category = document.getElementById('editCategory').value;
const taskIndex = tasks.findIndex(task => task.id === id);
if (taskIndex !== -1) {
tasks[taskIndex] = {
...tasks[taskIndex],
title,
description,
dueDate,
priority,
category
};
renderTasks();
editModal.classList.add('hidden');
// Show notification
showNotification('Task updated successfully!');
}
}
// Delete task
function deleteTask() {
const id = parseInt(document.getElementById('editId').value);
tasks = tasks.filter(task => task.id !== id);
renderTasks();
editModal.classList.add('hidden');
// Show notification
showNotification('Task deleted successfully!');
}
// Toggle task completion
function toggleTaskCompletion(id) {
const task = tasks.find(task => task.id === id);
if (task) {
task.completed = !task.completed;
renderTasks();
updateStats();
// Show notification
const message = task.completed ? 'Task marked as completed!' : 'Task marked as pending!';
showNotification(message);
}
}
// Open edit modal
function openEditModal(id) {
const task = tasks.find(task => task.id === id);
if (task) {
document.getElementById('editId').value = task.id;
document.getElementById('editTitle').value = task.title;
document.getElementById('editDescription').value = task.description;
document.getElementById('editDueDate').value = task.dueDate;
document.getElementById('editPriority').value = task.priority;
document.getElementById('editCategory').value = task.category;
editModal.classList.remove('hidden');
}
}
// Update stats counters
function updateStats() {
const totalTasks = tasks.length;
const completedTasks = tasks.filter(task => task.completed).length;
const pendingTasks = totalTasks - completedTasks;
document.getElementById('totalTasks').textContent = totalTasks;
document.getElementById('completedTasks').textContent = completedTasks;
document.getElementById('pendingTasks').textContent = pendingTasks;
}
// Render all tasks
function renderTasks() {
renderFilteredTasks(tasks);
updateStats();
}
// Render filtered tasks
function renderFilteredTasks(filteredTasks) {
if (filteredTasks.length === 0) {
taskList.classList.add('hidden');
emptyState.classList.remove('hidden');
return;
}
taskList.classList.remove('hidden');
emptyState.classList.add('hidden');
taskList.innerHTML = '';
// Sort tasks: uncompleted first, then by priority (high to low)
const sortedTasks = [...filteredTasks].sort((a, b) => {
if (a.completed !== b.completed) {
return a.completed ? 1 : -1;
}
const priorityOrder = { high: 3, medium: 2, low: 1 };
return priorityOrder[b.priority] - priorityOrder[a.priority];
});
sortedTasks.forEach(task => {
const taskCard = document.createElement('div');
taskCard.className = `task-card bg-white rounded-xl shadow-sm overflow-hidden ${task.completed ? 'completed-task' : ''}`;
taskCard.innerHTML = `
<div class="p-5 flex ${!task.completed ? 'pending-task' : ''}">
<div class="mr-4 mt-1">
<button onclick="toggleTaskCompletion(${task.id})" class="w-6 h-6 rounded-full border-2 flex items-center justify-center ${task.completed ? 'bg-secondary border-secondary' : 'border-gray-300'}">
${task.completed ? '<i class="fas fa-check text-white text-xs"></i>' : ''}
</button>
</div>
<div class="flex-1">
<div class="flex justify-between items-start">
<h3 class="font-semibold text-gray-800 ${task.completed ? 'line-through' : ''}">${task.title}</h3>
<span class="text-xs font-medium px-2 py-1 rounded-full ${task.priority === 'high' ? 'bg-red-100 text-red-800' : task.priority === 'medium' ? 'bg-yellow-100 text-yellow-800' : 'bg-green-100 text-green-800'}">
${task.priority.charAt(0).toUpperCase() + task.priority.slice(1)}
</span>
</div>
<p class="text-gray-600 text-sm mt-1 ${task.completed ? 'line-through' : ''}">${task.description || 'No description'}</p>
<div class="flex justify-between items-center mt-3">
<div class="flex items-center text-sm text-gray-500">
<i class="far fa-calendar mr-1"></i>
<span>${task.dueDate || 'No due date'}</span>
</div>
<div class="flex space-x-2">
<button onclick="openEditModal(${task.id})" class="text-gray-500 hover:text-primary">
<i class="fas fa-edit"></i>
</button>
<span class="text-xs font-medium px-2 py-1 rounded-full bg-gray-100 text-gray-700">
${task.category.charAt(0).toUpperCase() + task.category.slice(1)}
</span>
</div>
</div>
</div>
</div>
`;
taskList.appendChild(taskCard);
});
}
// Show notification
function showNotification(message) {
// Create notification element
const notification = document.createElement('div');
notification.className = 'fixed top-4 right-4 bg-white shadow-lg rounded-lg px-4 py-3 flex items-center transform translate-y-0 opacity-100 transition-all duration-300';
notification.innerHTML = `
<div class="bg-green-100 p-2 rounded-full mr-3">
<i class="fas fa-check-circle text-green-600"></i>
</div>
<div>
<p class="font-medium text-gray-800">Success</p>
<p class="text-sm text-gray-600">${message}</p>
</div>
`;
document.body.appendChild(notification);
// Remove notification after 3 seconds
setTimeout(() => {
notification.style.transform = 'translateY(-20px)';
notification.style.opacity = '0';
setTimeout(() => {
document.body.removeChild(notification);
}, 300);
}, 3000);
}
// Expose functions to global scope for inline event handlers
window.toggleTaskCompletion = toggleTaskCompletion;
window.openEditModal = openEditModal;
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Ragnarucem/taskflow-rag" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>