Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +471 -19
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: notetap
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,471 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en" class="dark">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Noted - Simple Note Taking App</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
/* Custom scrollbar */
|
| 11 |
+
::-webkit-scrollbar {
|
| 12 |
+
width: 8px;
|
| 13 |
+
}
|
| 14 |
+
::-webkit-scrollbar-track {
|
| 15 |
+
background: #f1f1f1;
|
| 16 |
+
}
|
| 17 |
+
.dark ::-webkit-scrollbar-track {
|
| 18 |
+
background: #1f2937;
|
| 19 |
+
}
|
| 20 |
+
::-webkit-scrollbar-thumb {
|
| 21 |
+
background: #9ca3af;
|
| 22 |
+
border-radius: 4px;
|
| 23 |
+
}
|
| 24 |
+
.dark ::-webkit-scrollbar-thumb {
|
| 25 |
+
background: #4b5563;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/* Animation for notes */
|
| 29 |
+
@keyframes fadeIn {
|
| 30 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 31 |
+
to { opacity: 1; transform: translateY(0); }
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.note-animation {
|
| 35 |
+
animation: fadeIn 0.3s ease-out forwards;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/* Custom checkbox */
|
| 39 |
+
.custom-checkbox {
|
| 40 |
+
appearance: none;
|
| 41 |
+
-webkit-appearance: none;
|
| 42 |
+
width: 20px;
|
| 43 |
+
height: 20px;
|
| 44 |
+
border: 2px solid #d1d5db;
|
| 45 |
+
border-radius: 4px;
|
| 46 |
+
cursor: pointer;
|
| 47 |
+
position: relative;
|
| 48 |
+
transition: all 0.2s;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.custom-checkbox:checked {
|
| 52 |
+
background-color: #3b82f6;
|
| 53 |
+
border-color: #3b82f6;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.custom-checkbox:checked::after {
|
| 57 |
+
content: "✓";
|
| 58 |
+
position: absolute;
|
| 59 |
+
color: white;
|
| 60 |
+
font-size: 12px;
|
| 61 |
+
left: 4px;
|
| 62 |
+
top: 1px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.dark .custom-checkbox {
|
| 66 |
+
border-color: #4b5563;
|
| 67 |
+
}
|
| 68 |
+
</style>
|
| 69 |
+
</head>
|
| 70 |
+
<body class="bg-gray-100 dark:bg-gray-900 transition-colors duration-200 min-h-screen">
|
| 71 |
+
<div class="container mx-auto px-4 py-8 max-w-6xl">
|
| 72 |
+
<!-- Header -->
|
| 73 |
+
<header class="flex justify-between items-center mb-8">
|
| 74 |
+
<div class="flex items-center">
|
| 75 |
+
<i class="fas fa-sticky-note text-blue-500 text-3xl mr-3"></i>
|
| 76 |
+
<h1 class="text-3xl font-bold text-gray-800 dark:text-white">Noted</h1>
|
| 77 |
+
</div>
|
| 78 |
+
<div class="flex items-center space-x-4">
|
| 79 |
+
<button id="themeToggle" class="p-2 rounded-full bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors">
|
| 80 |
+
<i class="fas fa-moon dark:hidden"></i>
|
| 81 |
+
<i class="fas fa-sun hidden dark:inline"></i>
|
| 82 |
+
</button>
|
| 83 |
+
<button id="clearAllBtn" class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors hidden">
|
| 84 |
+
<i class="fas fa-trash mr-2"></i>Clear All
|
| 85 |
+
</button>
|
| 86 |
+
</div>
|
| 87 |
+
</header>
|
| 88 |
+
|
| 89 |
+
<!-- Search and Add Note -->
|
| 90 |
+
<div class="flex flex-col md:flex-row gap-4 mb-8">
|
| 91 |
+
<div class="relative flex-grow">
|
| 92 |
+
<input type="text" id="searchInput" placeholder="Search notes..." class="w-full px-4 py-3 pl-10 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white">
|
| 93 |
+
<i class="fas fa-search absolute left-3 top-3.5 text-gray-400"></i>
|
| 94 |
+
</div>
|
| 95 |
+
<button id="addNoteBtn" class="px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors font-medium flex items-center justify-center">
|
| 96 |
+
<i class="fas fa-plus mr-2"></i> Add Note
|
| 97 |
+
</button>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
<!-- Notes Grid -->
|
| 101 |
+
<div id="notesContainer" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
|
| 102 |
+
<!-- Notes will be added here dynamically -->
|
| 103 |
+
</div>
|
| 104 |
+
|
| 105 |
+
<!-- Empty State -->
|
| 106 |
+
<div id="emptyState" class="text-center py-16">
|
| 107 |
+
<i class="fas fa-sticky-note text-gray-300 dark:text-gray-700 text-6xl mb-4"></i>
|
| 108 |
+
<h3 class="text-xl font-medium text-gray-500 dark:text-gray-400 mb-2">No notes yet</h3>
|
| 109 |
+
<p class="text-gray-400 dark:text-gray-500 mb-4">Click "Add Note" to create your first note</p>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<!-- Note Editor Modal -->
|
| 114 |
+
<div id="noteEditorModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50 hidden">
|
| 115 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col">
|
| 116 |
+
<div class="flex justify-between items-center p-4 border-b border-gray-200 dark:border-gray-700">
|
| 117 |
+
<h3 class="text-lg font-medium text-gray-800 dark:text-white" id="editorTitle">New Note</h3>
|
| 118 |
+
<button id="closeEditorBtn" class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-200">
|
| 119 |
+
<i class="fas fa-times text-xl"></i>
|
| 120 |
+
</button>
|
| 121 |
+
</div>
|
| 122 |
+
<div class="p-4 flex-grow overflow-y-auto">
|
| 123 |
+
<input type="text" id="noteTitleInput" placeholder="Title" class="w-full px-4 py-3 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white mb-4 font-medium">
|
| 124 |
+
<textarea id="noteContentInput" placeholder="Write your note here..." class="w-full px-4 py-3 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:text-white min-h-[200px]"></textarea>
|
| 125 |
+
<div class="mt-4 flex items-center">
|
| 126 |
+
<input type="checkbox" id="notePinnedInput" class="custom-checkbox mr-2">
|
| 127 |
+
<label for="notePinnedInput" class="text-gray-700 dark:text-gray-300 cursor-pointer">Pin this note</label>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
<div class="p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end space-x-3">
|
| 131 |
+
<button id="cancelNoteBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">
|
| 132 |
+
Cancel
|
| 133 |
+
</button>
|
| 134 |
+
<button id="saveNoteBtn" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors">
|
| 135 |
+
Save
|
| 136 |
+
</button>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</div>
|
| 140 |
+
|
| 141 |
+
<!-- Confirmation Modal -->
|
| 142 |
+
<div id="confirmModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50 hidden">
|
| 143 |
+
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md">
|
| 144 |
+
<div class="p-6">
|
| 145 |
+
<div class="flex items-center mb-4">
|
| 146 |
+
<i class="fas fa-exclamation-triangle text-yellow-500 text-2xl mr-3"></i>
|
| 147 |
+
<h3 class="text-lg font-medium text-gray-800 dark:text-white" id="confirmTitle">Confirm Action</h3>
|
| 148 |
+
</div>
|
| 149 |
+
<p class="text-gray-600 dark:text-gray-400 mb-6" id="confirmMessage">Are you sure you want to perform this action?</p>
|
| 150 |
+
<div class="flex justify-end space-x-3">
|
| 151 |
+
<button id="cancelConfirmBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">
|
| 152 |
+
Cancel
|
| 153 |
+
</button>
|
| 154 |
+
<button id="confirmActionBtn" class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors">
|
| 155 |
+
Confirm
|
| 156 |
+
</button>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
+
<script>
|
| 163 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 164 |
+
// DOM Elements
|
| 165 |
+
const notesContainer = document.getElementById('notesContainer');
|
| 166 |
+
const emptyState = document.getElementById('emptyState');
|
| 167 |
+
const addNoteBtn = document.getElementById('addNoteBtn');
|
| 168 |
+
const clearAllBtn = document.getElementById('clearAllBtn');
|
| 169 |
+
const searchInput = document.getElementById('searchInput');
|
| 170 |
+
const themeToggle = document.getElementById('themeToggle');
|
| 171 |
+
|
| 172 |
+
// Modal Elements
|
| 173 |
+
const noteEditorModal = document.getElementById('noteEditorModal');
|
| 174 |
+
const editorTitle = document.getElementById('editorTitle');
|
| 175 |
+
const noteTitleInput = document.getElementById('noteTitleInput');
|
| 176 |
+
const noteContentInput = document.getElementById('noteContentInput');
|
| 177 |
+
const notePinnedInput = document.getElementById('notePinnedInput');
|
| 178 |
+
const closeEditorBtn = document.getElementById('closeEditorBtn');
|
| 179 |
+
const cancelNoteBtn = document.getElementById('cancelNoteBtn');
|
| 180 |
+
const saveNoteBtn = document.getElementById('saveNoteBtn');
|
| 181 |
+
|
| 182 |
+
// Confirmation Modal Elements
|
| 183 |
+
const confirmModal = document.getElementById('confirmModal');
|
| 184 |
+
const confirmTitle = document.getElementById('confirmTitle');
|
| 185 |
+
const confirmMessage = document.getElementById('confirmMessage');
|
| 186 |
+
const cancelConfirmBtn = document.getElementById('cancelConfirmBtn');
|
| 187 |
+
const confirmActionBtn = document.getElementById('confirmActionBtn');
|
| 188 |
+
|
| 189 |
+
// App State
|
| 190 |
+
let notes = JSON.parse(localStorage.getItem('notes')) || [];
|
| 191 |
+
let currentNoteId = null;
|
| 192 |
+
let actionToConfirm = null;
|
| 193 |
+
let searchTerm = '';
|
| 194 |
+
|
| 195 |
+
// Initialize the app
|
| 196 |
+
function init() {
|
| 197 |
+
renderNotes();
|
| 198 |
+
updateEmptyState();
|
| 199 |
+
updateClearAllButton();
|
| 200 |
+
|
| 201 |
+
// Check for saved theme preference
|
| 202 |
+
const savedTheme = localStorage.getItem('theme');
|
| 203 |
+
if (savedTheme === 'dark' || (!savedTheme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
| 204 |
+
document.documentElement.classList.add('dark');
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// Render notes to the UI
|
| 209 |
+
function renderNotes() {
|
| 210 |
+
notesContainer.innerHTML = '';
|
| 211 |
+
|
| 212 |
+
// Filter notes based on search term
|
| 213 |
+
const filteredNotes = notes.filter(note =>
|
| 214 |
+
note.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
| 215 |
+
note.content.toLowerCase().includes(searchTerm.toLowerCase())
|
| 216 |
+
);
|
| 217 |
+
|
| 218 |
+
// Separate pinned and unpinned notes
|
| 219 |
+
const pinnedNotes = filteredNotes.filter(note => note.pinned);
|
| 220 |
+
const unpinnedNotes = filteredNotes.filter(note => !note.pinned);
|
| 221 |
+
|
| 222 |
+
// Render pinned notes first
|
| 223 |
+
if (pinnedNotes.length > 0) {
|
| 224 |
+
const pinnedSection = document.createElement('div');
|
| 225 |
+
pinnedSection.className = 'col-span-full mb-2';
|
| 226 |
+
pinnedSection.innerHTML = `
|
| 227 |
+
<h3 class="text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2 flex items-center">
|
| 228 |
+
<i class="fas fa-thumbtack mr-2"></i> Pinned Notes
|
| 229 |
+
</h3>
|
| 230 |
+
`;
|
| 231 |
+
notesContainer.appendChild(pinnedSection);
|
| 232 |
+
|
| 233 |
+
pinnedNotes.forEach(note => {
|
| 234 |
+
notesContainer.appendChild(createNoteElement(note));
|
| 235 |
+
});
|
| 236 |
+
|
| 237 |
+
// Add divider if there are both pinned and unpinned notes
|
| 238 |
+
if (unpinnedNotes.length > 0) {
|
| 239 |
+
const divider = document.createElement('div');
|
| 240 |
+
divider.className = 'col-span-full border-t border-gray-200 dark:border-gray-700 my-4';
|
| 241 |
+
notesContainer.appendChild(divider);
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
// Render unpinned notes
|
| 246 |
+
unpinnedNotes.forEach(note => {
|
| 247 |
+
notesContainer.appendChild(createNoteElement(note));
|
| 248 |
+
});
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
// Create a note element for the DOM
|
| 252 |
+
function createNoteElement(note) {
|
| 253 |
+
const noteElement = document.createElement('div');
|
| 254 |
+
noteElement.className = `note-animation bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden border border-gray-200 dark:border-gray-700 flex flex-col h-full ${note.pinned ? 'border-l-4 border-l-blue-500' : ''}`;
|
| 255 |
+
noteElement.dataset.id = note.id;
|
| 256 |
+
|
| 257 |
+
// Format the date
|
| 258 |
+
const date = new Date(note.updatedAt);
|
| 259 |
+
const formattedDate = date.toLocaleDateString('en-US', {
|
| 260 |
+
month: 'short',
|
| 261 |
+
day: 'numeric',
|
| 262 |
+
year: 'numeric'
|
| 263 |
+
});
|
| 264 |
+
|
| 265 |
+
noteElement.innerHTML = `
|
| 266 |
+
<div class="p-4 flex-grow">
|
| 267 |
+
<div class="flex justify-between items-start mb-2">
|
| 268 |
+
<h3 class="font-medium text-gray-800 dark:text-white truncate">${note.title}</h3>
|
| 269 |
+
<button class="pin-btn text-gray-400 hover:text-blue-500 ml-2" data-id="${note.id}">
|
| 270 |
+
<i class="fas ${note.pinned ? 'fa-thumbtack text-blue-500' : 'fa-thumbtack'}"></i>
|
| 271 |
+
</button>
|
| 272 |
+
</div>
|
| 273 |
+
<p class="text-gray-600 dark:text-gray-400 text-sm mb-4 line-clamp-3">${note.content}</p>
|
| 274 |
+
<div class="text-xs text-gray-400 dark:text-gray-500">${formattedDate}</div>
|
| 275 |
+
</div>
|
| 276 |
+
<div class="px-4 py-3 bg-gray-50 dark:bg-gray-700 border-t border-gray-200 dark:border-gray-700 flex justify-end space-x-2">
|
| 277 |
+
<button class="edit-btn px-3 py-1 text-sm text-blue-500 hover:text-blue-700 dark:hover:text-blue-400">
|
| 278 |
+
<i class="fas fa-edit mr-1"></i> Edit
|
| 279 |
+
</button>
|
| 280 |
+
<button class="delete-btn px-3 py-1 text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400">
|
| 281 |
+
<i class="fas fa-trash mr-1"></i> Delete
|
| 282 |
+
</button>
|
| 283 |
+
</div>
|
| 284 |
+
`;
|
| 285 |
+
|
| 286 |
+
return noteElement;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
// Update empty state visibility
|
| 290 |
+
function updateEmptyState() {
|
| 291 |
+
if (notes.length === 0) {
|
| 292 |
+
emptyState.classList.remove('hidden');
|
| 293 |
+
} else {
|
| 294 |
+
emptyState.classList.add('hidden');
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// Update clear all button visibility
|
| 299 |
+
function updateClearAllButton() {
|
| 300 |
+
if (notes.length > 0) {
|
| 301 |
+
clearAllBtn.classList.remove('hidden');
|
| 302 |
+
} else {
|
| 303 |
+
clearAllBtn.classList.add('hidden');
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
// Save notes to localStorage
|
| 308 |
+
function saveNotes() {
|
| 309 |
+
localStorage.setItem('notes', JSON.stringify(notes));
|
| 310 |
+
renderNotes();
|
| 311 |
+
updateEmptyState();
|
| 312 |
+
updateClearAllButton();
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
// Open note editor
|
| 316 |
+
function openNoteEditor(note = null) {
|
| 317 |
+
if (note) {
|
| 318 |
+
currentNoteId = note.id;
|
| 319 |
+
editorTitle.textContent = 'Edit Note';
|
| 320 |
+
noteTitleInput.value = note.title;
|
| 321 |
+
noteContentInput.value = note.content;
|
| 322 |
+
notePinnedInput.checked = note.pinned;
|
| 323 |
+
} else {
|
| 324 |
+
currentNoteId = null;
|
| 325 |
+
editorTitle.textContent = 'New Note';
|
| 326 |
+
noteTitleInput.value = '';
|
| 327 |
+
noteContentInput.value = '';
|
| 328 |
+
notePinnedInput.checked = false;
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
noteEditorModal.classList.remove('hidden');
|
| 332 |
+
noteTitleInput.focus();
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
// Close note editor
|
| 336 |
+
function closeNoteEditor() {
|
| 337 |
+
noteEditorModal.classList.add('hidden');
|
| 338 |
+
currentNoteId = null;
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
// Save note
|
| 342 |
+
function saveNote() {
|
| 343 |
+
const title = noteTitleInput.value.trim();
|
| 344 |
+
const content = noteContentInput.value.trim();
|
| 345 |
+
const pinned = notePinnedInput.checked;
|
| 346 |
+
|
| 347 |
+
if (!title && !content) {
|
| 348 |
+
// Don't save empty notes
|
| 349 |
+
closeNoteEditor();
|
| 350 |
+
return;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
const now = new Date();
|
| 354 |
+
|
| 355 |
+
if (currentNoteId) {
|
| 356 |
+
// Update existing note
|
| 357 |
+
const noteIndex = notes.findIndex(n => n.id === currentNoteId);
|
| 358 |
+
if (noteIndex !== -1) {
|
| 359 |
+
notes[noteIndex] = {
|
| 360 |
+
...notes[noteIndex],
|
| 361 |
+
title: title || 'Untitled Note',
|
| 362 |
+
content,
|
| 363 |
+
pinned,
|
| 364 |
+
updatedAt: now.getTime()
|
| 365 |
+
};
|
| 366 |
+
}
|
| 367 |
+
} else {
|
| 368 |
+
// Create new note
|
| 369 |
+
const newNote = {
|
| 370 |
+
id: Date.now().toString(),
|
| 371 |
+
title: title || 'Untitled Note',
|
| 372 |
+
content,
|
| 373 |
+
pinned,
|
| 374 |
+
createdAt: now.getTime(),
|
| 375 |
+
updatedAt: now.getTime()
|
| 376 |
+
};
|
| 377 |
+
notes.unshift(newNote);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
saveNotes();
|
| 381 |
+
closeNoteEditor();
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
// Delete note
|
| 385 |
+
function deleteNote(id) {
|
| 386 |
+
notes = notes.filter(note => note.id !== id);
|
| 387 |
+
saveNotes();
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
// Toggle note pinned status
|
| 391 |
+
function togglePinned(id) {
|
| 392 |
+
const noteIndex = notes.findIndex(n => n.id === id);
|
| 393 |
+
if (noteIndex !== -1) {
|
| 394 |
+
notes[noteIndex].pinned = !notes[noteIndex].pinned;
|
| 395 |
+
notes[noteIndex].updatedAt = new Date().getTime();
|
| 396 |
+
saveNotes();
|
| 397 |
+
}
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
// Show confirmation dialog
|
| 401 |
+
function showConfirmation(title, message, action) {
|
| 402 |
+
confirmTitle.textContent = title;
|
| 403 |
+
confirmMessage.textContent = message;
|
| 404 |
+
actionToConfirm = action;
|
| 405 |
+
confirmModal.classList.remove('hidden');
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
// Clear all notes
|
| 409 |
+
function clearAllNotes() {
|
| 410 |
+
notes = [];
|
| 411 |
+
saveNotes();
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
// Toggle dark/light theme
|
| 415 |
+
function toggleTheme() {
|
| 416 |
+
const html = document.documentElement;
|
| 417 |
+
if (html.classList.contains('dark')) {
|
| 418 |
+
html.classList.remove('dark');
|
| 419 |
+
localStorage.setItem('theme', 'light');
|
| 420 |
+
} else {
|
| 421 |
+
html.classList.add('dark');
|
| 422 |
+
localStorage.setItem('theme', 'dark');
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
// Event Listeners
|
| 427 |
+
addNoteBtn.addEventListener('click', () => openNoteEditor());
|
| 428 |
+
|
| 429 |
+
closeEditorBtn.addEventListener('click', closeNoteEditor);
|
| 430 |
+
cancelNoteBtn.addEventListener('click', closeNoteEditor);
|
| 431 |
+
|
| 432 |
+
saveNoteBtn.addEventListener('click', saveNote);
|
| 433 |
+
|
| 434 |
+
// Handle clicks on notes container (event delegation)
|
| 435 |
+
notesContainer.addEventListener('click', (e) => {
|
| 436 |
+
const noteElement = e.target.closest('.note-animation');
|
| 437 |
+
if (!noteElement) return;
|
| 438 |
+
|
| 439 |
+
const noteId = noteElement.dataset.id;
|
| 440 |
+
const note = notes.find(n => n.id === noteId);
|
| 441 |
+
|
| 442 |
+
if (e.target.classList.contains('edit-btn') || e.target.closest('.edit-btn')) {
|
| 443 |
+
openNoteEditor(note);
|
| 444 |
+
} else if (e.target.classList.contains('delete-btn') || e.target.closest('.delete-btn')) {
|
| 445 |
+
showConfirmation(
|
| 446 |
+
'Delete Note',
|
| 447 |
+
'Are you sure you want to delete this note? This action cannot be undone.',
|
| 448 |
+
() => deleteNote(noteId)
|
| 449 |
+
);
|
| 450 |
+
} else if (e.target.classList.contains('pin-btn') || e.target.closest('.pin-btn')) {
|
| 451 |
+
togglePinned(noteId);
|
| 452 |
+
}
|
| 453 |
+
});
|
| 454 |
+
|
| 455 |
+
// Clear all notes confirmation
|
| 456 |
+
clearAllBtn.addEventListener('click', () => {
|
| 457 |
+
showConfirmation(
|
| 458 |
+
'Clear All Notes',
|
| 459 |
+
'Are you sure you want to delete all notes? This action cannot be undone.',
|
| 460 |
+
clearAllNotes
|
| 461 |
+
);
|
| 462 |
+
});
|
| 463 |
+
|
| 464 |
+
// Confirmation modal events
|
| 465 |
+
cancelConfirmBtn.addEventListener('click', () => {
|
| 466 |
+
confirmModal.classList.add('hidden');
|
| 467 |
+
actionToConfirm = null;
|
| 468 |
+
});
|
| 469 |
+
|
| 470 |
+
confirmActionBtn.addEventListener
|
| 471 |
+
</html>
|
prompts.txt
ADDED
|
File without changes
|