File size: 16,964 Bytes
e44cae2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0dcfbe
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ScribbleSync - Digital Notepad</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>
    <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
    <style>
        .note-card {
            transition: all 0.3s ease;
        }
        .note-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);
        }
        #vanta-bg {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            opacity: 0.1;
        }
    </style>
</head>
<body class="bg-gray-50">
    <div id="vanta-bg"></div>
    
    <!-- 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-indigo-500 text-gray-900 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>
                    </div>
                </div>
                <div class="hidden sm:ml-6 sm:flex sm:items-center">
                    <button id="new-note-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
                        <i data-feather="plus" class="mr-1 h-4 w-4"></i> New Note
                    </button>
                </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="bg-indigo-50 border-indigo-500 text-indigo-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>
                <button id="mobile-new-note-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center ml-3 mt-2 mb-2">
                    <i data-feather="plus" class="mr-1 h-4 w-4"></i> New Note
                </button>
            </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">Your Notes</h1>
                <p class="mt-2 text-sm text-gray-500">Create, edit and organize your thoughts</p>
            </div>

            <!-- Notes Grid -->
            <div id="notes-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                <!-- Note cards will be added here dynamically -->
            </div>

            <!-- Empty State -->
            <div id="empty-state" class="text-center py-16 hidden">
                <i data-feather="edit" class="mx-auto h-12 w-12 text-gray-400"></i>
                <h3 class="mt-2 text-lg font-medium text-gray-900">No notes</h3>
                <p class="mt-1 text-sm text-gray-500">Get started by creating a new note.</p>
                <div class="mt-6">
                    <button id="empty-new-note-btn" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
                        <i data-feather="plus" class="-ml-1 mr-2 h-5 w-5"></i> New Note
                    </button>
                </div>
            </div>
        </div>
    </main>

    <!-- Note Editor Modal -->
    <div id="note-modal" class="fixed z-50 inset-0 overflow-y-auto hidden" aria-labelledby="modal-title" role="dialog" aria-modal="true">
        <div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
            <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div>
            <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
            <div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
                <div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                    <div class="sm:flex sm:items-start">
                        <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
                            <h3 class="text-lg leading-6 font-medium text-gray-900 mb-4" id="modal-title">
                                <span id="modal-title-text">New Note</span>
                            </h3>
                            <div class="mt-2">
                                <input type="text" id="note-title" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md mb-4 p-2" placeholder="Note title">
                                <textarea id="note-content" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md p-2 h-64" placeholder="Write your note here..."></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
                    <button type="button" id="save-note-btn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-base font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:ml-3 sm:w-auto sm:text-sm">
                        Save
                    </button>
                    <button type="button" id="cancel-note-btn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
                        Cancel
                    </button>
                    <button type="button" id="delete-note-btn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-red-600 text-white font-medium hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm hidden">
                        Delete
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Initialize Vanta.js background
        VANTA.NET({
            el: "#vanta-bg",
            color: 0x6366f1,
            backgroundColor: 0xf9fafb,
            points: 10,
            maxDistance: 20,
            spacing: 15
        });

        // Initialize Feather Icons
        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');
                }
            });

            // Note management
            let notes = JSON.parse(localStorage.getItem('notes')) || [];
            let currentNoteId = null;
            
            // DOM elements
            const notesContainer = document.getElementById('notes-container');
            const emptyState = document.getElementById('empty-state');
            const noteModal = document.getElementById('note-modal');
            const noteTitle = document.getElementById('note-title');
            const noteContent = document.getElementById('note-content');
            const saveNoteBtn = document.getElementById('save-note-btn');
            const cancelNoteBtn = document.getElementById('cancel-note-btn');
            const deleteNoteBtn = document.getElementById('delete-note-btn');
            const modalTitle = document.getElementById('modal-title-text');
            
            // New note buttons
            const newNoteBtn = document.getElementById('new-note-btn');
            const mobileNewNoteBtn = document.getElementById('mobile-new-note-btn');
            const emptyNewNoteBtn = document.getElementById('empty-new-note-btn');
            
            // Event listeners for new note buttons
            [newNoteBtn, mobileNewNoteBtn, emptyNewNoteBtn].forEach(btn => {
                btn.addEventListener('click', () => {
                    openNewNoteModal();
                });
            });
            
            // Cancel note button
            cancelNoteBtn.addEventListener('click', closeNoteModal);
            
            // Save note button
            saveNoteBtn.addEventListener('click', saveNote);
            
            // Delete note button
            deleteNoteBtn.addEventListener('click', deleteNote);
            
            // Initial render
            renderNotes();
            
            // Functions
            function openNewNoteModal() {
                currentNoteId = null;
                noteTitle.value = '';
                noteContent.value = '';
                modalTitle.textContent = 'New Note';
                deleteNoteBtn.classList.add('hidden');
                noteModal.classList.remove('hidden');
                noteTitle.focus();
            }
            
            function openEditNoteModal(id) {
                const note = notes.find(note => note.id === id);
                if (note) {
                    currentNoteId = id;
                    noteTitle.value = note.title;
                    noteContent.value = note.content;
                    modalTitle.textContent = 'Edit Note';
                    deleteNoteBtn.classList.remove('hidden');
                    noteModal.classList.remove('hidden');
                    noteTitle.focus();
                }
            }
            
            function closeNoteModal() {
                noteModal.classList.add('hidden');
            }
            
            function saveNote() {
                const title = noteTitle.value.trim();
                const content = noteContent.value.trim();
                
                if (!title) {
                    alert('Please enter a title for your note');
                    return;
                }
                
                const now = new Date();
                const timestamp = now.toISOString();
                
                if (currentNoteId) {
                    // Update existing note
                    const noteIndex = notes.findIndex(note => note.id === currentNoteId);
                    if (noteIndex !== -1) {
                        notes[noteIndex] = {
                            ...notes[noteIndex],
                            title,
                            content,
                            updatedAt: timestamp
                        };
                    }
                } else {
                    // Create new note
                    const newNote = {
                        id: Date.now().toString(),
                        title,
                        content,
                        createdAt: timestamp,
                        updatedAt: timestamp
                    };
                    notes.unshift(newNote);
                }
                
                saveToLocalStorage();
                renderNotes();
                closeNoteModal();
            }
            function deleteNote() {
                if (confirm('Are you sure you want to delete this note?')) {
                    const noteIndex = notes.findIndex(note => note.id === currentNoteId);
                    if (noteIndex !== -1) {
                        const deletedNote = notes[noteIndex];
                        
                        // Add to trash
                        const trash = JSON.parse(localStorage.getItem('trash')) || [];
                        trash.push({
                            ...deletedNote,
                            deletedAt: new Date().toISOString()
                        });
                        localStorage.setItem('trash', JSON.stringify(trash));
                        
                        // Remove from notes
                        notes.splice(noteIndex, 1);
                        saveToLocalStorage();
                        renderNotes();
                        closeNoteModal();
                    }
                }
            }
