File size: 10,230 Bytes
e44cae2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ScribbleSync - Trash</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<style>
.trash-item {
transition: all 0.2s ease;
}
.trash-item:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-50">
<!-- Navigation -->
<nav class="bg-white shadow-sm fixed w-full z-10">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<div class="flex-shrink-0 flex items-center">
<i data-feather="edit-3" class="text-indigo-600 h-6 w-6"></i>
<span class="ml-2 text-xl font-bold text-indigo-600">ScribbleSync</span>
</div>
<div class="hidden sm:ml-6 sm:flex sm:space-x-8">
<a href="index.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Notes
</a>
<a href="history.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
History
</a>
<a href="trash.html" class="border-indigo-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Trash
</a>
</div>
</div>
<div class="-mr-2 flex items-center sm:hidden">
<button type="button" id="mobile-menu-button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500">
<i data-feather="menu"></i>
</button>
</div>
</div>
</div>
<!-- Mobile menu -->
<div id="mobile-menu" class="sm:hidden hidden">
<div class="pt-2 pb-3 space-y-1">
<a href="index.html" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">
Notes
</a>
<a href="history.html" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">
History
</a>
<a href="trash.html" class="bg-indigo-50 border-indigo-500 text-indigo-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium">
Trash
</a>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="pt-20 pb-10 px-4 sm:px-6 lg:px-8">
<div class="max-w-7xl mx-auto">
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Trash</h1>
<p class="mt-2 text-sm text-gray-500">Deleted notes will be permanently removed after 30 days</p>
</div>
<!-- Trash Items -->
<div id="trash-container" class="space-y-4">
<!-- Trash items will be added here dynamically -->
<div id="empty-trash" class="text-center py-16">
<i data-feather="trash-2" class="mx-auto h-12 w-12 text-gray-400"></i>
<h3 class="mt-2 text-lg font-medium text-gray-900">Trash is empty</h3>
<p class="mt-1 text-sm text-gray-500">Deleted notes will appear here</p>
</div>
</div>
</div>
</main>
<script>
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Mobile menu toggle
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
mobileMenuButton.addEventListener('click', function() {
if (mobileMenu.classList.contains('hidden')) {
mobileMenu.classList.remove('hidden');
} else {
mobileMenu.classList.add('hidden');
}
});
// Load trash items from localStorage
const trash = JSON.parse(localStorage.getItem('trash')) || [];
const trashContainer = document.getElementById('trash-container');
const emptyTrash = document.getElementById('empty-trash');
function renderTrashItems() {
trashContainer.innerHTML = '';
if (trash.length === 0) {
emptyTrash.classList.remove('hidden');
return;
}
emptyTrash.classList.add('hidden');
trash.forEach(item => {
const itemDate = new Date(item.deletedAt);
const formattedDate = itemDate.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
const daysLeft = 30 - Math.floor((new Date() - itemDate) / (1000 * 60 * 60 * 24));
const trashItem = document.createElement('div');
trashItem.className = 'bg-white overflow-hidden shadow rounded-lg trash-item p-6';
trashItem.innerHTML = `
<div class="flex justify-between items-start">
<div>
<h3 class="text-lg font-medium text-gray-900">${item.title}</h3>
<p class="text-sm text-gray-500 mt-1">Deleted ${formattedDate}</p>
<p class="text-sm ${daysLeft > 7 ? 'text-green-600' : 'text-red-600'} mt-1">
${daysLeft > 0 ? `Will be permanently deleted in ${daysLeft} days` : 'Will be deleted soon'}
</p>
</div>
<div class="flex space-x-2">
<button class="restore-btn p-2 rounded-full hover:bg-gray-100" data-id="${item.id}">
<i data-feather="rotate-ccw" class="text-indigo-600"></i>
</button>
<button class="delete-forever-btn p-2 rounded-full hover:bg-red-50" data-id="${item.id}">
<i data-feather="trash" class="text-red-600"></i>
</button>
</div>
</div>
<div class="mt-4 text-sm text-gray-600">
<p>${item.content.substring(0, 200)}${item.content.length > 200 ? '...' : ''}</p>
</div>
`;
trashContainer.appendChild(trashItem);
});
feather.replace();
// Add event listeners to buttons
document.querySelectorAll('.restore-btn').forEach(btn => {
btn.addEventListener('click', restoreItem);
});
document.querySelectorAll('.delete-forever-btn').forEach(btn => {
btn.addEventListener('click', deleteForever);
});
}
function restoreItem(e) {
const id = e.currentTarget.getAttribute('data-id');
const itemIndex = trash.findIndex(item => item.id === id);
if (itemIndex !== -1) {
const restoredItem = trash[itemIndex];
// Add back to notes
const notes = JSON.parse(localStorage.getItem('notes')) || [];
notes.unshift({
id: restoredItem.id,
title: restoredItem.title,
content: restoredItem.content,
createdAt: restoredItem.createdAt,
updatedAt: new Date().toISOString()
});
localStorage.setItem('notes', JSON.stringify(notes));
// Remove from trash
trash.splice(itemIndex, 1);
localStorage.setItem('trash', JSON.stringify(trash));
renderTrashItems();
}
}
function deleteForever(e) {
if (confirm('Are you sure you want to permanently delete this note? This action cannot be undone.')) {
const id = e.currentTarget.getAttribute('data-id');
const itemIndex = trash.findIndex(item => item.id === id);
if (itemIndex !== -1) {
trash.splice(itemIndex, 1);
localStorage.setItem('trash', JSON.stringify(trash));
renderTrashItems();
}
}
}
renderTrashItems();
});
</script>
</body>
</html> |