Notes.txt

 avatar
unknown
plain_text
22 days ago
5.7 kB
8
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Quick Notes App</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #f5f6fa;
            padding: 20px;
            display: flex;
            justify-content: center;
        }

        .app-container {
            width: 100%;
            max-width: 800px;
            background: white;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.05);
        }

        header {
            margin-bottom: 25px;
            text-align: center;
        }

        h1 {
            color: #2f3640;
            font-size: 2rem;
            margin-bottom: 15px;
        }

        .input-area {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin-bottom: 30px;
        }

        input, textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid #dcdde1;
            border-radius: 6px;
            font-size: 1rem;
            outline: none;
            transition: border 0.2s;
        }

        input:focus, textarea:focus {
            border-color: #4cd137;
        }

        textarea {
            height: 100px;
            resize: vertical;
        }

        button {
            background-color: #4cd137;
            color: white;
            border: none;
            padding: 12px;
            font-size: 1rem;
            font-weight: bold;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.2s;
        }

        button:hover {
            background-color: #44bd32;
        }

        .notes-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
            gap: 20px;
        }

        .note-card {
            background: #fff8cd;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            min-height: 150px;
            border: 1px solid #f5f0b5;
        }

        .note-title {
            font-weight: bold;
            color: #2f3640;
            margin-bottom: 8px;
            font-size: 1.1rem;
        }

        .note-text {
            color: #333333;
            font-size: 0.95rem;
            white-space: pre-wrap;
            flex-grow: 1;
        }

        .delete-btn {
            background: none;
            color: #e84118;
            border: none;
            padding: 5px;
            margin-top: 15px;
            font-size: 0.85rem;
            font-weight: normal;
            cursor: pointer;
            text-align: right;
            align-self: flex-end;
        }

        .delete-btn:hover {
            background: none;
            color: #c23616;
            text-decoration: underline;
        }
    </style>
</head>
<body>

    <div class="app-container">
        <header>
            <h1>My Notes</h1>
        </header>

        <div class="input-area">
            <input type="text" id="noteTitle" placeholder="Title (optional)">
            <textarea id="noteText" placeholder="Take a note..."></textarea>
            <button id="addBtn">Add Note</button>
        </div>

        <div class="notes-grid" id="notesGrid"></div>
    </div>

    <script>
        const noteTitleInput = document.getElementById('noteTitle');
        const noteTextInput = document.getElementById('noteText');
        const addBtn = document.getElementById('addBtn');
        const notesGrid = document.getElementById('notesGrid');

        // Load notes from localStorage on startup
        let notes = JSON.parse(localStorage.getItem('savedNotes')) || [];

        // Render notes to screen
        function renderNotes() {
            notesGrid.innerHTML = '';
            notes.forEach((note, index) => {
                const noteCard = document.createElement('div');
                noteCard.classList.add('note-card');
                
                noteCard.innerHTML = `
                    <div>
                        ${note.title ? `<div class="note-title">${note.title}</div>` : ''}
                        <div class="note-text">${note.text}</div>
                    </div>
                    <button class="delete-btn" onclick="deleteNote(${index})">Delete</button>
                `;
                
                notesGrid.appendChild(noteCard);
            });
        }

        // Add a new note
        function addNote() {
            const title = noteTitleInput.value.trim();
            const text = noteTextInput.value.trim();

            if (!text) {
                alert('Please type some text for your note!');
                return;
            }

            notes.push({ title, text });
            localStorage.setItem('savedNotes', JSON.stringify(notes));
            
            // Clear inputs
            noteTitleInput.value = '';
            noteTextInput.value = '';
            
            renderNotes();
        }

        // Delete a note
        function deleteNote(index) {
            notes.splice(index, 1);
            localStorage.setItem('savedNotes', JSON.stringify(notes));
            renderNotes();
        }

        // Event listener
        addBtn.addEventListener('click', addNote);

        // Initial render
        renderNotes();
    </script>
</body>
</html>
Editor is loading...
Leave a Comment