Download debugger.html from chahuadev/chahuadev-framework-en: direct link, hf CLI and curl.
- Browser
- Download file 34.1 kB
-
https://huggingface.co/datasets/chahuadev/chahuadev-framework-en/resolve/main/debugger.html
- Command line
-
hf download hf://datasets/chahuadev/chahuadev-framework-en/debugger.html
-
curl -L -o debugger.html https://huggingface.co/datasets/chahuadev/chahuadev-framework-en/resolve/main/debugger.html
34.1 kB
| <html lang="th"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>แดชบอร์ดวินิจฉัยระบบ Chahua Development</title> | |
| <style> | |
| /* --- CSS Variables for Clean Theme (Based on chahua_license) --- */ | |
| :root { | |
| --bg-color: #f8f9fa; | |
| --surface-color: #ffffff; | |
| --primary-text-color: #212529; | |
| --secondary-text-color: #6c757d; | |
| --accent-color: #0056b3; | |
| --accent-hover-color: #004085; | |
| --border-color: #dee2e6; | |
| --shadow-color: rgba(0, 0, 0, 0.1); | |
| --success-color: #28a745; | |
| --warning-color: #ffc107; | |
| --danger-color: #dc3545; | |
| --info-color: #17a2b8; | |
| --terminal-bg: #2d3748; | |
| --terminal-border: #4a5568; | |
| --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| --border-radius: 12px; | |
| --shadow: 0 4px 15px rgba(0, 0, 0, 0.1); | |
| --transition: all 0.3s ease; | |
| } | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: var(--font-family); | |
| background: var(--bg-color); | |
| color: var(--primary-text-color); | |
| line-height: 1.6; | |
| overflow: hidden; | |
| height: 100vh; | |
| width: 100vw; | |
| } | |
| /* Main Container Layout */ | |
| .dashboard-container { | |
| display: flex; | |
| height: 100vh; | |
| gap: 20px; | |
| padding: 20px; | |
| position: relative; | |
| } | |
| /* Left Panel - Terminal Section */ | |
| .terminal-panel { | |
| background: var(--terminal-bg); | |
| border-radius: var(--border-radius); | |
| color: #ffffff; | |
| font-family: 'Courier New', monospace; | |
| box-shadow: var(--shadow); | |
| display: flex; | |
| flex-direction: column; | |
| overflow: hidden; | |
| border: 1px solid var(--border-color); | |
| flex: 0 0 auto; | |
| position: relative; | |
| min-width: 400px; | |
| max-width: 75%; | |
| width: calc(60% - 10px); | |
| } | |
| .terminal-header { | |
| background: rgba(0, 86, 179, 0.1); | |
| padding: 15px 20px; | |
| border-bottom: 1px solid var(--border-color); | |
| display: flex; | |
| align-items: center; | |
| justify-content: space-between; | |
| } | |
| .terminal-title { | |
| color: var(--accent-color); | |
| font-size: 1.1rem; | |
| margin: 0; | |
| font-weight: 600; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .terminal-controls { | |
| display: flex; | |
| gap: 8px; | |
| } | |
| .terminal-btn { | |
| background: var(--surface-color); | |
| color: var(--accent-color); | |
| border: 1px solid var(--border-color); | |
| padding: 6px 12px; | |
| border-radius: var(--border-radius); | |
| cursor: pointer; | |
| font-size: 0.8rem; | |
| font-weight: 500; | |
| transition: var(--transition); | |
| white-space: nowrap; | |
| } | |
| .terminal-btn:hover { | |
| background: var(--accent-color); | |
| color: white; | |
| border-color: var(--accent-color); | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 8px rgba(0, 86, 179, 0.2); | |
| } | |
| .terminal-btn:disabled { | |
| background: var(--bg-color); | |
| color: var(--secondary-text-color); | |
| cursor: not-allowed; | |
| border-color: var(--border-color); | |
| transform: none; | |
| box-shadow: none; | |
| } | |
| .terminal-btn.export-btn { | |
| background: var(--success-color); | |
| border-color: var(--success-color); | |
| color: white; | |
| } | |
| .terminal-btn.export-btn:hover:not(:disabled) { | |
| background: #1e7e34; | |
| border-color: #1e7e34; | |
| } | |
| #terminal-container { | |
| flex: 1; | |
| padding: 20px; | |
| background: var(--terminal-bg); | |
| overflow: hidden; | |
| font-family: 'Consolas', 'Monaco', 'Courier New', monospace; | |
| font-size: 0.9rem; | |
| line-height: 1.4; | |
| } | |
| /* Resize Handle */ | |
| .resize-handle { | |
| position: absolute; | |
| top: 0; | |
| right: -10px; | |
| width: 20px; | |
| height: 100%; | |
| cursor: col-resize; | |
| background: transparent; | |
| z-index: 10; | |
| user-select: none; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } | |
| .resize-handle::before { | |
| content: ''; | |
| width: 4px; | |
| height: 40px; | |
| background: var(--border-color); | |
| border-radius: 2px; | |
| transition: var(--transition); | |
| } | |
| .resize-handle:hover::before { | |
| background: var(--accent-color); | |
| opacity: 0.7; | |
| } | |
| .resize-handle.resizing::before { | |
| background: var(--accent-color); | |
| opacity: 1; | |
| box-shadow: 0 0 10px rgba(0, 86, 179, 0.5); | |
| } | |
| .dashboard-container.resizing { | |
| user-select: none; | |
| } | |
| .dashboard-container.resizing * { | |
| pointer-events: none; | |
| } | |
| .dashboard-container.resizing .resize-handle { | |
| pointer-events: auto; | |
| } | |
| /* Right Panel - Analysis Panel */ | |
| .analysis-panel { | |
| background: var(--surface-color); | |
| border-radius: var(--border-radius); | |
| box-shadow: var(--shadow); | |
| overflow: hidden; | |
| border: 1px solid var(--border-color); | |
| flex: 1; | |
| min-width: 300px; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .analysis-header { | |
| background: var(--surface-color); | |
| padding: 20px; | |
| border-bottom: 1px solid var(--border-color); | |
| } | |
| .analysis-title { | |
| color: var(--accent-color); | |
| font-size: 1.3rem; | |
| font-weight: 600; | |
| margin: 0; | |
| text-align: center; | |
| } | |
| .analysis-content { | |
| flex: 1; | |
| overflow-y: auto; | |
| padding: 20px; | |
| } | |
| /* Inspector Panel */ | |
| .inspector-panel { | |
| background: var(--surface-color); | |
| border-radius: var(--border-radius); | |
| border: 1px solid var(--border-color); | |
| overflow: hidden; | |
| } | |
| .inspector-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| flex-wrap: wrap; | |
| gap: 10px; | |
| padding: 15px 20px; | |
| background: rgba(0, 86, 179, 0.05); | |
| border-bottom: 1px solid var(--border-color); | |
| } | |
| .inspector-title { | |
| color: var(--accent-color); | |
| font-size: 1.1rem; | |
| font-weight: 600; | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| } | |
| .inspector-controls { | |
| display: flex; | |
| gap: 8px; | |
| flex-wrap: wrap; | |
| } | |
| .inspector-content { | |
| padding: 20px; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 15px; | |
| } | |
| /* Inspector Stats */ | |
| .inspector-stats { | |
| background: rgba(0, 86, 179, 0.05); | |
| border-radius: var(--border-radius); | |
| padding: 15px; | |
| border: 1px solid var(--border-color); | |
| } | |
| .stats-row { | |
| display: flex; | |
| justify-content: space-around; | |
| gap: 10px; | |
| margin-bottom: 10px; | |
| } | |
| .stat-item { | |
| text-align: center; | |
| } | |
| .stat-label { | |
| color: var(--secondary-text-color); | |
| font-size: 0.85rem; | |
| margin-bottom: 5px; | |
| } | |
| .stat-value { | |
| color: var(--primary-text-color); | |
| font-size: 1.5rem; | |
| font-weight: bold; | |
| } | |
| .stat-error { | |
| color: var(--danger-color); | |
| } | |
| .stat-warning { | |
| color: var(--warning-color); | |
| } | |
| /* Inspector Filters */ | |
| .inspector-filters { | |
| background: var(--surface-color); | |
| border-radius: var(--border-radius); | |
| padding: 15px; | |
| border: 1px solid var(--border-color); | |
| } | |
| .filter-group { | |
| margin-bottom: 10px; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .filter-group label { | |
| color: var(--secondary-text-color); | |
| font-size: 0.9rem; | |
| font-weight: 500; | |
| min-width: 120px; | |
| } | |
| .filter-group select { | |
| flex: 1; | |
| padding: 8px 12px; | |
| border: 1px solid var(--border-color); | |
| border-radius: var(--border-radius); | |
| background: var(--surface-color); | |
| color: var(--primary-text-color); | |
| font-size: 0.9rem; | |
| transition: var(--transition); | |
| } | |
| .filter-group select:focus { | |
| outline: none; | |
| border-color: var(--accent-color); | |
| box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2); | |
| } | |
| /* Inspector Results */ | |
| .inspector-results { | |
| background: var(--surface-color); | |
| border-radius: var(--border-radius); | |
| padding: 20px; | |
| border: 1px solid var(--border-color); | |
| min-height: 200px; | |
| } | |
| .no-selection { | |
| text-align: center; | |
| color: var(--secondary-text-color); | |
| padding: 30px; | |
| } | |
| .no-selection i { | |
| font-size: 3rem; | |
| margin-bottom: 20px; | |
| color: var(--border-color); | |
| } | |
| .no-selection h3 { | |
| color: var(--primary-text-color); | |
| margin-bottom: 10px; | |
| font-size: 1.2rem; | |
| } | |
| /* Code Snippet */ | |
| .code-snippet { | |
| background: var(--terminal-bg) ; | |
| color: #c9d1d9; | |
| font-family: 'Consolas', 'Courier New', monospace; | |
| white-space: pre; | |
| overflow-x: auto; | |
| border: 1px solid var(--border-color); | |
| border-radius: var(--border-radius); | |
| padding: 15px; | |
| margin: 10px 0; | |
| font-size: 0.85rem; | |
| line-height: 1.4; | |
| } | |
| /* Detail Section */ | |
| .detail-section { | |
| margin-bottom: 20px; | |
| } | |
| .detail-label { | |
| color: var(--accent-color); | |
| font-weight: 600; | |
| margin-bottom: 8px; | |
| font-size: 0.9rem; | |
| } | |
| .detail-value { | |
| background: rgba(0, 86, 179, 0.05); | |
| padding: 12px; | |
| border-radius: var(--border-radius); | |
| font-family: 'Courier New', monospace; | |
| white-space: pre-wrap; | |
| word-break: break-word; | |
| border: 1px solid var(--border-color); | |
| font-size: 0.85rem; | |
| } | |
| /* Scrollbar */ | |
| ::-webkit-scrollbar { | |
| width: 8px; | |
| } | |
| ::-webkit-scrollbar-track { | |
| background: var(--bg-color); | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background: var(--border-color); | |
| border-radius: 4px; | |
| } | |
| ::-webkit-scrollbar-thumb:hover { | |
| background: var(--secondary-text-color); | |
| } | |
| /* CSS สำหรับ Log Viewer ใหม่ */ | |
| .log-viewer-container { | |
| flex: 1; | |
| background: #0d1117; /* สีดำสนิท */ | |
| color: #c9d1d9; /* สีเทาอ่อน */ | |
| font-family: 'Consolas', 'Courier New', monospace; | |
| font-size: 13px; | |
| padding: 15px; | |
| overflow-y: auto; /* ทำให้เลื่อนได้เมื่อ Log ยาว */ | |
| white-space: pre-wrap; /* ทำให้ขึ้นบรรทัดใหม่เมื่อยาวเกิน */ | |
| word-break: break-all; | |
| margin: 0; | |
| border: none; | |
| outline: none; | |
| } | |
| /* สไตล์สำหรับแต่ละบรรทัดของ Log */ | |
| .log-line { | |
| display: block; | |
| margin: 0; | |
| padding: 1px 0; | |
| } | |
| /* สีสำหรับ Log แต่ละประเภท */ | |
| .log-line.log-error { color: #f85149; font-weight: bold; } | |
| .log-line.log-warning { color: #f2cc60; } | |
| .log-line.log-success { color: #7ee787; } | |
| .log-line.log-info { color: #8b949e; } /* สีเทาสำหรับข้อมูลทั่วไป */ | |
| .log-line.log-debug { color: #58a6ff; } /* สีฟ้าสำหรับ debug */ | |
| .log-line.log-command { color: #bc8cff; font-style: italic; } | |
| /* Responsive adjustments */ | |
| @media (max-width: 768px) { | |
| .dashboard-container { | |
| flex-direction: column; | |
| } | |
| .terminal-panel { | |
| width: 100%; | |
| max-width: none; | |
| height: 50%; | |
| } | |
| .inspector-controls { | |
| justify-content: center; | |
| } | |
| } | |
| /* Hide dev buttons unless in dev mode */ | |
| body:not(.dev-mode) .dev-only { | |
| display: none ; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="dashboard-container"> | |
| <!-- Left Panel - Terminal Section --> | |
| <div class="terminal-panel"> | |
| <div class="terminal-header"> | |
| <div class="terminal-title"> | |
| <i class="fas fa-terminal"></i> | |
| เทอร์มินัลแบบโต้ตอบ | |
| </div> | |
| </div> | |
| <pre id="log-viewer" class="log-viewer-container"></pre> | |
| <!-- Resize Handle --> | |
| <div class="resize-handle" id="resizeHandle"></div> | |
| </div> | |
| <!-- Right Panel - Inspector Panel --> | |
| <div class="analysis-panel"> | |
| <div class="analysis-header"> | |
| <div class="analysis-title"> | |
| <i class="fas fa-search"></i> เครื่องมือตรวจสอบโปรเจค | |
| </div> | |
| </div> | |
| <div class="analysis-content"> | |
| <div class="inspector-panel"> | |
| <div class="inspector-header"> | |
| <div class="inspector-title"> | |
| <i class="fas fa-bug"></i> | |
| ตรวจสอบและวิเคราะห์ | |
| </div> | |
| <div class="inspector-controls"> | |
| <button class="terminal-btn dev-only" id="scanSelfBtn"> | |
| <i class="fas fa-user-secret"></i> สแกนตัวเอง (Dev) | |
| </button> | |
| <button class="terminal-btn" id="scanPluginsBtn"> | |
| <i class="fas fa-puzzle-piece"></i> สแกนปลั๊กอิน | |
| </button> | |
| <button class="terminal-btn dev-only" id="runE2eTestsBtn" style="color: var(--success-color) !important; border-color: var(--success-color) !important;"> | |
| <i class="fas fa-vial"></i> เริ่มการทดสอบ E2E (Dev) | |
| </button> | |
| <button class="terminal-btn dev-only" id="openTestReportBtn" style="color: var(--warning-color) !important; border-color: var(--warning-color) !important;"> | |
| <i class="fas fa-chart-line"></i> เปิดรายงานผลการทดสอบ (Dev) | |
| </button> | |
| <button class="terminal-btn export-btn" id="exportIssuesBtn" disabled style="display: none;"> | |
| <i class="fas fa-download"></i> ส่งออก JSON | |
| </button> | |
| </div> | |
| </div> | |
| <div class="inspector-content"> | |
| <div class="inspector-stats" id="inspectorStats" style="display: none;"> | |
| <div class="stats-row"> | |
| <div class="stat-item"> | |
| <div class="stat-label">ไฟล์ทั้งหมด</div> | |
| <div class="stat-value" id="totalFiles">0</div> | |
| </div> | |
| <div class="stat-item"> | |
| <div class="stat-label">ปัญหาทั้งหมด</div> | |
| <div class="stat-value" id="totalIssues">0</div> | |
| </div> | |
| <div class="stat-item"> | |
| <div class="stat-label">ข้อผิดพลาด</div> | |
| <div class="stat-value stat-error" id="totalErrors">0</div> | |
| </div> | |
| <div class="stat-item"> | |
| <div class="stat-label">คำเตือน</div> | |
| <div class="stat-value stat-warning" id="totalWarnings">0</div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="inspector-filters" id="inspectorFilters" style="display: none;"> | |
| <div class="filter-group"> | |
| <label>กรองตามประเภท:</label> | |
| <select id="typeFilter"> | |
| <option value="all">ทุกประเภท</option> | |
| <option value="SyntaxError">ข้อผิดพลาดไวยากรณ์</option> | |
| <option value="MissingFile">ไฟล์หายไป</option> | |
| <option value="UnusedFile">ไฟล์ไม่ได้ใช้</option> | |
| <option value="MissingDependency">การพึ่งพาหายไป</option> | |
| <option value="CircularDependency">การพึ่งพาแบบวนรอบ</option> | |
| <option value="DuplicateExport">การส่งออกซ้ำ</option> | |
| <option value="MissingExport">การนำเข้า/ส่งออกไม่ตรงกัน</option> | |
| </select> | |
| </div> | |
| <div class="filter-group"> | |
| <label>กรองตามความรุนแรง:</label> | |
| <select id="severityFilter"> | |
| <option value="all">ทุกระดับ</option> | |
| <option value="error">ข้อผิดพลาด</option> | |
| <option value="warning">คำเตือน</option> | |
| <option value="info">ข้อมูล</option> | |
| </select> | |
| </div> | |
| </div> | |
| <div class="inspector-results" id="inspectorResults"> | |
| <div class="no-selection"> | |
| <i class="fas fa-search"></i> | |
| <h3>เครื่องมือตรวจสอบโปรเจค</h3> | |
| <p>เครื่องมือวิเคราะห์โค้ดเพื่อหาปัญหาต่างๆ ก่อนการรัน</p> | |
| <div style="margin-top: 20px; text-align: left;"> | |
| <h4 style="color: var(--accent-color); margin-bottom: 10px;">ความสามารถ:</h4> | |
| <ul style="color: var(--secondary-text-color); line-height: 1.6;"> | |
| <li>ตรวจสอบไวยากรณ์ (ข้อผิดพลาดไวยากรณ์)</li> | |
| <li>หาไฟล์ที่ไม่มีอยู่จริง (ไฟล์หายไป)</li> | |
| <li>หาไฟล์ที่ไม่ได้ใช้งาน (ไฟล์ไม่ได้ใช้)</li> | |
| <li>ตรวจสอบการพึ่งพาที่ขาดหาย</li> | |
| <li>หาการพึ่งพาแบบวนรอบ</li> | |
| <li>หาการส่งออกซ้ำ</li> | |
| <li>หาการนำเข้า/ส่งออกไม่ตรงกัน (ข้อผิดพลาดรันไทม์)</li> | |
| </ul> | |
| </div> | |
| <div style="margin-top: 20px;"> | |
| <p style="color: var(--warning-color);">คลิก "สแกนปลั๊กอิน" เพื่อเริ่มวิเคราะห์</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script src="debugger.js"></script> | |
| <script> | |
| // ================================= | |
| // PRODUCTION SECURITY SYSTEM | |
| // ================================= | |
| // ตรวจสอบโหมดการทำงาน | |
| const isDevelopmentMode = () => { | |
| // ตรวจสอบจาก URL parameters | |
| const urlParams = new URLSearchParams(window.location.search); | |
| const devParam = urlParams.get('dev'); | |
| // ตรวจสอบจาก localStorage | |
| const devStorage = localStorage.getItem('chahua_dev_mode'); | |
| // ตรวจสอบจาก environment variables (ถ้ามี) | |
| const isLocalhost = window.location.hostname === 'localhost' || | |
| window.location.hostname === '127.0.0.1' || | |
| window.location.hostname === ''; | |
| return devParam === 'true' || devStorage === 'true' || isLocalhost; | |
| }; | |
| // ระบบป้องกัน Console และ Developer Tools | |
| const initProductionSecurity = () => { | |
| if (isDevelopmentMode()) { | |
| // เปิดใช้งาน dev mode | |
| document.body.classList.add('dev-mode'); | |
| console.log('%c Developer Mode Enabled', 'color: #28a745; font-weight: bold; font-size: 14px;'); | |
| return; | |
| } | |
| // ปิดใช้งาน console ทั้งหมด | |
| const noop = () => {}; | |
| const consoleMethods = [ | |
| 'log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', | |
| 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd' | |
| ]; | |
| consoleMethods.forEach(method => { | |
| console[method] = noop; | |
| }); | |
| // ป้องกันการเปิด Developer Tools | |
| let devtools = {open: false, orientation: null}; | |
| const threshold = 160; | |
| setInterval(() => { | |
| if (window.outerHeight - window.innerHeight > threshold || | |
| window.outerWidth - window.innerWidth > threshold) { | |
| if (!devtools.open) { | |
| devtools.open = true; | |
| // Redirect หรือ แสดงข้อความเตือน | |
| document.body.innerHTML = ` | |
| <div style=" | |
| position: fixed; top: 0; left: 0; right: 0; bottom: 0; | |
| background: #f8f9fa; display: flex; align-items: center; justify-content: center; | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| "> | |
| <div style="text-align: center; color: #212529;"> | |
| <h2 style="color: #dc3545; margin-bottom: 20px;"> การเข้าถึงถูกจำกัด</h2> | |
| <p>กรุณาปิด Developer Tools เพื่อดำเนินการต่อ</p> | |
| <p style="color: #6c757d; font-size: 0.9rem;">Developer Tools detected. Please close to continue.</p> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| } else { | |
| devtools.open = false; | |
| } | |
| }, 500); | |
| // ปิดใช้งานคำสั่งลัดของ Developer Tools | |
| document.addEventListener('keydown', (e) => { | |
| // ปิด F12 | |
| if (e.key === 'F12') { | |
| e.preventDefault(); | |
| return false; | |
| } | |
| // ปิด Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+Shift+C | |
| if (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.key === 'J' || e.key === 'C')) { | |
| e.preventDefault(); | |
| return false; | |
| } | |
| // ปิด Ctrl+U (View Source) | |
| if (e.ctrlKey && e.key === 'U') { | |
| e.preventDefault(); | |
| return false; | |
| } | |
| // ปิด Ctrl+S (Save Page) | |
| if (e.ctrlKey && e.key === 'S') { | |
| e.preventDefault(); | |
| return false; | |
| } | |
| }); | |
| // ป้องกัน Right Click Context Menu | |
| document.addEventListener('contextmenu', (e) => { | |
| e.preventDefault(); | |
| return false; | |
| }); | |
| // ป้องกัน Text Selection | |
| document.addEventListener('selectstart', (e) => { | |
| e.preventDefault(); | |
| return false; | |
| }); | |
| // ป้องกัน Drag and Drop | |
| document.addEventListener('dragstart', (e) => { | |
| e.preventDefault(); | |
| return false; | |
| }); | |
| }; | |
| // ================================= | |
| // RESIZE HANDLE FUNCTIONALITY | |
| // ================================= | |
| // Resize Handle Functionality | |
| class ResizeController { | |
| constructor() { | |
| this.container = document.querySelector('.dashboard-container'); | |
| this.terminalPanel = document.querySelector('.terminal-panel'); | |
| this.resizeHandle = document.getElementById('resizeHandle'); | |
| this.isResizing = false; | |
| this.resizeTimeout = null; | |
| if (this.resizeHandle) { | |
| this.init(); | |
| } | |
| } | |
| init() { | |
| // เพิ่ม throttled resize method | |
| this.boundThrottledResize = this.throttle(this.resizeTerminal.bind(this), 100); | |
| // Bound methods for proper event handling | |
| this.boundHandleResize = this.handleResize.bind(this); | |
| this.boundStopResize = this.stopResize.bind(this); | |
| this.boundKeydownHandler = this.handleKeydown.bind(this); | |
| this.emergencyCleanup = this.stopResize.bind(this); | |
| // Mouse events | |
| this.resizeHandle.addEventListener('mousedown', this.startResize.bind(this)); | |
| // Log เฉพาะใน dev mode | |
| if (isDevelopmentMode()) { | |
| console.log(" Resize controller initialized for debugger"); | |
| } | |
| } | |
| startResize(e) { | |
| e.preventDefault(); | |
| this.isResizing = true; | |
| // Add visual feedback | |
| this.container.classList.add('resizing'); | |
| this.resizeHandle.classList.add('resizing'); | |
| // Add event listeners | |
| document.addEventListener('mousemove', this.boundHandleResize); | |
| document.addEventListener('mouseup', this.boundStopResize); | |
| // Emergency cleanup listeners | |
| document.addEventListener('mouseleave', this.emergencyCleanup); | |
| window.addEventListener('blur', this.emergencyCleanup); | |
| document.addEventListener('keydown', this.boundKeydownHandler); | |
| // Log เฉพาะใน dev mode | |
| if (isDevelopmentMode()) { | |
| console.log(" Resize started"); | |
| } | |
| } | |
| handleResize(e) { | |
| if (!this.isResizing) return; | |
| e.preventDefault(); | |
| const containerRect = this.container.getBoundingClientRect(); | |
| const newWidth = e.clientX - containerRect.left; | |
| const containerWidth = containerRect.width; | |
| const minWidth = 300; | |
| const maxWidth = containerWidth * 0.8; | |
| if (newWidth >= minWidth && newWidth <= maxWidth) { | |
| this.terminalPanel.style.width = `${newWidth}px`; | |
| this.terminalPanel.style.flex = 'none'; | |
| } | |
| } | |
| handleKeydown(e) { | |
| if (e.key === 'Escape' && this.isResizing) { | |
| this.stopResize(); | |
| } | |
| } | |
| stopResize() { | |
| if (!this.isResizing) return; | |
| this.isResizing = false; | |
| // Remove visual feedback | |
| this.container.classList.remove('resizing'); | |
| this.resizeHandle.classList.remove('resizing'); | |
| // Remove event listeners | |
| document.removeEventListener('mousemove', this.boundHandleResize); | |
| document.removeEventListener('mouseup', this.boundStopResize); | |
| // Remove emergency cleanup listeners | |
| document.removeEventListener('mouseleave', this.emergencyCleanup); | |
| window.removeEventListener('blur', this.emergencyCleanup); | |
| document.removeEventListener('keydown', this.boundKeydownHandler); | |
| // Clear timeout | |
| if (this.resizeTimeout) { | |
| clearTimeout(this.resizeTimeout); | |
| this.resizeTimeout = null; | |
| } | |
| // Log เฉพาะใน dev mode | |
| if (isDevelopmentMode()) { | |
| console.log(" Resize stopped and listeners cleaned up"); | |
| } | |
| } | |
| // เพิ่มฟังก์ชัน throttle เข้าไปใน Class | |
| throttle(func, limit) { | |
| let inThrottle; | |
| return function() { | |
| const args = arguments; | |
| const context = this; | |
| if (!inThrottle) { | |
| func.apply(context, args); | |
| inThrottle = true; | |
| setTimeout(() => inThrottle = false, limit); | |
| } | |
| } | |
| } | |
| // เพิ่มฟังก์ชัน resizeTerminal สำหรับการอ้างอิงใน boundThrottledResize | |
| resizeTerminal() { | |
| // ถ้ามี diagnostic dashboard ให้เรียกใช้ resizeTerminal ของมัน | |
| if (window.diagnosticDashboard && window.diagnosticDashboard.resizeTerminal) { | |
| window.diagnosticDashboard.resizeTerminal(); | |
| } | |
| } | |
| } | |
| // ================================= | |
| // INITIALIZATION | |
| // ================================= | |
| // Initialize security system first | |
| initProductionSecurity(); | |
| // Initialize resize controller when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', () => { | |
| window.resizeController = new ResizeController(); | |
| }); | |
| // Cleanup on page unload | |
| window.addEventListener('beforeunload', () => { | |
| if (window.resizeController) { | |
| window.resizeController.stopResize(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> |