File size: 18,013 Bytes
e759df7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64f33e0
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
352
353
354
355
356
357
358
359
360
361
362
363
364
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ScribbleSync - Your Digital Notebook</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>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#6366f1',
                        secondary: '#8b5cf6',
                        accent: '#ec4899',
                        dark: '#1e293b',
                        light: '#f8fafc'
                    },
                    fontFamily: {
                        sans: ['Inter', 'sans-serif']
                    }
                }
            }
        }
    </script>
    <style>
        .note-card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .note-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .fade-in {
            animation: fadeIn 0.5s ease-in;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .active-tab {
            border-bottom: 3px solid #6366f1;
            color: #6366f1;
        }
        .sidebar-transition {
            transition: all 0.3s ease-in-out;
        }
    </style>
</head>
<body class="bg-gray-50 font-sans">
    <div class="flex h-screen">
        <!-- Sidebar -->
        <div id="sidebar" class="w-64 bg-white shadow-lg z-10 sidebar-transition">
            <div class="p-5 border-b border-gray-200">
                <h1 class="text-2xl font-bold text-primary flex items-center">
                    <i data-feather="edit-3" class="mr-2"></i>
                    ScribbleSync
                </h1>
                <p class="text-gray-500 text-sm mt-1">Your digital notebook</p>
            </div>
            
            <div class="p-4">
                <button id="newNoteBtn" class="w-full bg-primary hover:bg-indigo-600 text-white py-2 px-4 rounded-lg flex items-center justify-center mb-4 transition duration-300">
                    <i data-feather="plus-circle" class="mr-2"></i>
                    New Note
                </button>
                
                <div class="mt-6">
                    <h2 class="text-xs uppercase font-semibold text-gray-500 tracking-wider mb-2">Sections</h2>
                    <ul>
                        <li>
                            <button id="notesTab" class="w-full text-left py-2 px-4 rounded-lg flex items-center active-tab">
                                <i data-feather="file-text" class="mr-3"></i>
                                Notes
                            </button>
                        </li>
                        <li class="mt-1">
                            <button id="historyTab" class="w-full text-left py-2 px-4 rounded-lg flex items-center text-gray-600 hover:bg-gray-100">
                                <i data-feather="clock" class="mr-3"></i>
                                History
                            </button>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <!-- Main Content -->
        <div class="flex-1 flex flex-col overflow-hidden">
            <!-- Top Bar -->
            <header class="bg-white shadow-sm z-10">
                <div class="flex items-center justify-between p-4">
                    <div class="flex items-center">
                        <button id="menuToggle" class="md:hidden mr-4 text-gray-600">
                            <i data-feather="menu"></i>
                        </button>
                        <h2 id="currentSectionTitle" class="text-xl font-semibold text-gray-800">My Notes</h2>
                    </div>
                    <div class="relative">
                        <input type="text" placeholder="Search notes..." class="pl-10 pr-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
                        <i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
                    </div>
                </div>
            </header>

            <!-- Content Area -->
            <main class="flex-1 overflow-y-auto p-6 bg-gray-50">
                <!-- Notes Section -->
                <section id="notesSection" class="fade-in">
                    <div class="flex justify-between items-center mb-6">
                        <h2 class="text-2xl font-bold text-gray-800">Recent Notes</h2>
                        <div class="flex space-x-2">
                            <button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
                                <i data-feather="filter" class="mr-2"></i>
                                Filter
                            </button>
                            <button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
                                <i data-feather="sort-asc" class="mr-2"></i>
                                Sort
                            </button>
                        </div>
                    </div>

                    <div id="notesContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                        <!-- Note cards will be dynamically inserted here -->
                    </div>
                </section>

                <!-- History Section (Hidden by default) -->
                <section id="historySection" class="hidden fade-in">
                    <div class="flex justify-between items-center mb-6">
                        <h2 class="text-2xl font-bold text-gray-800">Note History</h2>
                        <button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
                            <i data-feather="trash-2" class="mr-2"></i>
                            Clear History
                        </button>
                    </div>

                    <div id="historyContainer" class="space-y-4">
                        <!-- History items will be dynamically inserted here -->
                    </div>
                </section>
            </main>
        </div>
    </div>

    <!-- Note Editor Modal -->
    <div id="noteModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
        <div class="bg-white rounded-lg w-full max-w-2xl mx-4 max-h-[90vh] overflow-hidden flex flex-col">
            <div class="border-b border-gray-200 p-4 flex justify-between items-center">
                <h3 class="text-lg font-semibold">Edit Note</h3>
                <button id="closeModal" class="text-gray-500 hover:text-gray-700">
                    <i data-feather="x"></i>
                </button>
            </div>
            <div class="p-4 flex-1 overflow-y-auto">
                <input id="noteTitle" type="text" placeholder="Note Title" class="w-full text-2xl font-bold mb-4 p-2 border-b border-gray-200 focus:outline-none focus:border-primary">
                <textarea id="noteContent" placeholder="Start writing your note here..." class="w-full h-64 p-2 focus:outline-none"></textarea>
            </div>
            <div class="border-t border-gray-200 p-4 flex justify-end space-x-3">
                <button id="deleteNote" class="px-4 py-2 text-red-600 hover:bg-red-50 rounded-lg">Delete</button>
                <button id="saveNote" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-indigo-600">Save Note</button>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script>
        // Initialize feather icons
        feather.replace();

        // Sample data
        const sampleNotes = [
            { id: 1, title: "Project Ideas", content: "1. Mobile app for task management\n2. AI-powered recipe generator\n3. Virtual reality fitness app", date: "2023-05-15", tags: ["work", "ideas"] },
            { id: 2, title: "Meeting Notes", content: "Discussed new marketing strategy:\n- Focus on social media\n- Launch campaign in Q3\n- Budget allocation for ads", date: "2023-05-18", tags: ["meeting", "work"] },
            { id: 3, title: "Book Recommendations", content: "Fiction:\n- The Midnight Library by Matt Haig\n- Klara and the Sun by Kazuo Ishiguro\n\nNon-fiction:\n- Atomic Habits by James Clear", date: "2023-05-20", tags: ["books", "personal"] },
            { id: 4, title: "Travel Plans", content: "Destination: Japan\nDates: October 15-30\nItinerary:\n- Tokyo (5 days)\n- Kyoto (4 days)\n- Osaka (3 days)\nBudget: $3000", date: "2023-05-22", tags: ["travel", "plans"] },
            { id: 5, title: "Learning Goals", content: "This year I want to learn:\n1. Advanced JavaScript\n2. React Native\n3. Data Visualization\n4. Spanish (basic fluency)", date: "2023-05-25", tags: ["learning", "goals"] },
            { id: 6, title: "Recipe Collection", content: "Pasta Carbonara:\n- 400g spaghetti\n- 200g pancetta\n- 4 eggs\n- 100g pecorino cheese\n- Black pepper\n\nInstructions:\n1. Cook pasta...\n2. Fry pancetta...", date: "2023-05-28", tags: ["cooking", "recipes"] }
        ];

        const sampleHistory = [
            { id: 1, title: "Deleted: Shopping List", content: "Milk, Eggs, Bread, Fruits", date: "2023-05-30", action: "deleted" },
            { id: 2, title: "Modified: Project Ideas", content: "Added new idea: AI chatbot", date: "2023-05-29", action: "modified" },
            { id: 3, title: "Created: Budget Plan", content: "Monthly budget breakdown", date: "2023-05-28", action: "created" },
            { id: 4, title: "Deleted: Old Notes", content: "Outdated information", date: "2023-05-27", action: "deleted" }
        ];

        // DOM Elements
        const notesTab = document.getElementById('notesTab');
        const historyTab = document.getElementById('historyTab');
        const notesSection = document.getElementById('notesSection');
        const historySection = document.getElementById('historySection');
        const currentSectionTitle = document.getElementById('currentSectionTitle');
        const notesContainer = document.getElementById('notesContainer');
        const historyContainer = document.getElementById('historyContainer');
        const newNoteBtn = document.getElementById('newNoteBtn');
        const noteModal = document.getElementById('noteModal');
        const closeModal = document.getElementById('closeModal');
        const saveNote = document.getElementById('saveNote');
        const deleteNote = document.getElementById('deleteNote');
        const menuToggle = document.getElementById('menuToggle');
        const sidebar = document.getElementById('sidebar');
        const noteTitle = document.getElementById('noteTitle');
        const noteContent = document.getElementById('noteContent');

        // Current state
        let currentNoteId = null;
        let isSidebarOpen = true;

        // Initialize the app
        function initApp() {
            renderNotes();
            renderHistory();
            setupEventListeners();
        }

        // Render notes
        function renderNotes() {
            notesContainer.innerHTML = '';
            sampleNotes.forEach(note => {
                const noteCard = document.createElement('div');
                noteCard.className = 'note-card bg-white rounded-lg p-5 cursor-pointer';
                noteCard.innerHTML = `
                    <div class="flex justify-between items-start">
                        <h3 class="font-bold text-lg mb-2">${note.title}</h3>
                        <span class="text-xs text-gray-500">${formatDate(note.date)}</span>
                    </div>
                    <p class="text-gray-600 mb-4 whitespace-pre-line truncate">${note.content.substring(0, 100)}${note.content.length > 100 ? '...' : ''}</p>
                    <div class="flex flex-wrap gap-2">
                        ${note.tags.map(tag => `<span class="bg-purple-100 text-purple-800 text-xs px-2 py-1 rounded">${tag}</span>`).join('')}
                    </div>
                `;
                noteCard.addEventListener('click', () => openNoteEditor(note.id));
                notesContainer.appendChild(noteCard);
            });
        }

        // Render history
        function renderHistory() {
            historyContainer.innerHTML = '';
            sampleHistory.forEach(item => {
                const historyItem = document.createElement('div');
                historyItem.className = 'bg-white rounded-lg p-4 border-l-4 border-primary';
                historyItem.innerHTML = `
                    <div class="flex justify-between">
                        <h3 class="font-semibold">${item.title}</h3>
                        <span class="text-sm text-gray-500">${formatDate(item.date)}</span>
                    </div>
                    <p class="text-gray-600 my-2">${item.content}</p>
                    <div class="flex justify-between items-center">
                        <span class="text-xs px-2 py-1 rounded ${
                            item.action === 'created' ? 'bg-green-100 text-green-800' : 
                            item.action === 'modified' ? 'bg-blue-100 text-blue-800' : 
                            'bg-red-100 text-red-800'
                        }">
                            ${item.action.charAt(0).toUpperCase() + item.action.slice(1)}
                        </span>
                        <button class="text-primary hover:text-indigo-700 text-sm flex items-center">
                            <i data-feather="eye" class="mr-1"></i> View
                        </button>
                    </div>
                `;
                historyContainer.appendChild(historyItem);
            });
            feather.replace();
        }

        // Format date
        function formatDate(dateString) {
            const options = { year: 'numeric', month: 'short', day: 'numeric' };
            return new Date(dateString).toLocaleDateString(undefined, options);
        }

        // Open note editor
        function openNoteEditor(noteId = null) {
            currentNoteId = noteId;
            if (noteId) {
                const note = sampleNotes.find(n => n.id === noteId);
                noteTitle.value = note.title;
                noteContent.value = note.content;
                deleteNote.classList.remove('hidden');
            } else {
                noteTitle.value = '';
                noteContent.value = '';
                deleteNote.classList.add('hidden');
            }
            noteModal.classList.remove('hidden');
        }

        // Save note
        function saveCurrentNote() {
            // In a real app, this would save to a database
            console.log('Saving note:', noteTitle.value, noteContent.value);
            noteModal.classList.add('hidden');
            // Refresh notes display
            renderNotes();
        }

        // Delete note
        function deleteCurrentNote() {
            if (confirm('Are you sure you want to delete this note?')) {
                // In a real app, this would delete from a database
                console.log('Deleting note with ID:', currentNoteId);
                noteModal.classList.add('hidden');
                // Refresh notes display
                renderNotes();
            }
        }

        // Toggle sidebar on mobile
        function toggleSidebar() {
            isSidebarOpen = !isSidebarOpen;
            if (isSidebarOpen) {
                sidebar.classList.remove('-ml-64');
            } else {
                sidebar.classList.add('-ml-64');
            }
        }

        // Setup event listeners
        function setupEventListeners() {
            notesTab.addEventListener('click', () => {
                notesTab.classList.add('active-tab');
                historyTab.classList.remove('active-tab', 'text-gray-600');
                historyTab.classList.add('text-gray-600');
                notesSection.classList.remove('hidden');
                historySection.classList.add('hidden');
                currentSectionTitle.textContent = 'My Notes';
            });

            historyTab.addEventListener('click', () => {
                historyTab.classList.add('active-tab');
                notesTab.classList.remove('active-tab', 'text-gray-600');
                notesTab.classList.add('text-gray-600');
                historySection.classList.remove('hidden');
                notesSection.classList.add('hidden');
                currentSectionTitle.textContent = 'Note History';
            });

            newNoteBtn.addEventListener('click', () => openNoteEditor());
            closeModal.addEventListener('click', () => noteModal.classList.add('hidden'));
            saveNote.addEventListener('click', saveCurrentNote);
            deleteNote.addEventListener('click', deleteCurrentNote);
            menuToggle.addEventListener('click', toggleSidebar);

            // Close modal when clicking outside
            window.addEventListener('click', (e) => {
                if (e.target === noteModal) {
                    noteModal.classList.add('hidden');
                }
            });
        }

        // Initialize the app when DOM is loaded
        document.addEventListener('DOMContentLoaded', initApp);
    </script>
</body>
</html>