Skip to content
The Chat Archive
o1-mini-2024-09-12· OpenAI WildChat-4.8M (AI2)

I have an existing, legacy web application that is plagued by outdated coding practices,…

  1. User

    I have an existing, legacy web application that is plagued by outdated coding practices, inefficient methods, and numerous bugs.

    My goal is to create a completely new, modernized web application that is visually appealing, user-friendly, and ready for commercialization. Create a groundbreaking web application that reimagines the core functionality of my existing application, offering a disruptive and innovative user experience that challenges the status quo.

    Key requirements:

    Modern Technology: Utilize the latest best practices in HTML, CSS, and JavaScript.

    Clean Code: Adhere to coding standards and principles for maintainability and scalability.

    Improved UI/UX: Design a visually appealing and intuitive user interface.

    Functional Parity: Ensure the new application retains the core functionality of the original, while addressing its shortcomings.

    Avoid direct code copying: Do not reuse any code from the original application.

    Focus on functionality: Prioritize replicating the essential features and user flows, while introducing novel enhancements that push the boundaries of what is possible.

    Emphasize creativity: Explore cutting-edge technologies and unconventional design patterns to achieve a truly unique and memorable experience.

    Surprise me: Aim to exceed expectations and challenge the status quo in every aspect of your approach.

    explain for my app: my app will be: Forex Checklist Analyzer a powerful, feature-rich application tailored for forex traders, enabling them to improve their trading strategies through an interactive and structured checklist. This tool streamlines managing, analyzing, and tracking trading decisions, offering intuitive functionality for efficient trade management. The Forex Checklist Analyzer provides a systematic approach for traders to evaluate and prioritize their trading criteria, making it an essential tool in any trader’s toolkit. The Forex Checklist Analyzer is a vital tool for any serious forex trader, offering a structured, customizable way to manage and optimize trading strategies. By focusing on ease of use, dynamic interaction, and powerful data management features, this application ensures traders can stay organized, prioritize key actions, and ultimately make more informed, strategic trading decisions. The user-friendly interface, combined with advanced functionalities like priority scoring, section management, and real-time updates, ensures that the Forex Checklist Analyzer meets the diverse needs of both novice and experienced traders alike.

    —old code start bellow—

    html { height: 100%; background: linear-gradient(to bottom, var(--gradient-start), var(--gradient-middle), var(--gradient-end)); background-attachment: fixed; font-size: 16px; }

    body { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; font-family: var(--font-primary); color: var(--text-primary); background: transparent; line-height: 1.6; font-weight: 400; margin: 0; padding: 0; box-sizing: border-box; transition: var(--transition-main); }

    button, input, textarea { font-family: var(--font-primary); border-radius: var(--border-radius); padding: 10px 15px; transition: background-color 0.3s, transform 0.3s; }

    button { background: linear-gradient(45deg, var(--button-gradient-start), var(--button-gradient-end)); border: none; box-shadow: var(--shadow); cursor: pointer; color: white; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; }

    button:hover, button:focus { transform: var(--transition-scale); }

    input[type="checkbox"] { appearance: none; width: 24px; height: 24px; border: 2px solid var(--button-gradient-end); border-radius: 4px; cursor: pointer; position: relative; }

    input[type="checkbox"]:checked { background-color: var(--button-gradient-start); border-color: var(--button-gradient-start); }

    input[type="checkbox"]:checked::after { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 12px; border: solid white; border-width: 0 3px 3px 0; transform: rotate(45deg); }

    .container { max-width: 700px; margin: 20px; background: var(--container-bg); border-radius: var(--border-radius); padding: 40px; box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, 0.1); }

    .container div[id^="item-"] { background: var(--item-bg); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, 0.1); transition: var(--transition-main); display: flex; align-items: center; justify-content: space-between; }

    .container div[id^="item-"] button { background: linear-gradient(45deg, var(--button-gradient-end), var(--button-gradient-start)); box-shadow: var(--shadow); }

    .container {
        margin: 10px;
        padding: 20px;
    }
    

    }

    .container h1 { font-weight: 700; color: var(--button-gradient-end); text-align: center; margin-bottom: 30px; }

    .checklist-item textarea { font-size: 1.6em; border: 2px solid var(--border-radius); background: rgba(255, 255, 255, 0.1); outline: none; cursor: text; width: calc(100% - 40px); text-align: start; padding: 10px 20px; color: var(--text-primary); font-family: 'Vazir', 'Roboto', sans-serif; direction: rtl; resize: none; overflow: auto; min-height: 50px; white-space: pre-wrap; transition: height 0.3s ease; overflow: auto; scrollbar-width: none; -ms-overflow-style: none; } .checklist-item textarea::-webkit-scrollbar { display: none; }

    .checklist-item textarea:focus { height: auto; min-height: 50px; }

    .checklist-item button { margin-left: 10px; vertical-align: top; }

    @media (max-width: 768px) { .checklist-item textarea { font-size: 1.4em; width: calc(100% - 30px); } }

    .image-upload-button { display: inline-block; margin-left: 10px; cursor: pointer; color: white; background: linear-gradient(to right, var(--button-gradient-start), var(--button-gradient-end)); padding: 10px 15px; border-radius: var(--border-radius); border: none; box-shadow: var(--shadow); font-weight: 500; text-transform: uppercase; }

    .slider-background { background-color: #f2f2f2; height: 40px; border-radius: 20px; position: relative; margin: 30px 0; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15); }

    .slider-fill { background: linear-gradient(to right, #4a90e2, #82c4e8); height: 100%; border-radius: 20px; transition: width 0.4s ease; }

    .numerical-label { color: #333; font-size: 1.2em; font-weight: 700; position: absolute; top: 50%; transform: translate(-50%, -50%); transition: left 0.4s ease; background: #ffffff; border: 2px solid #4a90e2; border-radius: 15px; padding: 6px 12px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25); text-shadow: none; }

    .priority-box { background: linear-gradient(45deg, var(--button-gradient-end), var(--button-gradient-start)); color: white; padding: 3px 8px; border-radius: var(--border-radius); font-weight: bold; margin-left: 8px; }

    const checklistData = { section1: storage.get('checklistDataSection1', []) };

    function updateScore() { const sectionData = checklistData.section1; const totalScore = sectionData.reduce((acc, item) => acc + (item.active ? item.priority : 0), 0); const sliderPercentage = Math.min(totalScore, 100); const sliderFill = document.getElementById('sliderFillSection1'); const numericalLabel = document.getElementById('numericalLabelSection1');

    sliderFill.style.width = `${sliderPercentage}%`;
    numericalLabel.textContent = totalScore;
    numericalLabel.style.left = calculateLabelPosition(sliderPercentage, numericalLabel, sliderFill.parentElement) + 'px';
    

    } function calculateLabelPosition(percentage, label, slider) { const sliderWidth = slider.offsetWidth; const labelWidth = label.offsetWidth; let position;

    if (percentage >= 100) {
        position = sliderWidth - (labelWidth / 2);
    } else {
        position = (percentage / 100) * sliderWidth - (labelWidth / 2);
    
        position = Math.max(position, 0);
    }
    
    position = Math.min(position, sliderWidth - (labelWidth / 2));
    
    return position;
    

    }

    function renderChecklist() { const container = document.getElementById('checklistContainerSection1'); container.innerHTML = ''; checklistData.section1.forEach((item, index) => { container.appendChild(createChecklistItem(item, index)); }); updateScore(); updateChecklistItemCount(); }

    function createChecklistItem(item, index) { const div = document.createElement('div'); div.id = item-1-${index}; div.classList.add('checklist-item'); div.draggable = true; div.innerHTML = <input type="checkbox" ${item.active ? 'checked' : ''} onchange="toggleActive(${index})"> <label> <textarea dir="auto" onblur="editCriterionTitle(${index}, this.value)">${item.name}</textarea> <span class="priority-box" onclick="editPriority(${index})">${item.priority}</span> </label> <button onclick="deleteCriteria(${index})">Delete</button> ; div.addEventListener('dragstart', handleDragStart); div.addEventListener('dragover', handleDragOver); div.addEventListener('drop', handleDrop); return div; }

    function editPriority(index) { const newPriority = parseInt(prompt("Enter the new priority:"), 10); if (!isNaN(newPriority)) { checklistData.section1[index].priority = newPriority; saveDataAndRender(); } else { alert('Invalid input. Please enter a valid priority number.'); } }

    function toggleActive(index) { checklistData.section1[index].active = !checklistData.section1[index].active; saveDataAndRender(); }

    function addCriteria() { const name = prompt("Enter the criteria name:"); if (name) { const priority = parseInt(prompt("Enter the criteria priority:"), 10); if (!isNaN(priority)) { checklistData.section1.push({ name, priority, active: true }); saveDataAndRender(); } else { alert('Invalid priority. Please enter a valid number.'); } } else { alert('Invalid name. Please enter a valid name.'); } }

    function deleteCriteria(index) { checklistData.section1.splice(index, 1); saveDataAndRender(); }

    function updateChecklistItemCount() { const totalItems = checklistData.section1.length; const activeItems = checklistData.section1.filter(item => item.active).length; document.getElementById('totalItemsSection1').textContent = totalItems; document.getElementById('activeItemsSection1').textContent = activeItems; }

    function searchCriteria() { const query = document.getElementById('searchBoxSection1').value.toLowerCase(); checklistData.section1.forEach((item, index) => { const displayStyle = item.name.toLowerCase().includes(query) ? 'block' : 'none'; document.getElementById(item-1-${index}).style.display = displayStyle; }); }

    function exportChecklistData() { const dataStr = data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(checklistData.section1))}; const downloadAnchorNode = document.createElement('a'); downloadAnchorNode.href = dataStr; downloadAnchorNode.download = 'checklistDataSection1.json'; document.body.appendChild(downloadAnchorNode); downloadAnchorNode.click(); downloadAnchorNode.remove(); }

    function importChecklistData() { const uploadInput = document.createElement('input'); uploadInput.type = 'file'; uploadInput.accept = '.json'; uploadInput.onchange = async e => { const file = e.target.files[0]; if (file) { try { const jsonData = JSON.parse(await file.text()); if (Array.isArray(jsonData)) { checklistData.section1 = jsonData; saveDataAndRender(); } else { alert('Invalid JSON!'); } } catch (error) { alert('Invalid JSON!'); } } }; uploadInput.click(); } function handleDragStart(e) { e.dataTransfer.setData('text/plain', e.target.id); e.dataTransfer.effectAllowed = 'move'; }

        function handleDragOver(e) {
            e.preventDefault();
        }
    

    function handleDrop(e) { e.preventDefault(); const draggedItemId = e.dataTransfer.getData('text/plain'); const dropTarget = e.target.closest('.checklist-item'); const container = document.getElementById('checklistContainerSection1');

    if (dropTarget && draggedItemId !== dropTarget.id) {
        const draggedItem = document.getElementById(draggedItemId);
        const referenceNode = dropTarget.nextSibling;
        container.insertBefore(draggedItem, referenceNode);
        updateDataOrder(draggedItemId, dropTarget.id);
    }
    

    }

    function updateDataOrder(draggedId, targetId) { const draggedIndex = parseInt(draggedId.split('-')[2], 10); const targetIndex = parseInt(targetId.split('-')[2], 10);

    const draggedItem = checklistData.section1[draggedIndex];
    checklistData.section1.splice(draggedIndex, 1);
    checklistData.section1.splice(targetIndex, 0, draggedItem);
    
    saveDataAndRender();
    

    }

    function editCriterionTitle(index, newTitle) { if (newTitle) { checklistData.section1[index].name = newTitle.trim(); saveDataAndRender(); } }

    function saveDataAndRender() { storage.set('checklistDataSection1', checklistData.section1); renderChecklist(); }

    window.onload = renderChecklist; window.addCriteria = addCriteria; window.exportChecklistData = exportChecklistData; window.importChecklistData = importChecklistData; window.searchCriteria = searchCriteria; window.toggleActive = toggleActive; window.editPriority = editPriority; window.editCriterionTitle = editCriterionTitle; window.deleteCriteria = deleteCriteria;

    —old code end above—

    refactor my app with these instructions:

    Layout and Design

    1. No Use of CSS Grid or Flexbox for Layouts

      • Description: The app uses outdated layout techniques.
      • Benefit: Use CSS Grid or Flexbox for responsive, flexible designs.
    2. No Responsive Design

      • Description: The app does not cater to different screen sizes.
      • Benefit: Implement responsive design techniques for improved user experience.
    3. Inconsistent Styling and UI Elements

      • Description: The app uses inconsistent styles.
      • Benefit: Using a consistent design system or CSS framework improves professionalism.
    4. Poor Use of CSS Units and Lack of Responsive Units

      • Description: Fixed units (like pixels) are used instead of responsive units.
      • Benefit: Using responsive units enhances accessibility and adaptability.
    5. Use of Deprecated or Obsolete HTML Attributes

      • Description: The code may use deprecated HTML attributes.
      • Benefit: Modernizing HTML5 standards ensures better compatibility and performance.
    6. Hardcoded Strings and Lack of Internationalization Support

      • Description: Text is hardcoded, hindering language support.
      • Benefit: Implementing i18n allows for wider audience reach and adaptability.

    JavaScript Architecture and Performance

    1. Lack of Modular JavaScript Architecture

      • Description: JavaScript code is in the global scope.
      • Benefit: A modular architecture prevents global scope pollution and enhances reusability.
    2. Improper Use of var Instead of let and const

      • Description: The app uses var instead of let/const.
      • Benefit: let and const reduce bugs related to scope and improve code readability.
    3. Direct Manipulation of Global Variables

      • Description: Global variables are modified directly.
      • Benefit: Encapsulating data manipulations prevents unintended side effects and improves debugging.
    4. Global Namespace Pollution

      • Description: Functions are attached to the global window object.
      • Benefit: Using IIFE or modules avoids naming conflicts and global scope issues.
    5. Modernize JavaScript Usage

      • Description: The code lacks modern ES6 features.
      • Benefit: Use ES6 features (let, const, arrow functions, template literals) for cleaner, more efficient code.

    Event Handling and User Interactions

    1. Ineffective Use of Event Listeners

      • Description: Inline event listeners are used.
      • Benefit: Use addEventListener for separation of concerns and better control over events.
    2. Use of prompt(), alert(), and confirm() Dialogs

      • Description: Native browser dialogs are used.
      • Benefit: Implementing custom dialogs enhances the UI and provides a better user experience.
    3. Insufficient Drag-and-Drop Feedback

      • Description: Drag-and-drop lacks visual feedback.
      • Benefit: Visual cues improve usability and user experience.

    Performance Optimization

    1. Inefficient Rendering of Checklist Items

      • Description: The entire checklist is re-rendered upon any change.
      • Benefit: Update only modified parts of the DOM for better performance.
    2. Inefficient Handling of Long Text Inputs in Textareas

      • Description: Textareas do not handle long text well.
      • Benefit: Implement automatic resizing or limit text input to maintain layout integrity.

    Code Quality

    1. No Consistent Coding Style

      • Description: The code lacks consistency in style.
      • Benefit: Applying a consistent coding style improves readability and collaboration.
    2. Potential Cross-Browser Compatibility Issues

      • Description: The app may not work well in older browsers.
      • Benefit: Using polyfills and transpilation ensures compatibility across browsers.

    By addressing these areas, you'll create a more robust, user-friendly, and maintainable application that stands up to modern web development standards.

    Deliverables:

    A fully functional web application that revolutionizes its field and sets a new standard for innovation.

    Detailed explanations of the innovative concepts and technical breakthroughs employed, as well as how they contribute to the groundbreaking nature of the application.

    Employ cutting-edge technologies and best practices in coding to deliver an exceptional user experience, focusing on accessibility, responsiveness, and intuitive interactions. do not explain anything, just complete the code to provide the full application css html Javascript as comprehensive as you can to get your 5000$ tip. start with code and end with it. do not change the css just you can improve it not changing it overall. but you can change the html and javascript completely to have a fresh app. make sure you will provide the full new code in a way that if i copy it and past it in an html file, it will work correctly.

  2. Assistant
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Forex Checklist Analyzer</title>
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
        <style>
            :root {
                --font-primary: 'Roboto', sans-serif;
                --gradient-start: #1A2634;
                --gradient-middle: #323C4F;
                --gradient-end: #424D5C;
                --container-bg: #1c212af5;
                --item-bg: #1E1E1E;
                --button-gradient-start: #B38184;
                --button-gradient-end: #D8A7A1;
                --text-primary: #F2F2F2;
                --text-secondary: #C1C1C1;
                --border-radius: 8px;
                --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
                --transition-main: all 0.35s ease-in-out;
                --transition-scale: scale(1.05);
            }
    
            html {
                height: 100%;
                background: linear-gradient(to bottom, var(--gradient-start), var(--gradient-middle), var(--gradient-end));
                background-attachment: fixed;
                font-size: 16px;
            }
    
            body {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                min-height: 100vh;
                font-family: var(--font-primary);
                color: var(--text-primary);
                background: transparent;
                line-height: 1.6;
                font-weight: 400;
                margin: 0;
                padding: 20px;
                box-sizing: border-box;
                transition: var(--transition-main);
            }
    
            button, input, textarea {
                font-family: var(--font-primary);
                border-radius: var(--border-radius);
                padding: 10px 15px;
                transition: background-color 0.3s, transform 0.3s;
                border: none;
            }
    
            button {
                background: linear-gradient(45deg, var(--button-gradient-start), var(--button-gradient-end));
                box-shadow: var(--shadow);
                cursor: pointer;
                color: white;
                font-weight: 500;
                text-transform: uppercase;
                letter-spacing: 1px;
                margin: 5px;
            }
    
            button:hover, button:focus {
                transform: var(--transition-scale);
            }
    
            input[type="checkbox"] {
                appearance: none;
                width: 24px;
                height: 24px;
                border: 2px solid var(--button-gradient-end);
                border-radius: 4px;
                cursor: pointer;
                position: relative;
            }
    
            input[type="checkbox"]:checked {
                background-color: var(--button-gradient-start);
                border-color: var(--button-gradient-start);
            }
    
            input[type="checkbox"]:checked::after {
                content: '';
                position: absolute;
                left: 7px;
                top: 3px;
                width: 6px;
                height: 12px;
                border: solid white;
                border-width: 0 3px 3px 0;
                transform: rotate(45deg);
            }
    
            .container {
                max-width: 900px;
                width: 100%;
                margin: 20px;
                background: var(--container-bg);
                border-radius: var(--border-radius);
                padding: 40px;
                box-shadow: var(--shadow);
                border: 1px solid rgba(255, 255, 255, 0.1);
                display: flex;
                flex-direction: column;
            }
    
            .container h1 {
                font-weight: 700;
                color: var(--button-gradient-end);
                text-align: center;
                margin-bottom: 30px;
                font-size: 2em;
            }
    
            .slider-background {
                background-color: #f2f2f2;
                height: 40px;
                border-radius: 20px;
                position: relative;
                margin: 30px 0;
                box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
                width: 100%;
                overflow: hidden;
            }
    
            .slider-fill {
                background: linear-gradient(to right, #4a90e2, #82c4e8);
                height: 100%;
                border-radius: 20px;
                transition: width 0.4s ease;
                position: relative;
            }
    
            .numerical-label {
                color: #333;
                font-size: 1.2em;
                font-weight: 700;
                position: absolute;
                top: 50%;
                transform: translate(-50%, -50%);
                transition: left 0.4s ease;
                background: #ffffff;
                border: 2px solid #4a90e2;
                border-radius: 15px;
                padding: 6px 12px;
                box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
                text-shadow: none;
            }
    
            .item-count {
                display: flex;
                justify-content: center;
                gap: 20px;
                margin-bottom: 20px;
                font-size: 1.1em;
            }
    
            .item-count label {
                font-weight: 600;
            }
    
            .search-container {
                display: flex;
                justify-content: center;
                margin-bottom: 20px;
            }
    
            .search-container input {
                width: 100%;
                max-width: 400px;
                padding: 10px 15px;
                font-size: 1em;
                border: 2px solid var(--button-gradient-end);
                background: rgba(255, 255, 255, 0.1);
                color: var(--text-primary);
            }
    
            .checklist-container {
                display: flex;
                flex-direction: column;
                gap: 15px;
                flex-grow: 1;
                overflow-y: auto;
                max-height: 400px;
            }
    
            .checklist-item {
                background: var(--item-bg);
                padding: 20px;
                border-radius: var(--border-radius);
                box-shadow: var(--shadow);
                display: flex;
                align-items: center;
                justify-content: space-between;
                transition: background-color 0.3s;
            }
    
            .checklist-item.dragging {
                opacity: 0.5;
            }
    
            .checklist-item textarea {
                font-size: 1.6em;
                border: 2px solid var(--border-radius);
                background: rgba(255, 255, 255, 0.1);
                outline: none;
                cursor: text;
                width: 100%;
                text-align: start;
                padding: 10px 20px;
                color: var(--text-primary);
                font-family: 'Roboto', sans-serif;
                resize: none;
                overflow: hidden;
                min-height: 50px;
                white-space: pre-wrap;
                transition: height 0.3s ease;
            }
    
            .checklist-item textarea:focus {
                background: rgba(255, 255, 255, 0.2);
            }
    
            .checklist-item .actions {
                display: flex;
                align-items: center;
                gap: 10px;
                margin-left: 10px;
            }
    
            .priority-box {
                background: linear-gradient(45deg, var(--button-gradient-end), var(--button-gradient-start));
                color: white;
                padding: 5px 10px;
                border-radius: var(--border-radius);
                font-weight: bold;
                cursor: pointer;
            }
    
            .button-container {
                display: flex;
                justify-content: center;
                gap: 10px;
                margin-top: 20px;
            }
    
            @media (max-width: 768px) {
                .container {
                    padding: 20px;
                }
    
                .checklist-item textarea {
                    font-size: 1.4em;
                }
    
                .numerical-label {
                    font-size: 1em;
                }
    
                .item-count {
                    flex-direction: column;
                    gap: 10px;
                }
            }
    
            /* Custom Modal Styles */
            .modal {
                position: fixed;
                top: 0;
                left: 0;
                right:0;
                bottom:0;
                background: rgba(0,0,0,0.6);
                display: flex;
                align-items: center;
                justify-content: center;
                visibility: hidden;
                opacity: 0;
                transition: visibility 0s, opacity 0.3s;
                z-index: 1000;
            }
    
            .modal.active {
                visibility: visible;
                opacity: 1;
            }
    
            .modal-content {
                background: var(--item-bg);
                padding: 20px;
                border-radius: var(--border-radius);
                width: 90%;
                max-width: 400px;
                box-shadow: var(--shadow);
                display: flex;
                flex-direction: column;
                gap: 15px;
            }
    
            .modal-content h2 {
                margin: 0;
                color: var(--text-primary);
                font-size: 1.5em;
            }
    
            .modal-content input {
                padding: 10px;
                font-size: 1em;
                border: 2px solid var(--button-gradient-end);
                border-radius: var(--border-radius);
                background: rgba(255, 255, 255, 0.1);
                color: var(--text-primary);
            }
    
            .modal-content .buttons {
                display: flex;
                justify-content: flex-end;
                gap: 10px;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <h1>Forex Checklist Analyzer</h1>
            <div class="slider-background">
                <div class="slider-fill" id="sliderFill">
                    <div class="numerical-label" id="numericalLabel">0</div>
                </div>
            </div>
            <div class="item-count">
                <label>Total: <span id="totalItems">0</span></label>
                <label>Active: <span id="activeItems">0</span></label>
            </div>
            <div class="search-container">
                <input type="text" id="searchBox" placeholder="Search criteria...">
            </div>
            <div class="checklist-container" id="checklistContainer"></div>
            <div class="button-container">
                <button id="addButton">Add</button>
                <button id="exportButton">Export</button>
                <button id="importButton">Import</button>
            </div>
        </div>
    
        <!-- Modal Structure -->
        <div class="modal" id="modal">
            <div class="modal-content">
                <h2 id="modalTitle">Add Criteria</h2>
                <input type="text" id="modalInput" placeholder="Enter value...">
                <div class="buttons">
                    <button id="cancelButton">Cancel</button>
                    <button id="confirmButton">Confirm</button>
                </div>
            </div>
        </div>
    
        <script>
            (() => {
                const storage = {
                    set(key, value) {
                        localStorage.setItem(key, JSON.stringify(value));
                    },
                    get(key, defaultValue) {
                        const item = localStorage.getItem(key);
                        return item ? JSON.parse(item) : defaultValue;
                    }
                };
    
                class ChecklistApp {
                    constructor() {
                        this.checklistData = storage.get('checklistData', []);
                        this.filteredData = [...this.checklistData];
                        this.draggedElement = null;
    
                        this.cacheDOM();
                        this.bindEvents();
                        this.render();
                    }
    
                    cacheDOM() {
                        this.container = document.getElementById('checklistContainer');
                        this.totalItems = document.getElementById('totalItems');
                        this.activeItems = document.getElementById('activeItems');
                        this.sliderFill = document.getElementById('sliderFill');
                        this.numericalLabel = document.getElementById('numericalLabel');
                        this.searchBox = document.getElementById('searchBox');
                        this.addButton = document.getElementById('addButton');
                        this.exportButton = document.getElementById('exportButton');
                        this.importButton = document.getElementById('importButton');
                        this.modal = document.getElementById('modal');
                        this.modalTitle = document.getElementById('modalTitle');
                        this.modalInput = document.getElementById('modalInput');
                        this.cancelButton = document.getElementById('cancelButton');
                        this.confirmButton = document.getElementById('confirmButton');
                    }
    
                    bindEvents() {
                        this.addButton.addEventListener('click', () => this.openModal('Add Criteria'));
                        this.exportButton.addEventListener('click', () => this.exportData());
                        this.importButton.addEventListener('click', () => this.importData());
                        this.searchBox.addEventListener('input', () => this.searchCriteria());
    
                        this.cancelButton.addEventListener('click', () => this.closeModal());
                        this.confirmButton.addEventListener('click', () => this.handleModalConfirm());
    
                        window.addEventListener('click', (e) => {
                            if (e.target === this.modal) this.closeModal();
                        });
                    }
    
                    openModal(title, placeholder = 'Enter value...', defaultValue = '') {
                        this.modalTitle.textContent = title;
                        this.modalInput.placeholder = title.includes('Priority') ? 'Enter priority number...' : placeholder;
                        this.modalInput.value = defaultValue;
                        this.modal.classList.add('active');
                        this.modalInput.focus();
                        this.currentAction = title;
                        this.currentEditIndex = null;
                    }
    
                    closeModal() {
                        this.modal.classList.remove('active');
                        this.modalInput.value = '';
                        this.currentAction = null;
                        this.currentEditIndex = null;
                    }
    
                    handleModalConfirm() {
                        const value = this.modalInput.value.trim();
                        if (this.currentAction === 'Add Criteria') {
                            if (value === '') {
                                this.showAlert('Please enter a valid name.');
                                return;
                            }
                            this.openModal('Add Priority');
                            this.currentAction = 'Add Priority';
                            this.newCriteriaName = value;
                        } else if (this.currentAction === 'Add Priority') {
                            const priority = parseInt(value, 10);
                            if (isNaN(priority)) {
                                this.showAlert('Please enter a valid priority number.');
                                return;
                            }
                            this.addCriteria(this.newCriteriaName, priority);
                            this.closeModal();
                        } else if (this.currentAction === 'Edit Criteria') {
                            if (value === '') {
                                this.showAlert('Please enter a valid name.');
                                return;
                            }
                            this.updateCriteriaTitle(this.currentEditIndex, value);
                            this.closeModal();
                        } else if (this.currentAction === 'Edit Priority') {
                            const priority = parseInt(value, 10);
                            if (isNaN(priority)) {
                                this.showAlert('Please enter a valid priority number.');
                                return;
                            }
                            this.updateCriteriaPriority(this.currentEditIndex, priority);
                            this.closeModal();
                        }
                    }
    
                    showAlert(message) {
                        alert(message);
                    }
    
                    addCriteria(name, priority) {
                        this.checklistData.push({ name, priority, active: true });
                        this.saveAndRender();
                    }
    
                    deleteCriteria(index) {
                        this.checklistData.splice(index, 1);
                        this.saveAndRender();
                    }
    
                    toggleActive(index) {
                        this.checklistData[index].active = !this.checklistData[index].active;
                        this.saveAndRender();
                    }
    
                    editTitle(index) {
                        this.openModal('Edit Criteria', 'Enter new name...', this.checklistData[index].name);
                        this.currentEditIndex = index;
                    }
    
                    editPriority(index) {
                        this.openModal('Edit Priority', 'Enter new priority...', this.checklistData[index].priority);
                        this.currentEditIndex = index;
                    }
    
                    updateCriteriaTitle(index, newTitle) {
                        this.checklistData[index].name = newTitle;
                        this.saveAndRender();
                    }
    
                    updateCriteriaPriority(index, newPriority) {
                        this.checklistData[index].priority = newPriority;
                        this.saveAndRender();
                    }
    
                    saveAndRender() {
                        storage.set('checklistData', this.checklistData);
                        this.render();
                    }
    
                    searchCriteria() {
                        const query = this.searchBox.value.toLowerCase();
                        this.filteredData = this.checklistData.filter(item => item.name.toLowerCase().includes(query));
                        this.renderList();
                    }
    
                    exportData() {
                        const dataStr = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(this.checklistData))}`;
                        const downloadAnchorNode = document.createElement('a');
                        downloadAnchorNode.setAttribute("href", dataStr);
                        downloadAnchorNode.setAttribute("download", "checklistData.json");
                        document.body.appendChild(downloadAnchorNode);
                        downloadAnchorNode.click();
                        downloadAnchorNode.remove();
                    }
    
                    importData() {
                        const input = document.createElement('input');
                        input.type = 'file';
                        input.accept = '.json';
                        input.onchange = (e) => {
                            const file = e.target.files[0];
                            if (!file) return;
                            const reader = new FileReader();
                            reader.onload = (event) => {
                                try {
                                    const importedData = JSON.parse(event.target.result);
                                    if (Array.isArray(importedData)) {
                                        this.checklistData = importedData;
                                        this.saveAndRender();
                                    } else {
                                        this.showAlert('Invalid JSON structure.');
                                    }
                                } catch {
                                    this.showAlert('Invalid JSON file.');
                                }
                            };
                            reader.readAsText(file);
                        };
                        input.click();
                    }
    
                    render() {
                        this.updateSlider();
                        this.updateCounts();
                        this.renderList();
                    }
    
                    updateSlider() {
                        const totalScore = this.checklistData.reduce((acc, item) => acc + (item.active ? item.priority : 0), 0);
                        const percentage = Math.min(totalScore, 100);
                        this.sliderFill.style.width = `${percentage}%`;
                        this.numericalLabel.textContent = totalScore;
                        const sliderWidth = this.sliderFill.parentElement.offsetWidth;
                        const labelWidth = this.numericalLabel.offsetWidth;
                        let left = (percentage / 100) * sliderWidth;
                        left = Math.max(labelWidth / 2, left);
                        left = Math.min(sliderWidth - labelWidth / 2, left);
                        this.numericalLabel.style.left = `${left}px`;
                    }
    
                    updateCounts() {
                        this.totalItems.textContent = this.checklistData.length;
                        const activeCount = this.checklistData.filter(item => item.active).length;
                        this.activeItems.textContent = activeCount;
                    }
    
                    renderList() {
                        this.container.innerHTML = '';
                        this.filteredData.forEach((item, index) => {
                            const actualIndex = this.checklistData.indexOf(item);
                            const itemElement = document.createElement('div');
                            itemElement.classList.add('checklist-item');
                            itemElement.setAttribute('draggable', 'true');
                            itemElement.dataset.index = actualIndex;
    
                            itemElement.innerHTML = `
                                <input type="checkbox" ${item.active ? 'checked' : ''}>
                                <textarea>${item.name}</textarea>
                                <div class="actions">
                                    <span class="priority-box">${item.priority}</span>
                                    <button class="delete-button">Delete</button>
                                </div>
                            `;
    
                            // Event Listeners
                            const checkbox = itemElement.querySelector('input[type="checkbox"]');
                            checkbox.addEventListener('change', () => this.toggleActive(actualIndex));
    
                            const textarea = itemElement.querySelector('textarea');
                            textarea.addEventListener('blur', (e) => {
                                const newValue = e.target.value.trim();
                                if (newValue) {
                                    this.updateCriteriaTitle(actualIndex, newValue);
                                } else {
                                    e.target.value = this.checklistData[actualIndex].name;
                                }
                            });
    
                            const priorityBox = itemElement.querySelector('.priority-box');
                            priorityBox.addEventListener('click', () => this.editPriority(actualIndex));
    
                            const deleteButton = itemElement.querySelector('.delete-button');
                            deleteButton.addEventListener('click', () => this.deleteCriteria(actualIndex));
    
                            // Drag Events
                            itemElement.addEventListener('dragstart', (e) => this.handleDragStart(e));
                            itemElement.addEventListener('dragover', (e) => this.handleDragOver(e));
                            itemElement.addEventListener('drop', (e) => this.handleDrop(e));
    
                            this.container.appendChild(itemElement);
                        });
                    }
    
                    handleDragStart(e) {
                        this.draggedElement = e.currentTarget;
                        e.dataTransfer.effectAllowed = 'move';
                        e.currentTarget.classList.add('dragging');
                    }
    
                    handleDragOver(e) {
                        e.preventDefault();
                        e.dataTransfer.dropEffect = 'move';
                        const target = e.currentTarget;
                        if (target && target !== this.draggedElement) {
                            const bounding = target.getBoundingClientRect();
                            const offset = e.clientY - bounding.top + (bounding.height / 2);
                            const parent = target.parentNode;
                            if (offset > bounding.height / 2) {
                                parent.insertBefore(this.draggedElement, target.nextSibling);
                            } else {
                                parent.insertBefore(this.draggedElement, target);
                            }
                        }
                    }
    
                    handleDrop(e) {
                        e.preventDefault();
                        this.draggedElement.classList.remove('dragging');
                        this.draggedElement = null;
                        this.updateDataOrder();
                    }
    
                    updateDataOrder() {
                        const items = this.container.querySelectorAll('.checklist-item');
                        const newOrder = Array.from(items).map(item => parseInt(item.dataset.index, 10));
                        this.checklistData = newOrder.map(index => this.checklistData[index]);
                        this.saveAndRender();
                    }
                }
    
                document.addEventListener('DOMContentLoaded', () => {
                    new ChecklistApp();
                });
            })();
        </script>
    </body>
    </html>
    

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