function saveToLocalStorage() {
                localStorage.setItem('notes', JSON.stringify(notes));
            }
            
            function renderNotes() {
                notesContainer.innerHTML = '';
                
                if (notes.length === 0) {
                    emptyState.classList.remove('hidden');
                    return;
                }
                
                emptyState.classList.add('hidden');
                
                notes.forEach(note => {
                    const noteDate = new Date(note.updatedAt);
                    const formattedDate = noteDate.toLocaleDateString('en-US', {
                        year: 'numeric',
                        month: 'short',
                        day: 'numeric',
                        hour: '2-digit',
                        minute: '2-digit'
                    });
                    
                    const truncatedContent = note.content.length > 150 
                        ? note.content.substring(0, 150) + '...'
                        : note.content;
                    
                    const noteCard = document.createElement('div');
                    noteCard.className = 'bg-white overflow-hidden shadow rounded-lg note-card cursor-pointer';
                    noteCard.innerHTML = `
                        <div class="px-4 py-5 sm:p-6" onclick="openEditNoteModal('${note.id}')">
                            <div class="flex items-center justify-between">
                                <h3 class="text-lg leading-6 font-medium text-gray-900">${note.title}</h3>
                                <span class="text-xs text-gray-500">${formattedDate}</span>
                            </div>
                            <div class="mt-2 text-sm text-gray-600">
                                <p>${truncatedContent}</p>
                            </div>
                        </div>
                    `;
                    
                    notesContainer.appendChild(noteCard);
                });
                
                feather.replace();
            }
            
            // Expose functions to global scope for inline event handlers
            window.openEditNoteModal = openEditNoteModal;
        });
    </script>
</body>
</html>