undefined / index.html
poluser's picture
when i click the add task button, it does not add tasks, please fix
8edd1e9 verified
Raw History Blame Contribute Delete
18.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaskNinja Master - Slice Through Tasks! ⚔️</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/animejs/lib/anime.min.js"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#6366f1',
secondary: '#f59e0b'
}
}
}
}
</script>
<style>
.vanta-bg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.glass-effect {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.task-card {
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.task-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
</head>
<body class="min-h-screen bg-gradient-to-br from-gray-900 to-gray-800 text-white">
<div id="vanta-bg" class="vanta-bg"></div>
<!-- Navigation -->
<nav class="glass-effect sticky top-0 z-50">
<div class="container mx-auto px-4 py-4">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-2">
<i data-feather="check-circle" class="text-primary"></i>
<h1 class="text-2xl font-bold">TaskNinja <span class="text-primary">Master</span> <span class="text-secondary">⚔️</span></h1>
</div>
<div class="flex space-x-4">
<button id="tasks-tab" class="px-4 py-2 rounded-lg bg-primary text-white font-semibold transition-all duration-300">Tasks</button>
<button id="history-tab" class="px-4 py-2 rounded-lg bg-gray-700 hover:bg-gray-600 text-white font-semibold transition-all duration-300">History</button>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<!-- Tasks Section -->
<section id="tasks-section" class="fade-in">
<div class="max-w-4xl mx-auto">
<!-- Add Task Form -->
<div class="glass-effect rounded-2xl p-6 mb-8">
<h2 class="text-2xl font-bold mb-6 flex items-center">
<i data-feather="plus-circle" class="mr-3 text-primary animate-pulse"></i>
<span class="bg-clip-text text-transparent bg-gradient-to-r from-primary to-secondary">Throw a New Task Star</span> <span class="ml-2 text-secondary">✨</span>
</h2>
<form id="task-form" class="space-y-4">
<div class="grid md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium mb-2">Task Title</label>
<input type="text" id="task-title" placeholder="What needs to be done?" class="w-full px-4 py-3 rounded-lg bg-gray-800 border border-gray-600 focus:border-primary focus:ring-2 focus:ring-primary outline-none transition-all duration-300">
</div>
<div>
<label class="block text-sm font-medium mb-2">Priority</label>
<select id="task-priority" class="w-full px-4 py-3 rounded-lg bg-gray-800 border border-gray-600 focus:border-primary focus:ring-2 focus:ring-primary outline-none transition-all duration-300">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high">High</option>
</select>
</div>
</div>
<div>
<label class="block text-sm font-medium mb-2">Description</label>
<textarea id="task-description" placeholder="Add some details..." rows="3" class="w-full px-4 py-3 rounded-lg bg-gray-800 border border-gray-600 focus:border-primary focus:ring-2 focus:ring-primary outline-none transition-all duration-300"></textarea>
</div>
<button type="submit" class="w-full bg-primary hover:bg-indigo-600 text-white font-semibold py-3 px-6 rounded-lg transition-all duration-300 transform hover:scale-105 flex items-center justify-center">
<i data-feather="plus" class="mr-2"></i>
Add Task
</button>
</form>
</div>
<!-- Task List -->
<div class="glass-effect rounded-2xl p-6">
<h2 class="text-2xl font-bold mb-6 flex items-center">
<i data-feather="list" class="mr-3 text-secondary animate-spin" style="animation-duration: 3s"></i>
<span class="bg-clip-text text-transparent bg-gradient-to-r from-secondary to-primary">Dojo Tasks</span>
<span id="task-count" class="ml-3 bg-secondary text-white px-3 py-1 rounded-full text-sm">0 tasks</span>
</h2>
<div id="task-list" class="space-y-4">
<!-- Tasks will be dynamically added here -->
</div>
</div>
</div>
</section>
<!-- History Section -->
<section id="history-section" class="hidden fade-in">
<div class="max-w-4xl mx-auto">
<div class="glass-effect rounded-2xl p-6">
<h2 class="text-2xl font-bold mb-6 flex items-center">
<i data-feather="clock" class="mr-3 text-secondary animate-bounce" style="animation-duration: 2s"></i>
<span class="bg-clip-text text-transparent bg-gradient-to-r from-gray-400 to-gray-300">Ninja Scroll Archive</span> <span class="ml-2">📜</span>
<span id="history-count" class="ml-3 bg-gray-600 text-white px-3 py-1 rounded-full text-sm">0 completed</span>
</h2>
<div id="history-list" class="space-y-4">
<!-- Completed tasks will be dynamically added here -->
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="glass-effect mt-12">
<div class="container mx-auto px-4 py-6 text-center text-gray-400">
<p class="text-sm">Crafted by <span class="font-bold text-primary">Ninja Developers</span> with <i data-feather="heart" class="inline w-4 h-4 text-red-500 animate-pulse"></i> | Sharpen your productivity katana daily!</p>
</div>
</footer>
<script>
// Initialize Vanta.js background
VANTA.GLOBE({
el: "#vanta-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x6366f1,
backgroundColor: 0x111827
});
// Task management functionality
// Ninja-themed task storage with sound effects
const taskSound = new Audio('https://assets.mixkit.co/sfx/preview/mixkit-positive-interface-beep-221.mp3');
const completeSound = new Audio('https://assets.mixkit.co/sfx/preview/mixkit-unlock-game-notification-253.mp3');
let tasks = JSON.parse(localStorage.getItem('ninjaTasks')) || [];
let completedTasks = JSON.parse(localStorage.getItem('ninjaCompletedTasks')) || [];
// Tab switching
document.getElementById('tasks-tab').addEventListener('click', () => {
document.getElementById('tasks-section').classList.remove('hidden');
document.getElementById('history-section').classList.add('hidden');
document.getElementById('tasks-tab').classList.add('bg-primary', 'text-white');
document.getElementById('tasks-tab').classList.remove('bg-gray-700');
document.getElementById('history-tab').classList.add('bg-gray-700');
document.getElementById('history-tab').classList.remove('bg-primary', 'text-white');
});
document.getElementById('history-tab').addEventListener('click', () => {
document.getElementById('history-section').classList.remove('hidden');
document.getElementById('tasks-section').classList.add('hidden');
document.getElementById('history-tab').classList.add('bg-primary', 'text-white');
document.getElementById('history-tab').classList.remove('bg-gray-700');
document.getElementById('tasks-tab').classList.add('bg-gray-700');
document.getElementById('tasks-tab').classList.remove('bg-primary', 'text-white');
updateHistoryDisplay();
});
// Add task form
document.getElementById('task-form').addEventListener('submit', (e) => {
e.preventDefault();
const title = document.getElementById('task-title').value.trim();
const description = document.getElementById('task-description').value.trim();
const priority = document.getElementById('task-priority').value;
if (title) {
const newTask = {
id: Date.now(),
title,
description,
priority,
createdAt: new Date().toISOString(),
completed: false
};
tasks.unshift(newTask); // Add to beginning instead of end
saveTasks();
document.getElementById('task-form').reset();
// Ninja star throw animation
anime({
targets: '#task-title',
translateX: [-20, 0],
translateY: [-10, 0],
opacity: [0, 1],
duration: 800,
easing: 'spring(1, 80, 10, 0)'
});
// Force re-render of task list
updateTaskDisplay().then(() => {
// Animation for new task (first child since we added to beginning)
anime({
targets: '.task-card:first-child',
translateY: [50, 0],
opacity: [0, 1],
duration: 500,
easing: 'easeOutQuad'
});
});
}
});
function saveTasks() {
localStorage.setItem('ninjaTasks', JSON.stringify(tasks));
localStorage.setItem('ninjaCompletedTasks', JSON.stringify(completedTasks));
taskSound.play();
}
async function updateTaskDisplay() {
const taskList = document.getElementById('task-list');
const taskCount = document.getElementById('task-count');
const pendingTasks = tasks.filter(task => !task.completed);
taskCount.textContent = `${pendingTasks.length} ${pendingTasks.length === 1 ? 'task' : 'tasks'}`;
taskList.innerHTML = pendingTasks.map(task => `
<div class="task-card glass-effect rounded-xl p-4 border-l-4 ${
task.priority === 'high' ? 'border-red-500' :
task.priority === 'medium' ? 'border-yellow-500' : 'border-green-500'
}">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
<button onclick="toggleTask(${task.id})" class="w-6 h-6 rounded-full border-2 border-gray-400 hover:border-primary transition-all duration-300 flex items-center justify-center">
<i data-feather="check" class="w-4 h-4 text-white hidden"></i>
</button>
<div>
<h3 class="font-semibold text-lg">${task.title}</h3>
${task.description ? `<p class="text-gray-300 text-sm mt-1">${task.description}</p>` : ''}
<div class="flex items-center space-x-4 mt-2">
<span class="px-2 py-1 rounded-full text-xs ${
task.priority === 'high' ? 'bg-red-500' :
task.priority === 'medium' ? 'bg-yellow-500' : 'bg-green-500'
}">${task.priority}</span>
<span class="text-gray-400 text-xs">${new Date(task.createdAt).toLocaleDateString()}</span>
</div>
</div>
</div>
<button onclick="deleteTask(${task.id})" class="text-gray-400 hover:text-red-400 transition-colors duration-300">
<i data-feather="trash-2" class="w-5 h-5"></i>
</button>
</div>
</div>
`).join('');
await feather.replace();
return Promise.resolve();
}
function updateHistoryDisplay() {
const historyList = document.getElementById('history-list');
const historyCount = document.getElementById('history-count');
historyCount.textContent = `${completedTasks.length} ${completedTasks.length === 1 ? 'completed' : 'completed'}`;
historyList.innerHTML = completedTasks.map(task => `
<div class="glass-effect rounded-xl p-4 border-l-4 border-gray-500 opacity-75">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
<div class="w-6 h-6 rounded-full bg-green-500 flex items-center justify-center">
<i data-feather="check" class="w-4 h-4 text-white"></i>
</div>
<div>
<h3 class="font-semibold text-lg line-through">${task.title}</h3>
${task.description ? `<p class="text-gray-400 text-sm mt-1 line-through">${task.description}</p>` : ''}
<div class="flex items-center space-x-4 mt-2">
<span class="px-2 py-1 rounded-full text-xs bg-gray-600">${task.priority}</span>
<span class="text-gray-500 text-xs">Completed on ${new Date(task.completedAt).toLocaleDateString()}</span>
</div>
</div>
</div>
</div>
</div>
`).join('');
feather.replace();
}
function toggleTask(taskId) {
// Play sound immediately with volume adjusted
const sound = completeSound.cloneNode();
sound.volume = 0.3;
sound.play();
const task = tasks.find(t => t.id === taskId);
if (task) {
task.completed = true;
task.completedAt = new Date().toISOString();
completedTasks.push(task);
tasks = tasks.filter(t => t.id !== taskId);
saveTasks();
updateTaskDisplay();
// Show completion animation
anime({
targets: '.task-card',
translateX: [0, -100],
opacity: [1, 0],
duration: 500,
easing: 'easeInQuad',
complete: function() {
updateTaskDisplay();
}
});
}
}
function deleteTask(taskId) {
if (confirm('Are you sure you want to delete this task?')) {
tasks = tasks.filter(t => t.id !== taskId);
saveTasks();
updateTaskDisplay();
}
}
// Initialize display
updateTaskDisplay();
feather.replace();
// Add some sample tasks if empty
if (tasks.length === 0 && completedTasks.length === 0) {
const sampleTasks = [
{
id: 1,
title: "Welcome to TaskNinja Master!",
description: "Slice through tasks like a true ninja master",
priority: "high",
createdAt: new Date().toISOString(),
completed: false
},
{
id: 2,
title: "Train your focus",
description: "Complete 5 tasks without distractions",
priority: "medium",
createdAt: new Date().toISOString(),
completed: false
},
{
id: 3,
title: "Achieve black belt",
description: "Complete 20 tasks to earn your black belt",
priority: "high",
createdAt: new Date().toISOString(),
completed: false
}
];
tasks = sampleTasks;
saveTasks();
updateTaskDisplay();
}
</script>
</body>
</html>