x4 / index.html
maylay0's picture
i need an app keep up with my daliy life - Initial Deployment
fb2d11d verified
Raw History Blame Contribute Delete
43.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Daily Life Tracker</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 scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Animation for task completion */
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; transform: translateX(50px); }
}
.completed {
animation: fadeOut 0.5s forwards;
}
/* Mood selector animation */
.mood-option:hover {
transform: scale(1.1);
transition: transform 0.2s;
}
/* Calendar day hover */
.calendar-day:hover:not(.empty-day) {
background-color: #e2e8f0;
cursor: pointer;
}
/* Pulse animation for notifications */
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.pulse {
animation: pulse 1.5s infinite;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen">
<div class="container mx-auto px-4 py-8 max-w-6xl">
<!-- Header -->
<header class="flex justify-between items-center mb-8">
<div>
<h1 class="text-3xl font-bold text-indigo-700">Daily Life Tracker</h1>
<p class="text-gray-600">Organize your day, build habits, and track your mood</p>
</div>
<div class="flex items-center space-x-4">
<div class="relative">
<button id="notificationBtn" class="text-gray-600 hover:text-indigo-700">
<i class="fas fa-bell text-xl"></i>
<span id="notificationCount" class="absolute -top-2 -right-2 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center hidden">0</span>
</button>
<div id="notificationDropdown" class="hidden absolute right-0 mt-2 w-64 bg-white rounded-md shadow-lg z-10 p-2 max-h-80 overflow-y-auto">
<p class="text-gray-500 text-sm p-2">No new notifications</p>
</div>
</div>
<div class="relative">
<button id="profileBtn" class="flex items-center space-x-2">
<div class="h-10 w-10 rounded-full bg-indigo-500 flex items-center justify-center text-white font-bold">U</div>
</button>
</div>
</div>
</header>
<!-- Main Content -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Left Column -->
<div class="lg:col-span-2 space-y-6">
<!-- Date and Quick Stats -->
<div class="bg-white rounded-xl shadow p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800" id="currentDate">Today, June 15, 2023</h2>
<div class="flex space-x-2">
<button id="prevDay" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-chevron-left"></i>
</button>
<button id="nextDay" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-chevron-right"></i>
</button>
<button id="todayBtn" class="px-3 py-1 bg-indigo-100 text-indigo-700 rounded-full text-sm hover:bg-indigo-200">Today</button>
</div>
</div>
<div class="grid grid-cols-3 gap-4 text-center">
<div class="bg-blue-50 p-3 rounded-lg">
<p class="text-sm text-blue-600">Tasks</p>
<p class="text-xl font-bold"><span id="taskCount">0</span>/<span id="taskTotal">0</span></p>
</div>
<div class="bg-green-50 p-3 rounded-lg">
<p class="text-sm text-green-600">Habits</p>
<p class="text-xl font-bold"><span id="habitCount">0</span>/<span id="habitTotal">0</span></p>
</div>
<div class="bg-purple-50 p-3 rounded-lg">
<p class="text-sm text-purple-600">Mood</p>
<p class="text-xl font-bold" id="moodScore">-</p>
</div>
</div>
</div>
<!-- Tasks Section -->
<div class="bg-white rounded-xl shadow p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">Tasks</h2>
<button id="addTaskBtn" class="px-3 py-1 bg-indigo-600 text-white rounded-full text-sm hover:bg-indigo-700 flex items-center space-x-1">
<i class="fas fa-plus text-xs"></i>
<span>Add Task</span>
</button>
</div>
<div id="taskForm" class="hidden mb-4">
<div class="flex space-x-2">
<input type="text" id="newTaskInput" placeholder="What needs to be done?" class="flex-1 px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<button id="saveTaskBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">Add</button>
</div>
<div class="flex items-center mt-2 space-x-4">
<div class="flex items-center">
<input type="checkbox" id="importantTask" class="mr-2">
<label for="importantTask" class="text-sm text-gray-600">Important</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="urgentTask" class="mr-2">
<label for="urgentTask" class="text-sm text-gray-600">Urgent</label>
</div>
</div>
</div>
<div id="taskList" class="space-y-2">
<p class="text-gray-500 text-center py-4">No tasks added yet</p>
</div>
</div>
<!-- Habits Section -->
<div class="bg-white rounded-xl shadow p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">Habits</h2>
<button id="addHabitBtn" class="px-3 py-1 bg-indigo-600 text-white rounded-full text-sm hover:bg-indigo-700 flex items-center space-x-1">
<i class="fas fa-plus text-xs"></i>
<span>Add Habit</span>
</button>
</div>
<div id="habitForm" class="hidden mb-4">
<div class="flex space-x-2">
<input type="text" id="newHabitInput" placeholder="What habit do you want to track?" class="flex-1 px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<button id="saveHabitBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">Add</button>
</div>
<div class="mt-2">
<p class="text-sm text-gray-600 mb-1">Frequency</p>
<div class="flex space-x-2">
<button class="frequency-btn px-3 py-1 bg-gray-200 rounded-full text-sm" data-frequency="daily">Daily</button>
<button class="frequency-btn px-3 py-1 bg-gray-200 rounded-full text-sm" data-frequency="weekly">Weekly</button>
<button class="frequency-btn px-3 py-1 bg-gray-200 rounded-full text-sm" data-frequency="monthly">Monthly</button>
</div>
</div>
</div>
<div id="habitList" class="space-y-3">
<p class="text-gray-500 text-center py-4">No habits added yet</p>
</div>
</div>
</div>
<!-- Right Column -->
<div class="space-y-6">
<!-- Mood Tracker -->
<div class="bg-white rounded-xl shadow p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4">How are you feeling today?</h2>
<div class="grid grid-cols-5 gap-2 mb-4">
<button class="mood-option p-2 rounded-full bg-red-100 text-red-500" data-mood="1">
<i class="fas fa-frown text-2xl"></i>
</button>
<button class="mood-option p-2 rounded-full bg-yellow-100 text-yellow-500" data-mood="2">
<i class="fas fa-meh text-2xl"></i>
</button>
<button class="mood-option p-2 rounded-full bg-blue-100 text-blue-500" data-mood="3">
<i class="fas fa-smile text-2xl"></i>
</button>
<button class="mood-option p-2 rounded-full bg-green-100 text-green-500" data-mood="4">
<i class="fas fa-laugh text-2xl"></i>
</button>
<button class="mood-option p-2 rounded-full bg-purple-100 text-purple-500" data-mood="5">
<i class="fas fa-grin-stars text-2xl"></i>
</button>
</div>
<div id="moodNotes" class="hidden">
<textarea id="moodJournal" placeholder="Add some notes about your day..." class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 h-24"></textarea>
<button id="saveMoodBtn" class="mt-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 w-full">Save Mood</button>
</div>
<div id="moodHistory" class="mt-4">
<h3 class="text-sm font-medium text-gray-500 mb-2">Recent Moods</h3>
<div id="moodHistoryList" class="space-y-2">
<p class="text-gray-500 text-sm">No mood data yet</p>
</div>
</div>
</div>
<!-- Mini Calendar -->
<div class="bg-white rounded-xl shadow p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">Calendar</h2>
<div class="flex space-x-2">
<button id="prevMonth" class="p-1 rounded-full hover:bg-gray-100">
<i class="fas fa-chevron-left"></i>
</button>
<button id="nextMonth" class="p-1 rounded-full hover:bg-gray-100">
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
<div id="currentMonthYear" class="text-center font-medium mb-2">June 2023</div>
<div class="grid grid-cols-7 gap-1 text-center text-sm">
<div class="font-medium py-1">Sun</div>
<div class="font-medium py-1">Mon</div>
<div class="font-medium py-1">Tue</div>
<div class="font-medium py-1">Wed</div>
<div class="font-medium py-1">Thu</div>
<div class="font-medium py-1">Fri</div>
<div class="font-medium py-1">Sat</div>
</div>
<div id="calendarDays" class="grid grid-cols-7 gap-1 text-center text-sm">
<!-- Calendar days will be populated here -->
</div>
</div>
<!-- Quick Notes -->
<div class="bg-white rounded-xl shadow p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Quick Notes</h2>
<textarea id="quickNotes" placeholder="Jot down any thoughts or reminders..." class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 h-32"></textarea>
<button id="saveNotesBtn" class="mt-2 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 w-full">Save Notes</button>
</div>
</div>
</div>
</div>
<script>
// Initialize data
let tasks = [];
let habits = [];
let moods = [];
let notes = "";
let currentDate = new Date();
let currentMonth = currentDate.getMonth();
let currentYear = currentDate.getFullYear();
// DOM Elements
const currentDateEl = document.getElementById('currentDate');
const prevDayBtn = document.getElementById('prevDay');
const nextDayBtn = document.getElementById('nextDay');
const todayBtn = document.getElementById('todayBtn');
const taskCountEl = document.getElementById('taskCount');
const taskTotalEl = document.getElementById('taskTotal');
const habitCountEl = document.getElementById('habitCount');
const habitTotalEl = document.getElementById('habitTotal');
const moodScoreEl = document.getElementById('moodScore');
const addTaskBtn = document.getElementById('addTaskBtn');
const taskForm = document.getElementById('taskForm');
const newTaskInput = document.getElementById('newTaskInput');
const saveTaskBtn = document.getElementById('saveTaskBtn');
const importantTask = document.getElementById('importantTask');
const urgentTask = document.getElementById('urgentTask');
const taskList = document.getElementById('taskList');
const addHabitBtn = document.getElementById('addHabitBtn');
const habitForm = document.getElementById('habitForm');
const newHabitInput = document.getElementById('newHabitInput');
const saveHabitBtn = document.getElementById('saveHabitBtn');
const habitList = document.getElementById('habitList');
const frequencyBtns = document.querySelectorAll('.frequency-btn');
const moodOptions = document.querySelectorAll('.mood-option');
const moodNotes = document.getElementById('moodNotes');
const moodJournal = document.getElementById('moodJournal');
const saveMoodBtn = document.getElementById('saveMoodBtn');
const moodHistoryList = document.getElementById('moodHistoryList');
const prevMonthBtn = document.getElementById('prevMonth');
const nextMonthBtn = document.getElementById('nextMonth');
const currentMonthYearEl = document.getElementById('currentMonthYear');
const calendarDaysEl = document.getElementById('calendarDays');
const quickNotes = document.getElementById('quickNotes');
const saveNotesBtn = document.getElementById('saveNotesBtn');
const notificationBtn = document.getElementById('notificationBtn');
const notificationCount = document.getElementById('notificationCount');
const notificationDropdown = document.getElementById('notificationDropdown');
// Format date as "Weekday, Month Day, Year"
function formatDate(date) {
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
return date.toLocaleDateString('en-US', options);
}
// Format date as YYYY-MM-DD for storage
function formatDateKey(date) {
return date.toISOString().split('T')[0];
}
// Update the UI with the current date
function updateDateDisplay() {
currentDateEl.textContent = formatDate(currentDate);
loadDayData();
generateCalendar();
}
// Load data for the current day
function loadDayData() {
const dateKey = formatDateKey(currentDate);
// Load tasks
const dayTasks = tasks.filter(task => task.date === dateKey);
renderTasks(dayTasks);
// Load habits
const dayHabits = habits.filter(habit => {
if (habit.frequency === 'daily') return true;
if (habit.frequency === 'weekly' && currentDate.getDay() === 0) return true; // Sunday
if (habit.frequency === 'monthly' && currentDate.getDate() === 1) return true; // 1st of month
return false;
});
renderHabits(dayHabits);
// Load mood
const dayMood = moods.find(mood => mood.date === dateKey);
if (dayMood) {
moodScoreEl.textContent = dayMood.score;
moodJournal.value = dayMood.notes || '';
moodHistoryList.innerHTML = `
<div class="flex items-center justify-between bg-gray-50 p-2 rounded">
<div class="flex items-center">
<i class="fas ${getMoodIcon(dayMood.score)} text-${getMoodColor(dayMood.score)}-500 mr-2"></i>
<span>${dayMood.score}/5</span>
</div>
<span class="text-xs text-gray-500">Today</span>
</div>
`;
} else {
moodScoreEl.textContent = '-';
moodJournal.value = '';
moodHistoryList.innerHTML = '<p class="text-gray-500 text-sm">No mood data yet</p>';
}
// Load quick notes
quickNotes.value = notes;
// Update stats
updateStats();
}
// Update the quick stats display
function updateStats() {
const dateKey = formatDateKey(currentDate);
// Task stats
const dayTasks = tasks.filter(task => task.date === dateKey);
const completedTasks = dayTasks.filter(task => task.completed).length;
taskCountEl.textContent = completedTasks;
taskTotalEl.textContent = dayTasks.length;
// Habit stats
const dayHabits = habits.filter(habit => {
if (habit.frequency === 'daily') return true;
if (habit.frequency === 'weekly' && currentDate.getDay() === 0) return true;
if (habit.frequency === 'monthly' && currentDate.getDate() === 1) return true;
return false;
});
const completedHabits = dayHabits.filter(habit => habit.completedDates.includes(dateKey)).length;
habitCountEl.textContent = completedHabits;
habitTotalEl.textContent = dayHabits.length;
}
// Render tasks to the UI
function renderTasks(taskArray) {
if (taskArray.length === 0) {
taskList.innerHTML = '<p class="text-gray-500 text-center py-4">No tasks added yet</p>';
return;
}
taskList.innerHTML = '';
taskArray.forEach((task, index) => {
const taskEl = document.createElement('div');
taskEl.className = `flex items-center justify-between p-3 border rounded-lg ${task.completed ? 'bg-gray-50' : 'bg-white'}`;
taskEl.dataset.id = index;
const leftContent = document.createElement('div');
leftContent.className = 'flex items-center';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.className = 'mr-3 h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500';
checkbox.checked = task.completed;
checkbox.addEventListener('change', () => toggleTaskComplete(index));
const taskText = document.createElement('span');
taskText.className = `${task.completed ? 'line-through text-gray-400' : 'text-gray-700'}`;
taskText.textContent = task.text;
leftContent.appendChild(checkbox);
leftContent.appendChild(taskText);
const rightContent = document.createElement('div');
rightContent.className = 'flex items-center space-x-2';
if (task.important) {
const importantIcon = document.createElement('i');
importantIcon.className = 'fas fa-exclamation-circle text-red-500';
rightContent.appendChild(importantIcon);
}
if (task.urgent) {
const urgentIcon = document.createElement('i');
urgentIcon.className = 'fas fa-bolt text-yellow-500';
rightContent.appendChild(urgentIcon);
}
const deleteBtn = document.createElement('button');
deleteBtn.className = 'text-gray-400 hover:text-red-500';
deleteBtn.innerHTML = '<i class="fas fa-trash"></i>';
deleteBtn.addEventListener('click', (e) => {
e.stopPropagation();
deleteTask(index);
});
rightContent.appendChild(deleteBtn);
taskEl.appendChild(leftContent);
taskEl.appendChild(rightContent);
taskList.appendChild(taskEl);
});
}
// Render habits to the UI
function renderHabits(habitArray) {
if (habitArray.length === 0) {
habitList.innerHTML = '<p class="text-gray-500 text-center py-4">No habits added yet</p>';
return;
}
habitList.innerHTML = '';
habitArray.forEach((habit, index) => {
const dateKey = formatDateKey(currentDate);
const isCompleted = habit.completedDates.includes(dateKey);
const habitEl = document.createElement('div');
habitEl.className = 'flex items-center justify-between p-3 border rounded-lg bg-white';
habitEl.dataset.id = index;
const leftContent = document.createElement('div');
leftContent.className = 'flex items-center';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.className = 'mr-3 h-5 w-5 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500';
checkbox.checked = isCompleted;
checkbox.addEventListener('change', () => toggleHabitComplete(index));
const habitText = document.createElement('div');
const habitTitle = document.createElement('span');
habitTitle.className = 'text-gray-700';
habitTitle.textContent = habit.text;
const habitFrequency = document.createElement('p');
habitFrequency.className = 'text-xs text-gray-500';
habitFrequency.textContent = `Frequency: ${habit.frequency}`;
habitText.appendChild(habitTitle);
habitText.appendChild(habitFrequency);
leftContent.appendChild(checkbox);
leftContent.appendChild(habitText);
const rightContent = document.createElement('div');
rightContent.className = 'flex items-center space-x-2';
const streakText = document.createElement('span');
streakText.className = 'text-xs bg-indigo-100 text-indigo-800 px-2 py-1 rounded-full';
streakText.textContent = `Streak: ${habit.streak}`;
const deleteBtn = document.createElement('button');
deleteBtn.className = 'text-gray-400 hover:text-red-500';
deleteBtn.innerHTML = '<i class="fas fa-trash"></i>';
deleteBtn.addEventListener('click', (e) => {
e.stopPropagation();
deleteHabit(index);
});
rightContent.appendChild(streakText);
rightContent.appendChild(deleteBtn);
habitEl.appendChild(leftContent);
habitEl.appendChild(rightContent);
habitList.appendChild(habitEl);
});
}
// Generate calendar view
function generateCalendar() {
const firstDay = new Date(currentYear, currentMonth, 1);
const lastDay = new Date(currentYear, currentMonth + 1, 0);
const daysInMonth = lastDay.getDate();
const startingDay = firstDay.getDay();
currentMonthYearEl.textContent = new Date(currentYear, currentMonth).toLocaleDateString('en-US', { month: 'long', year: 'numeric' });
calendarDaysEl.innerHTML = '';
// Add empty cells for days before the first day of the month
for (let i = 0; i < startingDay; i++) {
const emptyDay = document.createElement('div');
emptyDay.className = 'empty-day py-1';
calendarDaysEl.appendChild(emptyDay);
}
// Add cells for each day of the month
for (let day = 1; day <= daysInMonth; day++) {
const dayCell = document.createElement('div');
dayCell.className = 'calendar-day py-1 rounded';
// Highlight today
const date = new Date(currentYear, currentMonth, day);
if (date.toDateString() === new Date().toDateString()) {
dayCell.classList.add('bg-indigo-100', 'font-medium');
}
// Highlight selected day
if (date.toDateString() === currentDate.toDateString()) {
dayCell.classList.add('bg-indigo-500', 'text-white');
}
dayCell.textContent = day;
dayCell.addEventListener('click', () => {
currentDate = new Date(currentYear, currentMonth, day);
updateDateDisplay();
});
calendarDaysEl.appendChild(dayCell);
}
}
// Get mood icon based on score
function getMoodIcon(score) {
switch(score) {
case 1: return 'fa-frown';
case 2: return 'fa-meh';
case 3: return 'fa-smile';
case 4: return 'fa-laugh';
case 5: return 'fa-grin-stars';
default: return 'fa-question';
}
}
// Get mood color based on score
function getMoodColor(score) {
switch(score) {
case 1: return 'red';
case 2: return 'yellow';
case 3: return 'blue';
case 4: return 'green';
case 5: return 'purple';
default: return 'gray';
}
}
// Toggle task completion status
function toggleTaskComplete(index) {
const dateKey = formatDateKey(currentDate);
tasks[index].completed = !tasks[index].completed;
// Add notification for task completion
if (tasks[index].completed) {
addNotification(`Task completed: ${tasks[index].text}`);
}
// Animation for completed task
if (tasks[index].completed) {
const taskEl = document.querySelector(`#taskList div[data-id="${index}"]`);
taskEl.classList.add('completed');
setTimeout(() => {
renderTasks(tasks.filter(task => task.date === dateKey));
updateStats();
}, 500);
} else {
renderTasks(tasks.filter(task => task.date === dateKey));
updateStats();
}
}
// Toggle habit completion status
function toggleHabitComplete(index) {
const dateKey = formatDateKey(currentDate);
const habit = habits[index];
if (habit.completedDates.includes(dateKey)) {
// Remove from completed dates
habit.completedDates = habit.completedDates.filter(d => d !== dateKey);
// Decrease streak if this was the most recent completion
const sortedDates = [...habit.completedDates].sort();
if (sortedDates.length > 0) {
const lastDate = new Date(sortedDates[sortedDates.length - 1]);
const yesterday = new Date(currentDate);
yesterday.setDate(yesterday.getDate() - 1);
if (lastDate.toDateString() !== yesterday.toDateString()) {
habit.streak = sortedDates.length;
}
} else {
habit.streak = 0;
}
} else {
// Add to completed dates
habit.completedDates.push(dateKey);
// Check if this continues a streak
const yesterday = new Date(currentDate);
yesterday.setDate(yesterday.getDate() - 1);
const yesterdayKey = formatDateKey(yesterday);
if (habit.completedDates.includes(yesterdayKey) || habit.completedDates.length === 1) {
habit.streak++;
} else {
habit.streak = 1;
}
// Add notification for habit completion
addNotification(`Habit completed: ${habit.text}`);
}
renderHabits(habits.filter(h => {
if (h.frequency === 'daily') return true;
if (h.frequency === 'weekly' && currentDate.getDay() === 0) return true;
if (h.frequency === 'monthly' && currentDate.getDate() === 1) return true;
return false;
}));
updateStats();
}
// Add a new task
function addTask() {
const text = newTaskInput.value.trim();
if (!text) return;
const dateKey = formatDateKey(currentDate);
tasks.push({
text,
date: dateKey,
completed: false,
important: importantTask.checked,
urgent: urgentTask.checked
});
newTaskInput.value = '';
importantTask.checked = false;
urgentTask.checked = false;
taskForm.classList.add('hidden');
renderTasks(tasks.filter(task => task.date === dateKey));
updateStats();
// Add notification for new task
addNotification(`New task added: ${text}`);
}
// Add a new habit
function addHabit() {
const text = newHabitInput.value.trim();
if (!text) return;
const frequency = document.querySelector('.frequency-btn.active')?.dataset.frequency || 'daily';
habits.push({
text,
frequency,
completedDates: [],
streak: 0
});
newHabitInput.value = '';
habitForm.classList.add('hidden');
renderHabits(habits.filter(h => {
if (h.frequency === 'daily') return true;
if (h.frequency === 'weekly' && currentDate.getDay() === 0) return true;
if (h.frequency === 'monthly' && currentDate.getDate() === 1) return true;
return false;
}));
updateStats();
// Add notification for new habit
addNotification(`New habit added: ${text}`);
}
// Delete a task
function deleteTask(index) {
tasks.splice(index, 1);
const dateKey = formatDateKey(currentDate);
renderTasks(tasks.filter(task => task.date === dateKey));
updateStats();
}
// Delete a habit
function deleteHabit(index) {
habits.splice(index, 1);
renderHabits(habits.filter(h => {
if (h.frequency === 'daily') return true;
if (h.frequency === 'weekly' && currentDate.getDay() === 0) return true;
if (h.frequency === 'monthly' && currentDate.getDate() === 1) return true;
return false;
}));
updateStats();
}
// Save mood data
function saveMood(score) {
const dateKey = formatDateKey(currentDate);
const existingIndex = moods.findIndex(m => m.date === dateKey);
const moodData = {
date: dateKey,
score: parseInt(score),
notes: moodJournal.value
};
if (existingIndex >= 0) {
moods[existingIndex] = moodData;
} else {
moods.push(moodData);
}
moodNotes.classList.add('hidden');
moodScoreEl.textContent = score;
// Update mood history
moodHistoryList.innerHTML = `
<div class="flex items-center justify-between bg-gray-50 p-2 rounded">
<div class="flex items-center">
<i class="fas ${getMoodIcon(score)} text-${getMoodColor(score)}-500 mr-2"></i>
<span>${score}/5</span>
</div>
<span class="text-xs text-gray-500">Today</span>
</div>
`;
// Add notification for mood update
addNotification(`Mood recorded: ${score}/5`);
}
// Save quick notes
function saveNotes() {
notes = quickNotes.value;
// Add notification for notes saved
addNotification('Notes saved');
}
// Add notification
function addNotification(message) {
const notification = document.createElement('div');
notification.className = 'p-2 border-b border-gray-100';
notification.innerHTML = `
<p class="text-sm">${message}</p>
<p class="text-xs text-gray-500">Just now</p>
`;
notificationDropdown.insertBefore(notification, notificationDropdown.firstChild);
// Show notification count
const count = notificationDropdown.children.length - 1; // Subtract the "No notifications" message
if (count > 0) {
notificationCount.textContent = count;
notificationCount.classList.remove('hidden');
// Add pulse animation to notification button
notificationBtn.classList.add('pulse');
setTimeout(() => {
notificationBtn.classList.remove('pulse');
}, 3000);
}
// Remove "No notifications" message if present
const noNotifications = notificationDropdown.querySelector('p.text-gray-500');
if (noNotifications && count > 0) {
noNotifications.remove();
}
}
// Event Listeners
prevDayBtn.addEventListener('click', () => {
currentDate.setDate(currentDate.getDate() - 1);
updateDateDisplay();
});
nextDayBtn.addEventListener('click', () => {
currentDate.setDate(currentDate.getDate() + 1);
updateDateDisplay();
});
todayBtn.addEventListener('click', () => {
currentDate = new Date();
updateDateDisplay();
});
addTaskBtn.addEventListener('click', () => {
taskForm.classList.toggle('hidden');
if (!taskForm.classList.contains('hidden')) {
newTaskInput.focus();
}
});
saveTaskBtn.addEventListener('click', addTask);
newTaskInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') addTask();
});
addHabitBtn.addEventListener('click', () => {
habitForm.classList.toggle('hidden');
if (!habitForm.classList.contains('hidden')) {
newHabitInput.focus();
}
});
saveHabitBtn.addEventListener('click', addHabit);
newHabitInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') addHabit();
});
frequencyBtns.forEach(btn => {
btn.addEventListener('click', () => {
frequencyBtns.forEach(b => b.classList.remove('bg-indigo-600', 'text-white'));
btn.classList.add('bg-indigo-600', 'text-white');
btn.classList.add('active');
});
});
moodOptions.forEach(option => {
option.addEventListener('click', () => {
const score = option.dataset.mood;
moodNotes.classList.remove('hidden');
moodJournal.focus();
// Set up save button with this score
saveMoodBtn.onclick = () => saveMood(score);
});
});
prevMonthBtn.addEventListener('click', () => {
currentMonth--;
if (currentMonth < 0) {
currentMonth = 11;
currentYear--;
}
generateCalendar();
});
nextMonthBtn.addEventListener('click', () => {
currentMonth++;
if (currentMonth > 11) {
currentMonth = 0;
currentYear++;
}
generateCalendar();
});
saveNotesBtn.addEventListener('click', saveNotes);
notificationBtn.addEventListener('click', () => {
notificationDropdown.classList.toggle('hidden');
// Reset notification count when dropdown is opened
if (!notificationDropdown.classList.contains('hidden')) {
notificationCount.classList.add('hidden');
notificationCount.textContent = '0';
}
});
// Close dropdowns when clicking outside
document.addEventListener('click', (e) => {
if (!notificationBtn.contains(e.target) && !notificationDropdown.contains(e.target)) {
notificationDropdown.classList.add('hidden');
}
});
// Initialize the app
updateDateDisplay();
// Sample data for demo purposes
tasks = [
{ text: "Complete project proposal", date: formatDateKey(new Date()), completed: false, important: true, urgent: true },
{ text: "Buy groceries", date: formatDateKey(new Date()), completed: false, important: true, urgent: false },
{ text: "Call mom", date: formatDateKey(new Date()), completed: true, important: false, urgent: false }
];
habits = [
{ text: "Drink 8 glasses of water", frequency: "daily", completedDates: [formatDateKey(new Date())], streak: 5 },
{ text: "30-minute workout", frequency: "daily", completedDates: [], streak: 0 },
{ text: "Weekly review", frequency: "weekly", completedDates: [], streak: 2 }
];
moods = [
{ date: formatDateKey(new Date()), score: 4, notes: "Had a productive day at work!" }
];
// Render initial data
loadDayData();
</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=maylay0/x4" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>