Skip to content
TheChatArchiveThe Chat Archive
grok-3-preview-02-24· xAIHugging Face LMArena Human Preference 140K

Create a note-taking app using Material ui design that includes the ability to add…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219-thinking-32k’s answer.
  1. User

    Create a note-taking app using Material ui design that includes the ability to add notes, draw sketches with a pen, manage tasks, and record audio. It should also have the necessary toolbar and a search feature. Use HTML, CSS, and JavaScript in a single file

  2. Assistant

    Below is a single-file implementation of a note-taking app using Material UI design principles. This app includes features for adding notes, drawing sketches, managing tasks, and recording audio, along with a toolbar and search functionality. The app uses HTML, CSS, and JavaScript, with the Materialize CSS framework for Material UI design.

    Key Features:

    1. Add Notes: Text-based notes with title and content.
    2. Draw Sketches: Canvas-based drawing with a pen tool.
    3. Manage Tasks: Task list with checkboxes for completion.
    4. Record Audio: Audio recording using the MediaRecorder API.
    5. Toolbar: Buttons for switching between modes and saving content.
    6. Search: Search notes and tasks by keyword.

    Limitations:

    • This is a basic implementation. For a production app, you would need to add persistent storage (e.g., localStorage or a backend database), better error handling, and more advanced features.
    • The audio recording feature requires browser support for the MediaRecorder API (works best in modern browsers like Chrome).

    Code:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Material UI Note-Taking App</title>
        <!-- Materialize CSS -->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
        <!-- Material Icons -->
        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
        <style>
            body {
                font-family: 'Roboto', sans-serif;
                background-color: #f5f5f5;
            }
            .container {
                margin-top: 20px;
            }
            .toolbar {
                background-color: #3f51b5;
                padding: 10px;
                color: white;
                display: flex;
                justify-content: space-between;
                align-items: center;
            }
            .toolbar button, .toolbar input {
                margin: 0 5px;
            }
            .content {
                margin-top: 20px;
            }
            .note, .task {
                background-color: white;
                padding: 15px;
                margin-bottom: 10px;
                border-radius: 5px;
                box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            }
            canvas {
                border: 1px solid #ddd;
                border-radius: 5px;
                background-color: white;
            }
            .hidden {
                display: none;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <!-- Toolbar -->
            <div class="toolbar">
                <div>
                    <button class="btn waves-effect waves-light" onclick="showSection('notes')">
                        <i class="material-icons left">note</i>Notes
                    </button>
                    <button class="btn waves-effect waves-light" onclick="showSection('sketch')">
                        <i class="material-icons left">brush</i>Sketch
                    </button>
                    <button class="btn waves-effect waves-light" onclick="showSection('tasks')">
                        <i class="material-icons left">check_box</i>Tasks
                    </button>
                    <button class="btn waves-effect waves-light" onclick="showSection('audio')">
                        <i class="material-icons left">mic</i>Audio
                    </button>
                </div>
                <div>
                    <input type="text" id="search" placeholder="Search..." onkeyup="searchContent()">
                </div>
            </div>
    
            <!-- Notes Section -->
            <div id="notesSection" class="content">
                <h4>Notes</h4>
                <div class="input-field">
                    <input id="noteTitle" type="text" placeholder="Note Title">
                </div>
                <div class="input-field">
                    <textarea id="noteContent" class="materialize-textarea" placeholder="Note Content"></textarea>
                </div>
                <button class="btn waves-effect waves-light" onclick="addNote()">
                    <i class="material-icons left">save</i>Save Note
                </button>
                <div id="notesList"></div>
            </div>
    
            <!-- Sketch Section -->
            <div id="sketchSection" class="content hidden">
                <h4>Sketch</h4>
                <canvas id="sketchCanvas" width="600" height="400"></canvas>
                <br>
                <button class="btn waves-effect waves-light" onclick="clearCanvas()">
                    <i class="material-icons left">clear</i>Clear
                </button>
                <button class="btn waves-effect waves-light" onclick="saveSketch()">
                    <i class="material-icons left">save</i>Save Sketch
                </button>
                <div id="sketchList"></div>
            </div>
    
            <!-- Tasks Section -->
            <div id="tasksSection" class="content hidden">
                <h4>Tasks</h4>
                <div class="input-field">
                    <input id="taskContent" type="text" placeholder="Task Description">
                </div>
                <button class="btn waves-effect waves-light" onclick="addTask()">
                    <i class="material-icons left">add</i>Add Task
                </button>
                <div id="tasksList"></div>
            </div>
    
            <!-- Audio Section -->
            <div id="audioSection" class="content hidden">
                <h4>Audio</h4>
                <button id="recordButton" class="btn waves-effect waves-light" onclick="startRecording()">
                    <i class="material-icons left">mic</i>Start Recording
                </button>
                <button id="stopButton" class="btn waves-effect waves-light disabled" onclick="stopRecording()">
                    <i class="material-icons left">stop</i>Stop Recording
                </button>
                <div id="audioList"></div>
            </div>
        </div>
    
        <!-- Materialize JS -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
        <script>
            let notes = [];
            let tasks = [];
            let sketches = [];
            let audioRecordings = [];
            let mediaRecorder;
            let audioChunks = [];
    
            // Show specific section
            function showSection(section) {
                document.querySelectorAll('.content').forEach(el => el.classList.add('hidden'));
                document.getElementById(`${section}Section`).classList.remove('hidden');
            }
    
            // Notes
            function addNote() {
                const title = document.getElementById('noteTitle').value;
                const content = document.getElementById('noteContent').value;
                if (title && content) {
                    notes.push({ title, content });
                    document.getElementById('noteTitle').value = '';
                    document.getElementById('noteContent').value = '';
                    displayNotes();
                }
            }
    
            function displayNotes() {
                const notesList = document.getElementById('notesList');
                notesList.innerHTML = notes.map((note, index) => `
                    <div class="note">
                        <h5>${note.title}</h5>
                        <p>${note.content}</p>
                        <button class="btn red" onclick="deleteNote(${index})">Delete</button>
                    </div>
                `).join('');
            }
    
            function deleteNote(index) {
                notes.splice(index, 1);
                displayNotes();
            }
    
            // Sketch
            const canvas = document.getElementById('sketchCanvas');
            const ctx = canvas.getContext('2d');
            let isDrawing = false;
    
            canvas.addEventListener('mousedown', startDrawing);
            canvas.addEventListener('mousemove', draw);
            canvas.addEventListener('mouseup', stopDrawing);
            canvas.addEventListener('mouseout', stopDrawing);
    
            function startDrawing(e) {
                isDrawing = true;
                draw(e);
            }
    
            function draw(e) {
                if (!isDrawing) return;
                ctx.lineWidth = 2;
                ctx.lineCap = 'round';
                ctx.strokeStyle = 'black';
                ctx.lineTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop);
                ctx.stroke();
                ctx.beginPath();
                ctx.moveTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop);
            }
    
            function stopDrawing() {
                isDrawing = false;
                ctx.beginPath();
            }
    
            function clearCanvas() {
                ctx.clearRect(0, 0, canvas.width, canvas.height);
            }
    
            function saveSketch() {
                const dataURL = canvas.toDataURL();
                sketches.push(dataURL);
                clearCanvas();
                displaySketches();
            }
    
            function displaySketches() {
                const sketchList = document.getElementById('sketchList');
                sketchList.innerHTML = sketches.map((sketch, index) => `
                    <div>
                        <img src="${sketch}" width="200" alt="Sketch">
                        <button class="btn red" onclick="deleteSketch(${index})">Delete</button>
                    </div>
                `).join('');
            }
    
            function deleteSketch(index) {
                sketches.splice(index, 1);
                displaySketches();
            }
    
            // Tasks
            function addTask() {
                const content = document.getElementById('taskContent').value;
                if (content) {
                    tasks.push({ content, completed: false });
                    document.getElementById('taskContent').value = '';
                    displayTasks();
                }
            }
    
            function displayTasks() {
                const tasksList = document.getElementById('tasksList');
                tasksList.innerHTML = tasks.map((task, index) => `
                    <div class="task">
                        <input type="checkbox" id="task${index}" ${task.completed ? 'checked' : ''} onchange="toggleTask(${index})">
                        <label for="task${index}">${task.content}</label>
                        <button class="btn red" onclick="deleteTask(${index})">Delete</button>
                    </div>
                `).join('');
            }
    
            function toggleTask(index) {
                tasks[index].completed = !tasks[index].completed;
                displayTasks();
            }
    
            function deleteTask(index) {
                tasks.splice(index, 1);
                displayTasks();
            }
    
            // Audio Recording
            navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
                mediaRecorder = new MediaRecorder(stream);
                mediaRecorder.ondataavailable = e => audioChunks.push(e.data);
                mediaRecorder.onstop = () => {
                    const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
                    const audioURL = URL.createObjectURL(audioBlob);
                    audioRecordings.push(audioURL);
                    audioChunks = [];
                    displayAudio();
                };
            });
    
            function startRecording() {
                audioChunks = [];
                mediaRecorder.start();
                document.getElementById('recordButton').classList.add('disabled');
                document.getElementById('stopButton').classList.remove('disabled');
            }
    
            function stopRecording() {
                mediaRecorder.stop();
                document.getElementById('recordButton').classList.remove('disabled');
                document.getElementById('stopButton').classList.add('disabled');
            }
    
            function displayAudio() {
                const audioList = document.getElementById('audioList');
                audioList.innerHTML = audioRecordings.map((audio, index) => `
                    <div>
                        <audio controls src="${audio}"></audio>
                        <button class="btn red" onclick="deleteAudio(${index})">Delete</button>
                    </div>
                `).join('');
            }
    
            function deleteAudio(index) {
                audioRecordings.splice(index, 1);
                displayAudio();
            }
    
            // Search
            function searchContent() {
                const query = document.getElementById('search').value.toLowerCase();
                const filteredNotes = notes.filter(note => 
                    note.title.toLowerCase().includes(query) || note.content.toLowerCase().includes(query)
                );
                const filteredTasks = tasks.filter(task => task.content.toLowerCase().includes(query));
    
                const notesList = document.getElementById('notesList');
                notesList.innerHTML = filteredNotes.map((note, index) => `
                    <div class="note">
                        <h5>${note.title}</h5>
                        <p>${note.content}</p>
                        <button class="btn red" onclick="deleteNote(${index})">Delete</button>
                    </div>
                `).join('');
    
                const tasksList = document.getElementById('tasksList');
                tasksList.innerHTML = filteredTasks.map((task, index) => `
                    <div class="task">
                        <input type="checkbox" id="task${index}" ${task.completed ? 'checked' : ''} onchange="toggleTask(${index})">
                        <label for="task${index}">${task.content}</label>
                        <button class="btn red" onclick="deleteTask(${index})">Delete</button>
                    </div>
                `).join('');
            }
    
            // Initialize
            showSection('notes');
        </script>
    </body>
    </html>
    

    How to Use:

    1. Save the Code: Save the code as index.html.
    2. Open in Browser: Open the file in a modern browser (e.g., Chrome, Firefox). Note that some features (like audio recording) may require running the app on a local server due to browser security restrictions. You can use tools like Live Server in VS Code or Python's http.server to serve the file locally.
    3. Features:
      • Notes: Enter a title and content, then click "Save Note" to add a note. Notes are displayed below and can be deleted.
      • Sketch: Use the canvas to draw with your mouse. Click "Clear" to reset the canvas and "Save Sketch" to save the drawing. Saved sketches are displayed below and can be deleted.
      • Tasks: Enter a task description and click "Add Task" to add a task. Tasks can be marked as completed using checkboxes and deleted.
      • Audio: Click "Start Recording" to record audio, then "Stop Recording" to save it. Saved recordings are displayed below and can be deleted.
      • Search: Use the search bar in the toolbar to filter notes and tasks by keyword.

    Notes:

    • Material UI Design: The app uses Materialize CSS for a Material UI look and feel, including buttons, icons, and input fields.
    • Persistence: This implementation does not persist data across page refreshes. To add persistence, you can use localStorage or integrate a backend database.
    • Audio Recording: The audio recording feature requires browser permission to access the microphone. Ensure you are running the app on a secure context (e.g., https or localhost).
    • Sketching: The sketching feature is basic and works best on desktop browsers. For a production app, consider adding features like color selection, brush size, and touch support for mobile devices.

    Enhancements for Production:

    • Add data persistence using localStorage or a backend API.
    • Improve the sketching feature with more tools (e.g., eraser, colors, undo/redo).
    • Enhance the search feature to include sketches and audio (e.g., by adding tags or metadata).
    • Add offline support using Service Workers.
    • Optimize for mobile devices with touch events and responsive design.

    Let me know if you'd like help with any of these enhancements or have questions about the code!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.