Spaces:
Running
Running
Download index.html from svsfvs/anycoder-a74e6fcc: direct link, hf CLI and curl.
- Browser
- Download file 24.2 kB
-
https://huggingface.co/spaces/svsfvs/anycoder-a74e6fcc/resolve/main/index.html
- Command line
-
hf download hf://spaces/svsfvs/anycoder-a74e6fcc/index.html
-
curl -L -o index.html https://huggingface.co/spaces/svsfvs/anycoder-a74e6fcc/resolve/main/index.html
24.2 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>PURE_ENGINE // BI-DIRECTIONAL_NEXUS_V.6</title> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;500;700&family=Rajdhani:wght@400;600;700&display=swap" rel="stylesheet"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css"> | |
| <style> | |
| :root { | |
| --bg-color: #050508; | |
| --panel-bg: #0a0a10; | |
| --primary-color: #00ff9d; | |
| --secondary-color: #ff0055; | |
| --accent-color: #00ccff; | |
| --text-dim: #8892b0; | |
| --code-font: 'Fira Code', monospace; | |
| --ui-font: 'Rajdhani', sans-serif; | |
| --border-glow: 0 0 10px rgba(0, 255, 157, 0.3); | |
| --panel-glow: 0 0 20px rgba(0, 0, 0, 0.5); | |
| } | |
| * { | |
| box-sizing: border-box; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| body { | |
| background-color: var(--bg-color); | |
| color: var(--primary-color); | |
| font-family: var(--ui-font); | |
| height: 100vh; | |
| overflow: hidden; | |
| display: flex; | |
| flex-direction: column; | |
| position: relative; | |
| } | |
| /* CRT Overlay */ | |
| body::before { | |
| content: " "; | |
| display: block; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| bottom: 0; | |
| right: 0; | |
| background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03)); | |
| z-index: 999; | |
| background-size: 100% 2px, 3px 100%; | |
| pointer-events: none; | |
| } | |
| /* Header */ | |
| header { | |
| height: 70px; | |
| border-bottom: 1px solid var(--primary-color); | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| padding: 0 2rem; | |
| background: rgba(5, 5, 8, 0.95); | |
| backdrop-filter: blur(10px); | |
| z-index: 100; | |
| box-shadow: var(--border-glow); | |
| } | |
| .brand { | |
| display: flex; | |
| align-items: center; | |
| gap: 15px; | |
| } | |
| .brand h1 { | |
| font-size: 1.8rem; | |
| letter-spacing: 3px; | |
| text-transform: uppercase; | |
| font-weight: 700; | |
| text-shadow: var(--border-glow); | |
| } | |
| .brand span { | |
| color: var(--secondary-color); | |
| font-family: var(--code-font); | |
| font-size: 0.9rem; | |
| } | |
| .system-status { | |
| display: flex; | |
| gap: 20px; | |
| font-size: 1rem; | |
| font-weight: 600; | |
| } | |
| .status-dot { | |
| width: 10px; | |
| height: 10px; | |
| border-radius: 50%; | |
| background-color: var(--primary-color); | |
| box-shadow: var(--border-glow); | |
| animation: pulse 2s infinite; | |
| } | |
| /* Main Workspace */ | |
| main { | |
| flex: 1; | |
| display: flex; | |
| padding: 20px; | |
| gap: 20px; | |
| overflow: hidden; | |
| z-index: 10; | |
| } | |
| /* Panels */ | |
| .workspace { | |
| flex: 2; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 15px; | |
| } | |
| .preview-panel { | |
| flex: 1; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 15px; | |
| } | |
| .panel-container { | |
| flex: 1; | |
| background: var(--panel-bg); | |
| border: 1px solid var(--primary-color); | |
| border-radius: 4px; | |
| position: relative; | |
| box-shadow: var(--panel-glow); | |
| display: flex; | |
| flex-direction: column; | |
| overflow: hidden; | |
| } | |
| .panel-header { | |
| background: rgba(0, 255, 157, 0.1); | |
| padding: 10px 15px; | |
| border-bottom: 1px solid rgba(0, 255, 157, 0.3); | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| font-family: var(--code-font); | |
| font-size: 0.9rem; | |
| } | |
| .panel-title { | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .panel-title::before { | |
| content: ''; | |
| display: block; | |
| width: 8px; | |
| height: 8px; | |
| background: var(--primary-color); | |
| border-radius: 50%; | |
| } | |
| .editor-wrapper { | |
| flex: 1; | |
| position: relative; | |
| } | |
| textarea { | |
| width: 100%; | |
| height: 100%; | |
| background: rgba(0,0,0,0.8); | |
| color: var(--text-dim); | |
| border: none; | |
| padding: 20px; | |
| font-family: var(--code-font); | |
| font-size: 14px; | |
| line-height: 1.6; | |
| resize: none; | |
| outline: none; | |
| transition: background 0.3s; | |
| } | |
| textarea:focus { | |
| background: rgba(0,0,0,1); | |
| } | |
| textarea.python-editor { | |
| color: #d4d4d4; | |
| } | |
| /* Readable Preview Styling (Simulated UI) */ | |
| .readable-preview { | |
| padding: 20px; | |
| overflow-y: auto; | |
| background: #0d0d12; | |
| font-family: var(--code-font); | |
| font-size: 14px; | |
| } | |
| .data-record { | |
| border-left: 3px solid var(--accent-color); | |
| background: rgba(0, 204, 255, 0.05); | |
| padding: 15px; | |
| margin-bottom: 15px; | |
| transition: all 0.3s ease; | |
| } | |
| .data-record:hover { | |
| background: rgba(0, 204, 255, 0.1); | |
| transform: translateX(5px); | |
| } | |
| .data-record.credit-card { border-color: var(--primary-color); } | |
| .data-record.email { border-color: var(--secondary-color); } | |
| .data-record.number { border-color: #ffcc00; } | |
| .record-header { | |
| display: flex; | |
| justify-content: space-between; | |
| margin-bottom: 10px; | |
| font-size: 0.8rem; | |
| color: var(--text-dim); | |
| text-transform: uppercase; | |
| border-bottom: 1px solid rgba(255,255,255,0.1); | |
| padding-bottom: 5px; | |
| } | |
| .record-content { | |
| color: #e0e0e0; | |
| white-space: pre-wrap; | |
| line-height: 1.5; | |
| } | |
| .highlight-val { | |
| color: var(--primary-color); | |
| font-weight: bold; | |
| } | |
| /* Controls */ | |
| .controls { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| gap: 20px; | |
| padding: 20px; | |
| background: rgba(0,0,0,0.8); | |
| border-top: 1px solid #333; | |
| } | |
| .btn { | |
| padding: 12px 30px; | |
| background: transparent; | |
| border: 1px solid var(--primary-color); | |
| color: var(--primary-color); | |
| font-family: var(--ui-font); | |
| font-size: 1.2rem; | |
| font-weight: 700; | |
| text-transform: uppercase; | |
| cursor: pointer; | |
| transition: all 0.3s; | |
| clip-path: polygon(10% 0, 100% 0, 100% 70%, 90% 100%, 0 100%, 0 30%); | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .btn:hover { | |
| background: var(--primary-color); | |
| color: #000; | |
| box-shadow: var(--border-glow); | |
| } | |
| .btn-secondary { | |
| border-color: var(--accent-color); | |
| color: var(--accent-color); | |
| } | |
| .btn-secondary:hover { | |
| background: var(--accent-color); | |
| box-shadow: 0 0 15px rgba(0, 204, 255, 0.4); | |
| } | |
| .btn-danger { | |
| border-color: var(--secondary-color); | |
| color: var(--secondary-color); | |
| } | |
| .btn-danger:hover { | |
| background: var(--secondary-color); | |
| box-shadow: 0 0 15px rgba(255, 0, 85, 0.4); | |
| } | |
| /* Terminal */ | |
| .terminal { | |
| height: 150px; | |
| background: #000; | |
| border-top: 1px solid var(--text-dim); | |
| padding: 15px; | |
| font-family: var(--code-font); | |
| font-size: 0.85rem; | |
| color: var(--text-dim); | |
| overflow-y: auto; | |
| display: flex; | |
| flex-direction: column-reverse; | |
| } | |
| .log-entry { | |
| margin-bottom: 5px; | |
| } | |
| .log-entry::before { | |
| content: "> "; | |
| color: var(--primary-color); | |
| } | |
| .log-error { color: var(--secondary-color); } | |
| .log-info { color: var(--accent-color); } | |
| .log-success { color: var(--primary-color); font-weight: bold; } | |
| /* Responsive */ | |
| @media (max-width: 1024px) { | |
| main { | |
| flex-direction: column; | |
| overflow-y: auto; | |
| } | |
| .workspace, .preview-panel { | |
| flex: none; | |
| height: 500px; | |
| } | |
| } | |
| /* Animations */ | |
| @keyframes pulse { | |
| 0% { box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.7); } | |
| 70% { box-shadow: 0 0 0 10px rgba(0, 255, 157, 0); } | |
| 100% { box-shadow: 0 0 0 0 rgba(0, 255, 157, 0); } | |
| } | |
| @keyframes glitch { | |
| 0% { transform: translate(0); } | |
| 20% { transform: translate(-2px, 2px); } | |
| 40% { transform: translate(-2px, -2px); } | |
| 60% { transform: translate(2px, 2px); } | |
| 80% { transform: translate(2px, -2px); } | |
| 100% { transform: translate(0); } | |
| } | |
| .glitch-effect { | |
| animation: glitch 0.2s cubic-bezier(.25, .46, .45, .94) both infinite; | |
| color: var(--secondary-color) ; | |
| border-color: var(--secondary-color) ; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header> | |
| <div class="brand"> | |
| <h1>PURE_ENGINE</h1> | |
| <span>// BI-DIRECTIONAL_NEXUS_V.6</span> | |
| </div> | |
| <div class="system-status"> | |
| <div class="status-item">SYSTEM: <span style="color:var(--primary-color)">ONLINE</span></div> | |
| <div class="status-item">MODE: <span style="color:var(--accent-color)">SYNCHRONIZED</span></div> | |
| <div class="status-item"> | |
| <div class="status-dot"></div> | |
| <span style="margin-left: 5px">NEURAL_LINK</span> | |
| </div> | |
| </div> | |
| </header> | |
| <main> | |
| <!-- Left Side: Python Code Generation --> | |
| <section class="workspace"> | |
| <div class="panel-container"> | |
| <div class="panel-header"> | |
| <div class="panel-title">PYTHON_SCRIPT_GENERATOR</div> | |
| <div style="color: var(--text-dim);">READ/WRITE_PERMISSION: GRANTED</div> | |
| </div> | |
| <div class="editor-wrapper"> | |
| <textarea id="pythonCode" spellcheck="false" placeholder="# Paste raw data here to generate Python structure... | |
| # Or edit this code to update the readable output. | |
| # Example: | |
| # data_list = ['item1', 'item2'] | |
| # parsed_output = { 'id': 1, 'value': 'data' }"></textarea> | |
| </div> | |
| </div> | |
| <div class="controls"> | |
| <button class="btn btn-danger" id="clearBtn">PURGE_DATA</button> | |
| <button class="btn" id="generateBtn">INITIATE_CONVERSION</button> | |
| <button class="btn btn-secondary" id="syncBtn">FORCE_SYNC</button> | |
| </div> | |
| </section> | |
| <!-- Right Side: Readable Dashboard --> | |
| <section class="preview-panel"> | |
| <div class="panel-container" style="border-color: var(--accent-color);"> | |
| <div class="panel-header"> | |
| <div class="panel-title">HUMAN_READABLE_DASHBOARD</div> | |
| <div style="color: var(--text-dim);">LIVE_UPDATE: ACTIVE</div> | |
| </div> | |
| <div id="readableContent" class="readable-preview"> | |
| <div style="text-align: center; padding: 50px; color: var(--text-dim);"> | |
| <p>AWAITING DATA STREAM...</p> | |
| <p style="font-size: 0.8rem; margin-top: 10px;"> | |
| [ SYSTEM READY. INPUT RAW TEXT OR PYTHON CODE TO BEGIN DECONSTRUCTION. ] | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="terminal" id="terminalLog"> | |
| <div class="log-entry">> SYSTEM_INIT: PURE_ENGINE_SINGULARITY...</div> | |
| <div class="log-entry">> MODULES_LOADED: [PYTHON_PARSER, PATTERN_MATCHER, UI_RENDER]</div> | |
| <div class="log-entry log-success">> STATUS: SYNCHRONIZATION ESTABLISHED</div> | |
| </div> | |
| </section> | |
| </main> | |
| <script> | |
| // --- CORE ENGINE LOGIC --- | |
| const terminal = document.getElementById('terminalLog'); | |
| const readableContent = document.getElementById('readableContent'); | |
| const pythonCodeArea = document.getElementById('pythonCode'); | |
| const generateBtn = document.getElementById('generateBtn'); | |
| const clearBtn = document.getElementById('clearBtn'); | |
| const syncBtn = document.getElementById('syncBtn'); | |
| // Helper: Log to Terminal | |
| function log(msg, type = 'info') { | |
| const div = document.createElement('div'); | |
| div.className = 'log-entry ' + (type === 'error' ? 'log-error' : type === 'success' ? 'log-success' : 'log-info'); | |
| const timestamp = new Date().toLocaleTimeString('en-US', { hour12: false }); | |
| div.innerText = `[${timestamp}] ${msg}`; | |
| // Insert before the last child (which is effectively the top due to flex-reverse logic if we appended, | |
| // but here we want prepend for "newest at bottom" visually in flex-direction: column-reverse) | |
| // Actually, with flex-direction: column-reverse, the last child is at the bottom visually. | |
| // So we want to append to the DOM to put it at the bottom visually? | |
| // Let's just prepend for "newest at top" standard terminal style or append for newest at bottom. | |
| // Let's use prepend for "Newest at Top" (like a chat). | |
| terminal.prepend(div); | |
| } | |
| // Helper: Create HTML for Readable Card | |
| function createReadableCard(type, title, contentHTML) { | |
| const card = document.createElement('div'); | |
| card.className = `data-record ${type}`; | |
| let typeLabel = "UNKNOWN_DATA"; | |
| if(type === 'credit-card') typeLabel = "FINANCIAL_TRANSACTION"; | |
| if(type === 'email') typeLabel = "USER_COMMUNICATION"; | |
| if(type === 'number') typeLabel = "STRUCTURED_IDENTIFIER"; | |
| if(type === 'text') typeLabel = "DECODED_TEXTURE"; | |
| card.innerHTML = ` | |
| <div class="record-header"> | |
| <span>${typeLabel}</span> | |
| <span style="font-family:var(--code-font)">ID:${Math.floor(Math.random() * 9000) + 1000}</span> | |
| </div> | |
| <div class="record-content"> | |
| ${contentHTML} | |
| </div> | |
| `; | |
| return card; | |
| } | |
| // --- PATTERN RECOGNITION & PYTHON GENERATION --- | |
| function generatePythonCodeFromText(text) { | |
| if (!text || text.trim().length === 0) return ""; | |
| let pythonCode = "# Generated Data Structure from PURE_ENGINE\n"; | |
| pythonCode += "raw_input_text = '''" + text.replace(/'/g, "\\'") + "'''\n\n"; | |
| pythonCode += "parsed_data = {\n 'source': 'user_input_stream',\n 'records': [\n"; | |
| let recordsAdded = 0; | |
| // 1. Credit Card Detection | |
| const ccRegex = /(?:\d[ -]*?){13,19}/g; | |
| const ccMatches = text.match(ccRegex); | |
| if (ccMatches) { | |
| log(`DETECTED_CREDIT_CARDS: ${ccMatches.length} FOUND`, 'info'); | |
| ccMatches.forEach((match, index) => { | |
| const clean = match.replace(/\D/g, ''); | |
| const groups = clean.match(/.{1,4}/g); | |
| const formatted = groups ? groups.join(' ') : clean; | |
| pythonCode += ` {\n`; | |
| pythonCode += ` 'type': 'credit_card',\n`; | |
| pythonCode += ` 'masked_number': '${"**** **** **** " + clean.slice(-4)}',\n`; | |
| pythonCode += ` 'raw_value': '${formatted}',\n`; | |
| pythonCode += ` 'luhn_valid': True,\n`; | |
| pythonCode += ` 'bin': '${clean.slice(0,6)}'\n`; | |
| pythonCode += ` },\n`; | |
| recordsAdded++; | |
| }); | |
| } | |
| // 2. Email Detection | |
| const emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g; | |
| const emailMatches = text.match(emailRegex); | |
| if (emailMatches) { | |
| log(`DETECTED_EMAILS: ${emailMatches.length} FOUND`, 'info'); | |
| emailMatches.forEach((email, index) => { | |
| const parts = email.split('@'); | |
| pythonCode += ` {\n`; | |
| pythonCode += ` 'type': 'email',\n`; | |
| pythonCode += ` 'address': '${email}',\n`; | |
| pythonCode += ` 'user': '${parts[0]}',\n`; | |
| pythonCode += ` 'domain': '${parts[1]}',\n`; | |
| pythonCode += ` 'provider': '${parts[1].split('.')[0]}'\n`; | |
| pythonCode += ` },\n`; | |
| recordsAdded++; | |
| }); | |
| } | |
| // 3. Numbers / IDs | |
| const numberRegex = /\b\d{5,}\b/g; | |
| const numberMatches = text.match(numberRegex); | |
| // Filter out numbers that are part of CC numbers (simple check: if they are in a long sequence) | |
| // For simplicity in this demo, we show standalone long numbers | |
| if (numberMatches) { | |
| // Filter to avoid duplicates of CC numbers | |
| const uniqueNumbers = [...new Set(numberMatches.filter(n => !ccMatches || !ccMatches.some(c => c.includes(n))))]; | |
| if (uniqueNumbers.length > 0) { | |
| log(`DETECTED_IDS/STREAMS: ${uniqueNumbers.length} FOUND`, 'info'); | |
| uniqueNumbers.forEach((num, index) => { | |
| let type = "INTEGER"; | |
| if (num.length === 9) type = "SSN/LINK_ID"; | |
| else if (num.length > 10) type = "UNIVERSAL_ID"; | |
| pythonCode += ` {\n`; | |
| pythonCode += ` 'type': 'identifier',\n`; | |
| pythonCode += ` 'value': ${num},\n`; | |
| pythonCode += ` 'classification': '${type}'\n`; | |
| pythonCode += ` },\n`; | |
| recordsAdded++; | |
| }); | |
| } | |
| } | |
| // 4. General Text Extraction | |
| const textBlocks = text.match(/[a-zA-Z0-9\s,.'"]{50,}/g); | |
| if (textBlocks && textBlocks.length > 0) { | |
| log("DETECTED_TEXTURE_BLOCKS...", 'info'); | |
| // Just take the first block for the demo to avoid clutter | |
| const block = textBlocks[0].trim(); | |
| // Escape for Python | |
| const safeBlock = block.replace(/'/g, "\\'"); | |
| pythonCode += ` {\n`; | |
| pythonCode += ` 'type': 'text_fragment',\n`; | |
| pythonCode += ` 'content': '${safeBlock}',\n`; | |
| pythonCode += ` 'length': ${block.length}\n`; | |
| pythonCode += ` },\n`; | |
| recordsAdded++; | |
| } | |
| pythonCode += " ]\n"; | |
| pythonCode += "}\n\n"; | |
| pythonCode += "print(f'Processed {recordsAdded} records successfully.')"; | |
| return pythonCode; | |
| } | |
| // Function to Parse Python Code and Render UI | |
| function renderUIFromPython(code) { | |
| readableContent.innerHTML = ''; // Clear current | |
| // Simple heuristic parsing for the UI (Not a full Python parser, but works for the generated format) | |
| // We look for patterns like 'type': '...' and 'value': ... | |
| // 1. Find all 'type' declarations | |
| const typeRegex = /'type':\s*'([^']+)'/g; | |
| const types = [...code.matchAll(typeRegex)]; | |
| // 2. Extract values based on type | |
| types.forEach((match, index) => { | |
| const type = match[1]; | |
| const start = match.index; | |
| // Extract content until the next record or end of records array | |
| const nextRecordStart = code.indexOf("},", start); | |
| const recordBlock = code.substring(start, nextRecordStart !== -1 ? nextRecordStart + 2 : code.length); | |
| let contentHTML = ""; | |
| if (type === 'credit_card') { | |
| const numMatch = recordBlock.match(/'masked_number':\s*'([^']+)'/); | |
| const rawMatch = recordBlock.match(/'raw_value':\s*'([^']+)'/); | |
| contentHTML = `<div>STATUS: <span class="highlight-val">VALIDATED</span></div>`; | |
| contentHTML += `<div>CARD: ${numMatch ? numMatch[1] : 'N/A'}</div>`; | |
| contentHTML += `<div>FULL: ${rawMatch ? rawMatch[1] : 'N/A'}</div>`; | |
| readableContent.appendChild(createReadableCard('credit-card', "Credit Card Node", contentHTML)); | |
| } | |
| else if (type === 'email') { | |
| const addrMatch = recordBlock.match(/'address':\s*'([^']+)'/); | |
| const domMatch = recordBlock.match(/'domain':\s*'([^']+)'/); | |
| contentHTML = `<div>TO: <span class="highlight-val">${addrMatch ? addrMatch[1] : 'N/A'}</span></div>`; | |
| contentHTML += `<div>DOMAIN: ${domMatch ? domMatch[1] : 'N/A'}</div>`; | |
| contentHTML += `<div>SECURITY: ENCRYPTED</div>`; | |
| readableContent.appendChild(createReadableCard('email', "Email Node", contentHTML)); | |
| } | |
| else if (type === 'identifier') { | |
| const valMatch = recordBlock.match(/'value':\s*(\d+)/); | |
| const classMatch = recordBlock.match(/'classification':\s*'([^']+)'/); | |
| contentHTML = `<div>ID_CLASS: ${classMatch ? classMatch[1] : 'UNKNOWN'}</div>`; | |
| contentHTML += `<div>VALUE: <span class="highlight-val">${valMatch ? valMatch[1] : 'N/A'}</span></div>`; | |
| readableContent.appendChild(createReadableCard('number', "Data Identifier", contentHTML)); | |
| } | |
| else if (type === 'text_fragment') { | |
| const contentMatch = recordBlock.match(/'content':\s*'([^']+)'/); | |
| contentHTML = `<div style="white-space: pre-wrap; color: #ccc;">"${contentMatch ? contentMatch[1] : ''}"</div>`; | |
| readableContent.appendChild(createReadableCard('text', "Text Fragment", contentHTML)); | |
| } | |
| }); | |
| if (readableContent.children.length === 0) { | |
| readableContent.innerHTML = '<div style="text-align: center; padding: 50px; color: var(--text-dim);"><p>NO STRUCTURED DATA DETECTED IN CODE</p><p>EDIT PYTHON CODE TO ADD RECORDS</p></div>'; | |
| } | |
| } | |
| // Main Processor | |
| function processStream() { | |
| const input = pythonCodeArea.value; | |
| if (input.trim().length === 0) { | |
| log("ERROR: EMPTY_INPUT_STREAM", "error"); | |
| return; | |
| } | |
| // Check if input looks like Python code or raw text | |
| const looksLikePython = input.includes("def ") || input.includes("import ") || input.includes("'type'"); | |
| if (looksLikePython) { | |
| log("DETECTING_PYTHON_STRUCTURE...", "info"); | |
| renderUIFromPython(input); | |
| log("UI_RENDER_COMPLETE: SYNCHRONIZED", "success"); | |
| } else { | |
| log("CONVERTING_RAW_TEXT_TO_PYTHON...", "info"); | |
| const generatedCode = generatePythonCodeFromText(input); | |
| pythonCodeArea.value = generatedCode; | |
| // Trigger UI render after a slight delay to allow DOM update | |
| setTimeout(() => { | |
| renderUIFromPython(generatedCode); | |
| log("PYTHON_GENERATION_COMPLETE", "success"); | |
| }, 100); | |
| } | |
| } | |
| // --- EVENT LISTENERS --- | |
| generateBtn.addEventListener('click', () => { | |
| // Visual Glitch Effect | |
| generateBtn.classList.add('glitch-effect'); | |
| setTimeout(() => generateBtn.classList.remove('glitch-effect'), 300); | |
| processStream(); | |
| }); | |
| clearBtn.addEventListener('click', () => { | |
| pythonCodeArea.value = ''; | |
| readableContent.innerHTML = '<div style="text-align: center; padding: 50px; color: var(--text-dim);"><p>AWAITING DATA STREAM...</p><p style="font-size: 0.8rem; margin-top: 10px;">[ SYSTEM PURGED. READY. ]</p></div>'; | |
| terminal.innerHTML = ''; | |
| log("SYSTEM PURGED. READY FOR NEW_INPUT.", "info"); | |
| }); | |
| syncBtn.addEventListener('click', () => { | |
| // If user manually edited the Python code, force re-render UI | |
| log("MANUAL_SYNC_INITIATED...", "info"); | |
| renderUIFromPython(pythonCodeArea.value); | |
| log("UI_REFRESHED.", "success"); | |
| }); | |
| // Auto-update UI if user types in the Python editor | |
| let autoSaveTimer; | |
| pythonCodeArea.addEventListener('input', () => { | |
| clearTimeout(autoSaveTimer); | |
| autoSaveTimer = setTimeout(() => { | |
| // Only auto-render if it looks like python to avoid errors on typing | |
| if (pythonCodeArea.value.includes("'type'")) { | |
| renderUIFromPython(pythonCodeArea.value); | |
| } | |
| }, 1000); | |
| }); | |
| // Initialize | |
| hljs.highlightAll(); | |
| log("CONNECTION_ESTABLISHED. AWAITING_COMMAND."); | |
| </script> | |
| </body> | |
| </html> |