Prompt Generator Implementation Analysis

Key Features Identified:

1. Data Structure

Prompts are stored as an array of objects with properties:

{ "category": "Computers", "name": "Act as a Linux Terminal", "text": "I want you to act as a linux terminal..." }

2. Template Processing

Dynamic placeholders in curly braces {like this} are converted to input fields:

// Extract placeholders: /{(?!like this)(.*?)}/g // Convert to input fields with unique IDs // Real-time template filling as user types

3. Search & Filter

Real-time search across category names and prompt names:

function filterNodes() { var searchValue = document.getElementById("searchInput").value.toLowerCase(); // Filter categories and prompts // Show/hide based on search matches }

4. Expandable UI

Tree-like structure with collapsible categories and prompts:

function toggleChildren(node) { // Expand/collapse category // Show/hide all prompts in category } function toggleText(promptElement) { // Expand/collapse individual prompt details }

5. Copy to Clipboard

One-click copying of final processed text:

function copyText(promptElementId) { let activePrompt = getPromptById(promptId); navigator.clipboard.writeText(activePrompt['finalText']); }

6. Real-time Template Updates

As users type in input fields, the template updates live:

function fillInTemplate(inputElement, inputId, promptId) { // Get current input values // Replace template placeholders // Update final text display }

Technology Stack:

Implementation Flow:

  1. Load prompts data array
  2. Group prompts by category
  3. Process each prompt for template placeholders
  4. Generate input fields for placeholders
  5. Render UI using Mustache templates
  6. Bind event listeners for search, expand/collapse, copy
  7. Handle real-time template updates