generative-waves / index.html
jayedgar's picture
Add 2 files
e4555de verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nebula Tasks | Modern To-Do 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">
<style>
/* Custom gradient animation */
@keyframes gradientBG {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.gradient-bg {
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradientBG 15s ease infinite;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.5);
}
/* Task item animation */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.task-item {
animation: fadeIn 0.3s ease-out forwards;
}
/* Checkbox style */
.custom-checkbox {
appearance: none;
-webkit-appearance: none;
width: 22px;
height: 22px;
border: 2px solid rgba(255, 255, 255, 0.7);
border-radius: 6px;
cursor: pointer;
position: relative;
transition: all 0.2s;
}
.custom-checkbox:checked {
background-color: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.7);
}
.custom-checkbox:checked::after {
content: '✓';
position: absolute;
color: white;
font-size: 14px;
left: 4px;
top: 0;
}
</style>
</head>
<body class="gradient-bg min-h-screen text-white font-sans">
<div class="container mx-auto px-4 py-8 max-w-3xl">
<!-- Header -->
<header class="mb-8 text-center">
<h1 class="text-4xl font-bold mb-2 flex items-center justify-center">
<i class="fas fa-meteor mr-3 text-yellow-300"></i>
Nebula Tasks
</h1>
<p class="opacity-80">Organize your cosmic to-dos</p>
</header>
<!-- Main Card -->
<div class="bg-white bg-opacity-10 backdrop-blur-lg rounded-xl shadow-2xl overflow-hidden">
<!-- Input Section -->
<div class="p-6 border-b border-white border-opacity-20">
<div class="flex gap-3">
<input
type="text"
id="taskInput"
placeholder="Add a new task..."
class="flex-1 bg-white bg-opacity-20 rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-white focus:ring-opacity-50 placeholder-white placeholder-opacity-70"
>
<button
id="addTaskBtn"
class="bg-white bg-opacity-30 hover:bg-opacity-40 text-white px-5 rounded-lg transition-all duration-200 flex items-center justify-center"
>
<i class="fas fa-plus mr-2"></i> Add
</button>
</div>
</div>
<!-- Filter Controls -->
<div class="px-6 py-3 flex justify-between items-center bg-white bg-opacity-5">
<div class="text-sm opacity-80">
<span id="taskCount">0</span> tasks
</div>
<div class="flex gap-2">
<button
data-filter="all"
class="filter-btn px-3 py-1 text-xs rounded-full bg-white bg-opacity-20 hover:bg-opacity-30 transition"
>
All
</button>
<button
data-filter="active"
class="filter-btn px-3 py-1 text-xs rounded-full bg-white bg-opacity-10 hover:bg-opacity-20 transition"
>
Active
</button>
<button
data-filter="completed"
class="filter-btn px-3 py-1 text-xs rounded-full bg-white bg-opacity-10 hover:bg-opacity-20 transition"
>
Completed
</button>
</div>
</div>
<!-- Tasks List -->
<div id="tasksContainer" class="max-h-96 overflow-y-auto px-6">
<!-- Tasks will be added here dynamically -->
<div id="emptyState" class="py-10 text-center opacity-70">
<i class="fas fa-tasks text-4xl mb-3 opacity-50"></i>
<p>No tasks yet. Add one above!</p>
</div>
</div>
<!-- Footer Actions -->
<div class="p-4 bg-white bg-opacity-5 flex justify-between items-center text-sm">
<button
id="clearCompletedBtn"
class="opacity-70 hover:opacity-100 transition"
>
Clear completed
</button>
<button
id="saveAllBtn"
class="bg-blue-500 bg-opacity-80 hover:bg-opacity-100 px-3 py-1 rounded-lg flex items-center transition"
>
<i class="fas fa-save mr-2"></i> Save All
</button>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// DOM Elements
const taskInput = document.getElementById('taskInput');
const addTaskBtn = document.getElementById('addTaskBtn');
const tasksContainer = document.getElementById('tasksContainer');
const emptyState = document.getElementById('emptyState');
const taskCount = document.getElementById('taskCount');
const filterButtons = document.querySelectorAll('.filter-btn');
const clearCompletedBtn = document.getElementById('clearCompletedBtn');
const saveAllBtn = document.getElementById('saveAllBtn');
// State
let tasks = [];
let currentFilter = 'all';
// Initialize the app
loadTasks();
updateTaskCount();
updateEmptyState();
updateActiveFilterButton();
// Event Listeners
addTaskBtn.addEventListener('click', addTask);
taskInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') addTask();
});
filterButtons.forEach(btn => {
btn.addEventListener('click', function() {
currentFilter = this.dataset.filter;
renderTasks();
updateActiveFilterButton();
});
});
clearCompletedBtn.addEventListener('click', clearCompletedTasks);
saveAllBtn.addEventListener('click', saveTasks);
// Functions
function addTask() {
const text = taskInput.value.trim();
if (text === '') return;
const newTask = {
id: Date.now(),
text: text,
completed: false,
createdAt: new Date()
};
tasks.unshift(newTask);
taskInput.value = '';
renderTasks();
updateTaskCount();
updateEmptyState();
saveTasks();
}
function renderTasks() {
tasksContainer.innerHTML = '';
const filteredTasks = tasks.filter(task => {
if (currentFilter === 'active') return !task.completed;
if (currentFilter === 'completed') return task.completed;
return true;
});
if (filteredTasks.length === 0) {
updateEmptyState();
return;
}
emptyState.style.display = 'none';
filteredTasks.forEach(task => {
const taskElement = document.createElement('div');
taskElement.className = `task-item py-3 px-2 flex items-center border-b border-white border-opacity-10 hover:bg-white hover:bg-opacity-5 transition ${task.completed ? 'opacity-70' : ''}`;
taskElement.innerHTML = `
<div class="flex items-center flex-1">
<input
type="checkbox"
class="custom-checkbox mr-3"
${task.completed ? 'checked' : ''}
data-id="${task.id}"
>
<span class="${task.completed ? 'line-through opacity-80' : ''}">${task.text}</span>
</div>
<button class="delete-btn p-2 rounded-full hover:bg-white hover:bg-opacity-20 transition" data-id="${task.id}">
<i class="fas fa-trash-alt opacity-70 hover:opacity-100"></i>
</button>
`;
tasksContainer.appendChild(taskElement);
});
// Add event listeners to new elements
document.querySelectorAll('.custom-checkbox').forEach(checkbox => {
checkbox.addEventListener('change', toggleTaskComplete);
});
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.addEventListener('click', deleteTask);
});
}
function toggleTaskComplete(e) {
const taskId = parseInt(e.target.dataset.id);
const task = tasks.find(t => t.id === taskId);
if (task) {
task.completed = e.target.checked;
renderTasks();
updateTaskCount();
saveTasks();
}
}
function deleteTask(e) {
const taskId = parseInt(e.currentTarget.dataset.id);
tasks = tasks.filter(task => task.id !== taskId);
renderTasks();
updateTaskCount();
updateEmptyState();
saveTasks();
}
function clearCompletedTasks() {
tasks = tasks.filter(task => !task.completed);
renderTasks();
updateTaskCount();
updateEmptyState();
saveTasks();
}
function updateTaskCount() {
const activeTasks = tasks.filter(task => !task.completed).length;
const totalTasks = tasks.length;
taskCount.textContent = `${activeTasks} active of ${totalTasks}`;
}
function updateEmptyState() {
const filteredTasks = tasks.filter(task => {
if (currentFilter === 'active') return !task.completed;
if (currentFilter === 'completed') return task.completed;
return true;
});
if (filteredTasks.length === 0) {
emptyState.style.display = 'block';
} else {
emptyState.style.display = 'none';
}
}
function updateActiveFilterButton() {
filterButtons.forEach(btn => {
if (btn.dataset.filter === currentFilter) {
btn.classList.remove('bg-opacity-10');
btn.classList.add('bg-opacity-20');
} else {
btn.classList.remove('bg-opacity-20');
btn.classList.add('bg-opacity-10');
}
});
}
function saveTasks() {
localStorage.setItem('nebula-tasks', JSON.stringify(tasks));
// Show save confirmation
const originalText = saveAllBtn.innerHTML;
saveAllBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Saved!';
saveAllBtn.classList.remove('bg-blue-500');
saveAllBtn.classList.add('bg-green-500');
setTimeout(() => {
saveAllBtn.innerHTML = originalText;
saveAllBtn.classList.remove('bg-green-500');
saveAllBtn.classList.add('bg-blue-500');
}, 1500);
}
function loadTasks() {
const savedTasks = localStorage.getItem('nebula-tasks');
if (savedTasks) {
tasks = JSON.parse(savedTasks);
renderTasks();
}
}
});
</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=jayedgar/generative-waves" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>