Spaces:
Running
Running
Create a Notes App, with a notes section, and a history section.
Browse files- README.md +7 -4
- index.html +362 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🏃
|
| 4 |
colorFrom: yellow
|
| 5 |
-
colorTo:
|
|
|
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: ScribbleSync 📝
|
|
|
|
| 3 |
colorFrom: yellow
|
| 4 |
+
colorTo: purple
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
index.html
CHANGED
|
@@ -1,19 +1,363 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ScribbleSync - Your Digital Notebook</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 11 |
+
<script>
|
| 12 |
+
tailwind.config = {
|
| 13 |
+
theme: {
|
| 14 |
+
extend: {
|
| 15 |
+
colors: {
|
| 16 |
+
primary: '#6366f1',
|
| 17 |
+
secondary: '#8b5cf6',
|
| 18 |
+
accent: '#ec4899',
|
| 19 |
+
dark: '#1e293b',
|
| 20 |
+
light: '#f8fafc'
|
| 21 |
+
},
|
| 22 |
+
fontFamily: {
|
| 23 |
+
sans: ['Inter', 'sans-serif']
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
</script>
|
| 29 |
+
<style>
|
| 30 |
+
.note-card {
|
| 31 |
+
transition: all 0.3s ease;
|
| 32 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 33 |
+
}
|
| 34 |
+
.note-card:hover {
|
| 35 |
+
transform: translateY(-5px);
|
| 36 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
| 37 |
+
}
|
| 38 |
+
.fade-in {
|
| 39 |
+
animation: fadeIn 0.5s ease-in;
|
| 40 |
+
}
|
| 41 |
+
@keyframes fadeIn {
|
| 42 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 43 |
+
to { opacity: 1; transform: translateY(0); }
|
| 44 |
+
}
|
| 45 |
+
.active-tab {
|
| 46 |
+
border-bottom: 3px solid #6366f1;
|
| 47 |
+
color: #6366f1;
|
| 48 |
+
}
|
| 49 |
+
.sidebar-transition {
|
| 50 |
+
transition: all 0.3s ease-in-out;
|
| 51 |
+
}
|
| 52 |
+
</style>
|
| 53 |
+
</head>
|
| 54 |
+
<body class="bg-gray-50 font-sans">
|
| 55 |
+
<div class="flex h-screen">
|
| 56 |
+
<!-- Sidebar -->
|
| 57 |
+
<div id="sidebar" class="w-64 bg-white shadow-lg z-10 sidebar-transition">
|
| 58 |
+
<div class="p-5 border-b border-gray-200">
|
| 59 |
+
<h1 class="text-2xl font-bold text-primary flex items-center">
|
| 60 |
+
<i data-feather="edit-3" class="mr-2"></i>
|
| 61 |
+
ScribbleSync
|
| 62 |
+
</h1>
|
| 63 |
+
<p class="text-gray-500 text-sm mt-1">Your digital notebook</p>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
<div class="p-4">
|
| 67 |
+
<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">
|
| 68 |
+
<i data-feather="plus-circle" class="mr-2"></i>
|
| 69 |
+
New Note
|
| 70 |
+
</button>
|
| 71 |
+
|
| 72 |
+
<div class="mt-6">
|
| 73 |
+
<h2 class="text-xs uppercase font-semibold text-gray-500 tracking-wider mb-2">Sections</h2>
|
| 74 |
+
<ul>
|
| 75 |
+
<li>
|
| 76 |
+
<button id="notesTab" class="w-full text-left py-2 px-4 rounded-lg flex items-center active-tab">
|
| 77 |
+
<i data-feather="file-text" class="mr-3"></i>
|
| 78 |
+
Notes
|
| 79 |
+
</button>
|
| 80 |
+
</li>
|
| 81 |
+
<li class="mt-1">
|
| 82 |
+
<button id="historyTab" class="w-full text-left py-2 px-4 rounded-lg flex items-center text-gray-600 hover:bg-gray-100">
|
| 83 |
+
<i data-feather="clock" class="mr-3"></i>
|
| 84 |
+
History
|
| 85 |
+
</button>
|
| 86 |
+
</li>
|
| 87 |
+
</ul>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
|
| 92 |
+
<!-- Main Content -->
|
| 93 |
+
<div class="flex-1 flex flex-col overflow-hidden">
|
| 94 |
+
<!-- Top Bar -->
|
| 95 |
+
<header class="bg-white shadow-sm z-10">
|
| 96 |
+
<div class="flex items-center justify-between p-4">
|
| 97 |
+
<div class="flex items-center">
|
| 98 |
+
<button id="menuToggle" class="md:hidden mr-4 text-gray-600">
|
| 99 |
+
<i data-feather="menu"></i>
|
| 100 |
+
</button>
|
| 101 |
+
<h2 id="currentSectionTitle" class="text-xl font-semibold text-gray-800">My Notes</h2>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="relative">
|
| 104 |
+
<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">
|
| 105 |
+
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
</header>
|
| 109 |
+
|
| 110 |
+
<!-- Content Area -->
|
| 111 |
+
<main class="flex-1 overflow-y-auto p-6 bg-gray-50">
|
| 112 |
+
<!-- Notes Section -->
|
| 113 |
+
<section id="notesSection" class="fade-in">
|
| 114 |
+
<div class="flex justify-between items-center mb-6">
|
| 115 |
+
<h2 class="text-2xl font-bold text-gray-800">Recent Notes</h2>
|
| 116 |
+
<div class="flex space-x-2">
|
| 117 |
+
<button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
|
| 118 |
+
<i data-feather="filter" class="mr-2"></i>
|
| 119 |
+
Filter
|
| 120 |
+
</button>
|
| 121 |
+
<button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
|
| 122 |
+
<i data-feather="sort-asc" class="mr-2"></i>
|
| 123 |
+
Sort
|
| 124 |
+
</button>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<div id="notesContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 129 |
+
<!-- Note cards will be dynamically inserted here -->
|
| 130 |
+
</div>
|
| 131 |
+
</section>
|
| 132 |
+
|
| 133 |
+
<!-- History Section (Hidden by default) -->
|
| 134 |
+
<section id="historySection" class="hidden fade-in">
|
| 135 |
+
<div class="flex justify-between items-center mb-6">
|
| 136 |
+
<h2 class="text-2xl font-bold text-gray-800">Note History</h2>
|
| 137 |
+
<button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
|
| 138 |
+
<i data-feather="trash-2" class="mr-2"></i>
|
| 139 |
+
Clear History
|
| 140 |
+
</button>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
<div id="historyContainer" class="space-y-4">
|
| 144 |
+
<!-- History items will be dynamically inserted here -->
|
| 145 |
+
</div>
|
| 146 |
+
</section>
|
| 147 |
+
</main>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
|
| 151 |
+
<!-- Note Editor Modal -->
|
| 152 |
+
<div id="noteModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
|
| 153 |
+
<div class="bg-white rounded-lg w-full max-w-2xl mx-4 max-h-[90vh] overflow-hidden flex flex-col">
|
| 154 |
+
<div class="border-b border-gray-200 p-4 flex justify-between items-center">
|
| 155 |
+
<h3 class="text-lg font-semibold">Edit Note</h3>
|
| 156 |
+
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
|
| 157 |
+
<i data-feather="x"></i>
|
| 158 |
+
</button>
|
| 159 |
+
</div>
|
| 160 |
+
<div class="p-4 flex-1 overflow-y-auto">
|
| 161 |
+
<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">
|
| 162 |
+
<textarea id="noteContent" placeholder="Start writing your note here..." class="w-full h-64 p-2 focus:outline-none"></textarea>
|
| 163 |
+
</div>
|
| 164 |
+
<div class="border-t border-gray-200 p-4 flex justify-end space-x-3">
|
| 165 |
+
<button id="deleteNote" class="px-4 py-2 text-red-600 hover:bg-red-50 rounded-lg">Delete</button>
|
| 166 |
+
<button id="saveNote" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-indigo-600">Save Note</button>
|
| 167 |
+
</div>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 172 |
+
<script>
|
| 173 |
+
// Initialize feather icons
|
| 174 |
+
feather.replace();
|
| 175 |
+
|
| 176 |
+
// Sample data
|
| 177 |
+
const sampleNotes = [
|
| 178 |
+
{ 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"] },
|
| 179 |
+
{ 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"] },
|
| 180 |
+
{ 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"] },
|
| 181 |
+
{ 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"] },
|
| 182 |
+
{ 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"] },
|
| 183 |
+
{ 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"] }
|
| 184 |
+
];
|
| 185 |
+
|
| 186 |
+
const sampleHistory = [
|
| 187 |
+
{ id: 1, title: "Deleted: Shopping List", content: "Milk, Eggs, Bread, Fruits", date: "2023-05-30", action: "deleted" },
|
| 188 |
+
{ id: 2, title: "Modified: Project Ideas", content: "Added new idea: AI chatbot", date: "2023-05-29", action: "modified" },
|
| 189 |
+
{ id: 3, title: "Created: Budget Plan", content: "Monthly budget breakdown", date: "2023-05-28", action: "created" },
|
| 190 |
+
{ id: 4, title: "Deleted: Old Notes", content: "Outdated information", date: "2023-05-27", action: "deleted" }
|
| 191 |
+
];
|
| 192 |
+
|
| 193 |
+
// DOM Elements
|
| 194 |
+
const notesTab = document.getElementById('notesTab');
|
| 195 |
+
const historyTab = document.getElementById('historyTab');
|
| 196 |
+
const notesSection = document.getElementById('notesSection');
|
| 197 |
+
const historySection = document.getElementById('historySection');
|
| 198 |
+
const currentSectionTitle = document.getElementById('currentSectionTitle');
|
| 199 |
+
const notesContainer = document.getElementById('notesContainer');
|
| 200 |
+
const historyContainer = document.getElementById('historyContainer');
|
| 201 |
+
const newNoteBtn = document.getElementById('newNoteBtn');
|
| 202 |
+
const noteModal = document.getElementById('noteModal');
|
| 203 |
+
const closeModal = document.getElementById('closeModal');
|
| 204 |
+
const saveNote = document.getElementById('saveNote');
|
| 205 |
+
const deleteNote = document.getElementById('deleteNote');
|
| 206 |
+
const menuToggle = document.getElementById('menuToggle');
|
| 207 |
+
const sidebar = document.getElementById('sidebar');
|
| 208 |
+
const noteTitle = document.getElementById('noteTitle');
|
| 209 |
+
const noteContent = document.getElementById('noteContent');
|
| 210 |
+
|
| 211 |
+
// Current state
|
| 212 |
+
let currentNoteId = null;
|
| 213 |
+
let isSidebarOpen = true;
|
| 214 |
+
|
| 215 |
+
// Initialize the app
|
| 216 |
+
function initApp() {
|
| 217 |
+
renderNotes();
|
| 218 |
+
renderHistory();
|
| 219 |
+
setupEventListeners();
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
// Render notes
|
| 223 |
+
function renderNotes() {
|
| 224 |
+
notesContainer.innerHTML = '';
|
| 225 |
+
sampleNotes.forEach(note => {
|
| 226 |
+
const noteCard = document.createElement('div');
|
| 227 |
+
noteCard.className = 'note-card bg-white rounded-lg p-5 cursor-pointer';
|
| 228 |
+
noteCard.innerHTML = `
|
| 229 |
+
<div class="flex justify-between items-start">
|
| 230 |
+
<h3 class="font-bold text-lg mb-2">${note.title}</h3>
|
| 231 |
+
<span class="text-xs text-gray-500">${formatDate(note.date)}</span>
|
| 232 |
+
</div>
|
| 233 |
+
<p class="text-gray-600 mb-4 whitespace-pre-line truncate">${note.content.substring(0, 100)}${note.content.length > 100 ? '...' : ''}</p>
|
| 234 |
+
<div class="flex flex-wrap gap-2">
|
| 235 |
+
${note.tags.map(tag => `<span class="bg-purple-100 text-purple-800 text-xs px-2 py-1 rounded">${tag}</span>`).join('')}
|
| 236 |
+
</div>
|
| 237 |
+
`;
|
| 238 |
+
noteCard.addEventListener('click', () => openNoteEditor(note.id));
|
| 239 |
+
notesContainer.appendChild(noteCard);
|
| 240 |
+
});
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// Render history
|
| 244 |
+
function renderHistory() {
|
| 245 |
+
historyContainer.innerHTML = '';
|
| 246 |
+
sampleHistory.forEach(item => {
|
| 247 |
+
const historyItem = document.createElement('div');
|
| 248 |
+
historyItem.className = 'bg-white rounded-lg p-4 border-l-4 border-primary';
|
| 249 |
+
historyItem.innerHTML = `
|
| 250 |
+
<div class="flex justify-between">
|
| 251 |
+
<h3 class="font-semibold">${item.title}</h3>
|
| 252 |
+
<span class="text-sm text-gray-500">${formatDate(item.date)}</span>
|
| 253 |
+
</div>
|
| 254 |
+
<p class="text-gray-600 my-2">${item.content}</p>
|
| 255 |
+
<div class="flex justify-between items-center">
|
| 256 |
+
<span class="text-xs px-2 py-1 rounded ${
|
| 257 |
+
item.action === 'created' ? 'bg-green-100 text-green-800' :
|
| 258 |
+
item.action === 'modified' ? 'bg-blue-100 text-blue-800' :
|
| 259 |
+
'bg-red-100 text-red-800'
|
| 260 |
+
}">
|
| 261 |
+
${item.action.charAt(0).toUpperCase() + item.action.slice(1)}
|
| 262 |
+
</span>
|
| 263 |
+
<button class="text-primary hover:text-indigo-700 text-sm flex items-center">
|
| 264 |
+
<i data-feather="eye" class="mr-1"></i> View
|
| 265 |
+
</button>
|
| 266 |
+
</div>
|
| 267 |
+
`;
|
| 268 |
+
historyContainer.appendChild(historyItem);
|
| 269 |
+
});
|
| 270 |
+
feather.replace();
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// Format date
|
| 274 |
+
function formatDate(dateString) {
|
| 275 |
+
const options = { year: 'numeric', month: 'short', day: 'numeric' };
|
| 276 |
+
return new Date(dateString).toLocaleDateString(undefined, options);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
// Open note editor
|
| 280 |
+
function openNoteEditor(noteId = null) {
|
| 281 |
+
currentNoteId = noteId;
|
| 282 |
+
if (noteId) {
|
| 283 |
+
const note = sampleNotes.find(n => n.id === noteId);
|
| 284 |
+
noteTitle.value = note.title;
|
| 285 |
+
noteContent.value = note.content;
|
| 286 |
+
deleteNote.classList.remove('hidden');
|
| 287 |
+
} else {
|
| 288 |
+
noteTitle.value = '';
|
| 289 |
+
noteContent.value = '';
|
| 290 |
+
deleteNote.classList.add('hidden');
|
| 291 |
+
}
|
| 292 |
+
noteModal.classList.remove('hidden');
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Save note
|
| 296 |
+
function saveCurrentNote() {
|
| 297 |
+
// In a real app, this would save to a database
|
| 298 |
+
console.log('Saving note:', noteTitle.value, noteContent.value);
|
| 299 |
+
noteModal.classList.add('hidden');
|
| 300 |
+
// Refresh notes display
|
| 301 |
+
renderNotes();
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
// Delete note
|
| 305 |
+
function deleteCurrentNote() {
|
| 306 |
+
if (confirm('Are you sure you want to delete this note?')) {
|
| 307 |
+
// In a real app, this would delete from a database
|
| 308 |
+
console.log('Deleting note with ID:', currentNoteId);
|
| 309 |
+
noteModal.classList.add('hidden');
|
| 310 |
+
// Refresh notes display
|
| 311 |
+
renderNotes();
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
// Toggle sidebar on mobile
|
| 316 |
+
function toggleSidebar() {
|
| 317 |
+
isSidebarOpen = !isSidebarOpen;
|
| 318 |
+
if (isSidebarOpen) {
|
| 319 |
+
sidebar.classList.remove('-ml-64');
|
| 320 |
+
} else {
|
| 321 |
+
sidebar.classList.add('-ml-64');
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
// Setup event listeners
|
| 326 |
+
function setupEventListeners() {
|
| 327 |
+
notesTab.addEventListener('click', () => {
|
| 328 |
+
notesTab.classList.add('active-tab');
|
| 329 |
+
historyTab.classList.remove('active-tab', 'text-gray-600');
|
| 330 |
+
historyTab.classList.add('text-gray-600');
|
| 331 |
+
notesSection.classList.remove('hidden');
|
| 332 |
+
historySection.classList.add('hidden');
|
| 333 |
+
currentSectionTitle.textContent = 'My Notes';
|
| 334 |
+
});
|
| 335 |
+
|
| 336 |
+
historyTab.addEventListener('click', () => {
|
| 337 |
+
historyTab.classList.add('active-tab');
|
| 338 |
+
notesTab.classList.remove('active-tab', 'text-gray-600');
|
| 339 |
+
notesTab.classList.add('text-gray-600');
|
| 340 |
+
historySection.classList.remove('hidden');
|
| 341 |
+
notesSection.classList.add('hidden');
|
| 342 |
+
currentSectionTitle.textContent = 'Note History';
|
| 343 |
+
});
|
| 344 |
+
|
| 345 |
+
newNoteBtn.addEventListener('click', () => openNoteEditor());
|
| 346 |
+
closeModal.addEventListener('click', () => noteModal.classList.add('hidden'));
|
| 347 |
+
saveNote.addEventListener('click', saveCurrentNote);
|
| 348 |
+
deleteNote.addEventListener('click', deleteCurrentNote);
|
| 349 |
+
menuToggle.addEventListener('click', toggleSidebar);
|
| 350 |
+
|
| 351 |
+
// Close modal when clicking outside
|
| 352 |
+
window.addEventListener('click', (e) => {
|
| 353 |
+
if (e.target === noteModal) {
|
| 354 |
+
noteModal.classList.add('hidden');
|
| 355 |
+
}
|
| 356 |
+
});
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
// Initialize the app when DOM is loaded
|
| 360 |
+
document.addEventListener('DOMContentLoaded', initApp);
|
| 361 |
+
</script>
|
| 362 |
+
</body>
|
| 363 |
</html>
|