| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <title>UTG Interactive Visualization</title> |
| <meta charset="utf-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.28.1/cytoscape.min.js"></script> |
| <style> |
| :root { |
| --bg-primary: #ffffff; |
| --bg-secondary: #f5f5f5; |
| --bg-tertiary: #e8e8e8; |
| --text-primary: #333333; |
| --text-secondary: #666666; |
| --border-color: #dddddd; |
| --accent-blue: #2196F3; |
| --accent-teal: #4ECDC4; |
| --accent-red: #FF6B6B; |
| --accent-orange: #FFA726; |
| --accent-purple: #9C27B0; |
| --accent-green: #66BB6A; |
| --graph-bg: #f8f9fa; |
| --node-text: #ffffff; |
| --edge-color: #999999; |
| --shadow: rgba(0, 0, 0, 0.1); |
| } |
| |
| [data-theme="dark"] { |
| --bg-primary: #1a1a2e; |
| --bg-secondary: #16213e; |
| --bg-tertiary: #0f3460; |
| --text-primary: #e8e8e8; |
| --text-secondary: #a0a0a0; |
| --border-color: #2d3748; |
| --accent-blue: #64B5F6; |
| --accent-teal: #4DB6AC; |
| --accent-red: #EF5350; |
| --accent-orange: #FFB74D; |
| --accent-purple: #BA68C8; |
| --accent-green: #81C784; |
| --graph-bg: #0d1b2a; |
| --node-text: #ffffff; |
| --edge-color: #5a6578; |
| --shadow: rgba(0, 0, 0, 0.3); |
| } |
| |
| * { |
| box-sizing: border-box; |
| transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease; |
| } |
| |
| html, body { |
| width: 100%; |
| height: 100%; |
| margin: 0; |
| padding: 0; |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; |
| background: var(--bg-primary); |
| color: var(--text-primary); |
| } |
| |
| .container { |
| display: flex; |
| flex-direction: column; |
| height: 100%; |
| } |
| |
| |
| .toolbar { |
| display: flex; |
| align-items: center; |
| justify-content: space-between; |
| padding: 12px 20px; |
| background: var(--bg-secondary); |
| border-bottom: 1px solid var(--border-color); |
| flex-wrap: wrap; |
| gap: 10px; |
| } |
| |
| .toolbar-left { |
| display: flex; |
| align-items: center; |
| gap: 20px; |
| } |
| |
| .toolbar-right { |
| display: flex; |
| align-items: center; |
| gap: 15px; |
| } |
| |
| .title { |
| font-size: 18px; |
| font-weight: 600; |
| color: var(--text-primary); |
| } |
| |
| |
| .theme-toggle { |
| display: flex; |
| align-items: center; |
| gap: 8px; |
| cursor: pointer; |
| padding: 6px 12px; |
| border-radius: 20px; |
| background: var(--bg-tertiary); |
| border: 1px solid var(--border-color); |
| } |
| |
| .theme-toggle:hover { |
| background: var(--border-color); |
| } |
| |
| .theme-icon { |
| font-size: 16px; |
| } |
| |
| |
| .layout-select { |
| padding: 6px 12px; |
| border-radius: 6px; |
| border: 1px solid var(--border-color); |
| background: var(--bg-tertiary); |
| color: var(--text-primary); |
| font-size: 13px; |
| cursor: pointer; |
| } |
| |
| |
| .search-container { |
| position: relative; |
| } |
| |
| .search-input { |
| padding: 6px 12px 6px 32px; |
| border-radius: 20px; |
| border: 1px solid var(--border-color); |
| background: var(--bg-tertiary); |
| color: var(--text-primary); |
| font-size: 13px; |
| width: 200px; |
| } |
| |
| .search-input::placeholder { |
| color: var(--text-secondary); |
| } |
| |
| .search-icon { |
| position: absolute; |
| left: 10px; |
| top: 50%; |
| transform: translateY(-50%); |
| color: var(--text-secondary); |
| } |
| |
| |
| .main-content { |
| display: flex; |
| flex: 1; |
| overflow: hidden; |
| } |
| |
| |
| #cy { |
| flex: 1; |
| background: var(--graph-bg); |
| } |
| |
| |
| .side-panel { |
| width: 320px; |
| background: var(--bg-secondary); |
| border-left: 1px solid var(--border-color); |
| display: flex; |
| flex-direction: column; |
| overflow: hidden; |
| } |
| |
| .panel-section { |
| padding: 16px; |
| border-bottom: 1px solid var(--border-color); |
| } |
| |
| .panel-title { |
| font-size: 14px; |
| font-weight: 600; |
| color: var(--text-primary); |
| margin-bottom: 12px; |
| display: flex; |
| align-items: center; |
| gap: 8px; |
| } |
| |
| |
| .stats-grid { |
| display: grid; |
| grid-template-columns: repeat(2, 1fr); |
| gap: 12px; |
| } |
| |
| .stat-card { |
| background: var(--bg-tertiary); |
| padding: 12px; |
| border-radius: 8px; |
| text-align: center; |
| } |
| |
| .stat-value { |
| font-size: 24px; |
| font-weight: 700; |
| color: var(--accent-blue); |
| } |
| |
| .stat-value.cycle { |
| color: var(--accent-red); |
| } |
| |
| .stat-value.teal { |
| color: var(--accent-teal); |
| } |
| |
| .stat-value.orange { |
| color: var(--accent-orange); |
| } |
| |
| .stat-value.purple { |
| color: var(--accent-purple); |
| } |
| |
| .stat-label { |
| font-size: 11px; |
| color: var(--text-secondary); |
| margin-top: 4px; |
| text-transform: uppercase; |
| letter-spacing: 0.5px; |
| } |
| |
| |
| .legend { |
| display: flex; |
| flex-direction: column; |
| gap: 8px; |
| } |
| |
| .legend-item { |
| display: flex; |
| align-items: center; |
| gap: 10px; |
| font-size: 13px; |
| color: var(--text-secondary); |
| } |
| |
| .legend-color { |
| width: 16px; |
| height: 16px; |
| border-radius: 50%; |
| flex-shrink: 0; |
| } |
| |
| |
| .node-details { |
| flex: 1; |
| overflow-y: auto; |
| padding: 16px; |
| } |
| |
| .detail-placeholder { |
| text-align: center; |
| color: var(--text-secondary); |
| font-size: 13px; |
| padding: 40px 20px; |
| } |
| |
| .detail-content { |
| display: none; |
| } |
| |
| .detail-header { |
| margin-bottom: 16px; |
| } |
| |
| .detail-state-id { |
| font-family: 'Monaco', 'Menlo', monospace; |
| font-size: 14px; |
| color: var(--accent-blue); |
| word-break: break-all; |
| background: var(--bg-tertiary); |
| padding: 8px 12px; |
| border-radius: 6px; |
| } |
| |
| .detail-url { |
| font-size: 12px; |
| color: var(--text-secondary); |
| margin-top: 8px; |
| word-break: break-all; |
| } |
| |
| .detail-row { |
| display: flex; |
| justify-content: space-between; |
| padding: 8px 0; |
| border-bottom: 1px solid var(--border-color); |
| font-size: 13px; |
| } |
| |
| .detail-label { |
| color: var(--text-secondary); |
| } |
| |
| .detail-value { |
| font-weight: 500; |
| color: var(--text-primary); |
| } |
| |
| .badge { |
| display: inline-block; |
| padding: 2px 8px; |
| border-radius: 12px; |
| font-size: 11px; |
| font-weight: 500; |
| } |
| |
| .badge-root { |
| background: var(--accent-purple); |
| color: white; |
| } |
| |
| .badge-leaf { |
| background: var(--accent-green); |
| color: white; |
| } |
| |
| .badge-cycle { |
| background: var(--accent-red); |
| color: white; |
| } |
| |
| .actions-list { |
| margin-top: 12px; |
| } |
| |
| .actions-title { |
| font-size: 12px; |
| font-weight: 600; |
| color: var(--text-primary); |
| margin-bottom: 8px; |
| } |
| |
| .action-item { |
| font-size: 12px; |
| color: var(--text-secondary); |
| padding: 4px 8px; |
| background: var(--bg-tertiary); |
| border-radius: 4px; |
| margin-bottom: 4px; |
| word-break: break-all; |
| } |
| |
| |
| .detail-type-badge { |
| display: inline-block; |
| padding: 4px 12px; |
| border-radius: 4px; |
| font-size: 11px; |
| font-weight: 600; |
| text-transform: uppercase; |
| letter-spacing: 0.5px; |
| margin-bottom: 12px; |
| } |
| |
| .node-badge { |
| background: var(--accent-teal); |
| color: white; |
| } |
| |
| .edge-badge { |
| background: var(--accent-orange); |
| color: white; |
| } |
| |
| |
| .edge-flow { |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| gap: 12px; |
| padding: 16px; |
| background: var(--bg-tertiary); |
| border-radius: 8px; |
| margin-bottom: 16px; |
| } |
| |
| .edge-flow-node { |
| font-family: 'Monaco', 'Menlo', monospace; |
| font-size: 13px; |
| color: var(--accent-blue); |
| background: var(--bg-primary); |
| padding: 6px 12px; |
| border-radius: 6px; |
| border: 1px solid var(--border-color); |
| } |
| |
| .edge-flow-arrow { |
| font-size: 20px; |
| color: var(--accent-orange); |
| font-weight: bold; |
| } |
| |
| |
| .edge-section { |
| margin-top: 12px; |
| padding: 10px; |
| background: var(--bg-tertiary); |
| border-radius: 6px; |
| } |
| |
| .edge-section-title { |
| font-size: 11px; |
| font-weight: 600; |
| color: var(--text-secondary); |
| text-transform: uppercase; |
| letter-spacing: 0.5px; |
| margin-bottom: 6px; |
| } |
| |
| .edge-section-content { |
| font-size: 13px; |
| color: var(--text-primary); |
| word-break: break-all; |
| line-height: 1.5; |
| } |
| |
| .edge-section-content.code { |
| font-family: 'Monaco', 'Menlo', monospace; |
| font-size: 11px; |
| background: var(--bg-primary); |
| padding: 8px; |
| border-radius: 4px; |
| overflow-x: auto; |
| } |
| |
| |
| .btn.active { |
| background: var(--accent-blue); |
| border-color: var(--accent-blue); |
| color: white; |
| } |
| |
| |
| .footer { |
| padding: 10px 20px; |
| background: var(--bg-secondary); |
| border-top: 1px solid var(--border-color); |
| font-size: 12px; |
| color: var(--text-secondary); |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| } |
| |
| |
| .btn { |
| padding: 6px 14px; |
| border-radius: 6px; |
| border: 1px solid var(--border-color); |
| background: var(--bg-tertiary); |
| color: var(--text-primary); |
| font-size: 13px; |
| cursor: pointer; |
| display: flex; |
| align-items: center; |
| gap: 6px; |
| } |
| |
| .btn:hover { |
| background: var(--border-color); |
| } |
| |
| .btn-primary { |
| background: var(--accent-blue); |
| border-color: var(--accent-blue); |
| color: white; |
| } |
| |
| .btn-primary:hover { |
| opacity: 0.9; |
| } |
| |
| |
| .filter-chips { |
| display: flex; |
| flex-wrap: wrap; |
| gap: 6px; |
| margin-top: 8px; |
| } |
| |
| .chip { |
| padding: 4px 10px; |
| border-radius: 16px; |
| font-size: 12px; |
| cursor: pointer; |
| border: 1px solid var(--border-color); |
| background: var(--bg-tertiary); |
| color: var(--text-secondary); |
| } |
| |
| .chip.active { |
| background: var(--accent-blue); |
| border-color: var(--accent-blue); |
| color: white; |
| } |
| |
| .chip:hover:not(.active) { |
| background: var(--border-color); |
| } |
| |
| |
| @media (max-width: 768px) { |
| .side-panel { |
| display: none; |
| } |
| .toolbar { |
| padding: 10px; |
| } |
| .search-input { |
| width: 150px; |
| } |
| } |
| |
| |
| .modal-overlay { |
| display: none; |
| position: fixed; |
| top: 0; |
| left: 0; |
| width: 100%; |
| height: 100%; |
| background: rgba(0, 0, 0, 0.8); |
| z-index: 1000; |
| justify-content: center; |
| align-items: center; |
| } |
| |
| .modal-overlay.active { |
| display: flex; |
| } |
| |
| .modal-content { |
| background: var(--bg-primary); |
| border-radius: 12px; |
| max-width: 95vw; |
| max-height: 90vh; |
| overflow: hidden; |
| box-shadow: 0 20px 60px var(--shadow); |
| } |
| |
| .modal-header { |
| display: flex; |
| justify-content: space-between; |
| align-items: center; |
| padding: 16px 20px; |
| background: var(--bg-secondary); |
| border-bottom: 1px solid var(--border-color); |
| } |
| |
| .modal-title { |
| font-size: 16px; |
| font-weight: 600; |
| color: var(--text-primary); |
| } |
| |
| .modal-close { |
| background: none; |
| border: none; |
| font-size: 24px; |
| cursor: pointer; |
| color: var(--text-secondary); |
| padding: 4px 8px; |
| border-radius: 4px; |
| } |
| |
| .modal-close:hover { |
| background: var(--bg-tertiary); |
| color: var(--text-primary); |
| } |
| |
| .modal-body { |
| padding: 20px; |
| overflow-y: auto; |
| max-height: calc(90vh - 60px); |
| } |
| |
| .replay-container { |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| gap: 30px; |
| flex-wrap: wrap; |
| } |
| |
| .replay-state { |
| text-align: center; |
| max-width: 45%; |
| } |
| |
| .replay-state-label { |
| font-size: 12px; |
| font-weight: 600; |
| color: var(--text-secondary); |
| text-transform: uppercase; |
| letter-spacing: 0.5px; |
| margin-bottom: 8px; |
| } |
| |
| .replay-state-id { |
| font-family: 'Monaco', 'Menlo', monospace; |
| font-size: 11px; |
| color: var(--accent-blue); |
| margin-bottom: 12px; |
| } |
| |
| .replay-screenshot-container { |
| position: relative; |
| display: inline-block; |
| border: 2px solid var(--border-color); |
| border-radius: 8px; |
| overflow: hidden; |
| background: var(--bg-tertiary); |
| } |
| |
| .replay-screenshot { |
| max-width: 100%; |
| max-height: 400px; |
| display: block; |
| } |
| |
| .replay-screenshot.placeholder { |
| width: 300px; |
| height: 200px; |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| color: var(--text-secondary); |
| font-size: 14px; |
| } |
| |
| .click-marker { |
| position: absolute; |
| border: 3px solid #FF6B6B; |
| background: rgba(255, 107, 107, 0.3); |
| border-radius: 4px; |
| pointer-events: none; |
| animation: pulse 1.5s ease-in-out infinite; |
| } |
| |
| .click-marker::after { |
| content: '👆'; |
| position: absolute; |
| top: -30px; |
| left: 50%; |
| transform: translateX(-50%); |
| font-size: 20px; |
| } |
| |
| @keyframes pulse { |
| 0%, 100% { opacity: 1; transform: scale(1); } |
| 50% { opacity: 0.7; transform: scale(1.05); } |
| } |
| |
| .replay-arrow { |
| font-size: 48px; |
| color: var(--accent-orange); |
| flex-shrink: 0; |
| } |
| |
| .replay-action-info { |
| text-align: center; |
| margin-top: 20px; |
| padding: 16px; |
| background: var(--bg-secondary); |
| border-radius: 8px; |
| } |
| |
| .replay-action-type { |
| display: inline-block; |
| padding: 4px 12px; |
| background: var(--accent-orange); |
| color: white; |
| border-radius: 16px; |
| font-size: 12px; |
| font-weight: 600; |
| margin-bottom: 8px; |
| } |
| |
| .replay-action-desc { |
| font-size: 14px; |
| color: var(--text-primary); |
| } |
| |
| |
| .gallery-thumbnail { |
| width: 120px; |
| height: 80px; |
| object-fit: cover; |
| border-radius: 6px; |
| cursor: pointer; |
| border: 2px solid transparent; |
| transition: border-color 0.2s ease, transform 0.2s ease; |
| flex-shrink: 0; |
| } |
| |
| .gallery-thumbnail:hover { |
| transform: scale(1.05); |
| border-color: var(--accent-blue); |
| } |
| |
| .gallery-thumbnail.active { |
| border-color: var(--accent-orange); |
| box-shadow: 0 0 10px rgba(255, 167, 38, 0.5); |
| } |
| |
| .gallery-thumbnails::-webkit-scrollbar { |
| height: 8px; |
| } |
| |
| .gallery-thumbnails::-webkit-scrollbar-track { |
| background: var(--bg-tertiary); |
| border-radius: 4px; |
| } |
| |
| .gallery-thumbnails::-webkit-scrollbar-thumb { |
| background: var(--border-color); |
| border-radius: 4px; |
| } |
| |
| .gallery-thumbnails::-webkit-scrollbar-thumb:hover { |
| background: var(--text-secondary); |
| } |
| |
| .screenshot-badge { |
| display: inline-block; |
| padding: 2px 6px; |
| border-radius: 10px; |
| font-size: 10px; |
| background: var(--accent-teal); |
| color: white; |
| margin-left: 8px; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="container"> |
| |
| <div class="toolbar"> |
| <div class="toolbar-left"> |
| <span class="title">UTG Visualization</span> |
| <select class="layout-select" id="layoutSelect"> |
| <option value="cose">Force-Directed (CoSE)</option> |
| <option value="breadthfirst">Hierarchical</option> |
| <option value="circle">Circular</option> |
| <option value="grid">Grid</option> |
| <option value="concentric">Concentric</option> |
| </select> |
| </div> |
| <div class="toolbar-right"> |
| <div class="search-container"> |
| <span class="search-icon">🔍</span> |
| <input type="text" class="search-input" id="searchInput" placeholder="Search states..."> |
| </div> |
| <button class="btn" id="edgeLabelBtn" title="Toggle edge labels"> |
| <span id="edgeLabelIcon">🔗</span> |
| <span id="edgeLabelText">Labels</span> |
| </button> |
| <button class="btn" id="fitBtn">Fit View</button> |
| <button class="btn" id="exportBtn">Export PNG</button> |
| <div class="theme-toggle" id="themeToggle"> |
| <span class="theme-icon" id="themeIcon">☾</span> |
| <span id="themeText">Dark</span> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="main-content"> |
| |
| <div id="cy"></div> |
|
|
| |
| <div class="side-panel"> |
| |
| <div class="panel-section"> |
| <div class="panel-title">📊 Statistics</div> |
| <div class="stats-grid"> |
| <div class="stat-card"> |
| <div class="stat-value">1</div> |
| <div class="stat-label">States</div> |
| </div> |
| <div class="stat-card"> |
| <div class="stat-value teal">0</div> |
| <div class="stat-label">Transitions</div> |
| </div> |
| <div class="stat-card"> |
| <div class="stat-value cycle">0</div> |
| <div class="stat-label">Cycles</div> |
| </div> |
| <div class="stat-card"> |
| <div class="stat-value orange">0</div> |
| <div class="stat-label">Max Depth</div> |
| </div> |
| <div class="stat-card"> |
| <div class="stat-value purple">1</div> |
| <div class="stat-label">Entry Points</div> |
| </div> |
| <div class="stat-card"> |
| <div class="stat-value">0.0</div> |
| <div class="stat-label">Avg Actions</div> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="panel-section"> |
| <div class="panel-title">🎨 Legend</div> |
| <div class="legend"> |
| <div class="legend-item"> |
| <div class="legend-color" style="background: #4ECDC4;"></div> |
| <span>Regular State</span> |
| </div> |
| <div class="legend-item"> |
| <div class="legend-color" style="background: #FF6B6B;"></div> |
| <span>State in Cycle</span> |
| </div> |
| <div class="legend-item"> |
| <div class="legend-color" style="background: #9C27B0;"></div> |
| <span>Entry Point (Root)</span> |
| </div> |
| <div class="legend-item"> |
| <div class="legend-color" style="background: #66BB6A;"></div> |
| <span>Leaf State</span> |
| </div> |
| </div> |
| <div class="filter-chips"> |
| <div class="chip active" data-filter="all">All</div> |
| <div class="chip" data-filter="cycle">In Cycles</div> |
| <div class="chip" data-filter="root">Roots</div> |
| <div class="chip" data-filter="leaf">Leaves</div> |
| </div> |
| </div> |
|
|
| |
| <div class="node-details"> |
| <div class="detail-placeholder" id="detailPlaceholder"> |
| 👉 Click a node or edge to see details |
| </div> |
| |
| <div class="detail-content" id="nodeDetailContent"> |
| <div class="detail-type-badge node-badge">State</div> |
| <div class="detail-header"> |
| <div class="detail-state-id" id="detailStateId"></div> |
| <div class="detail-url" id="detailUrl"></div> |
| </div> |
| <div id="detailBadges" style="margin-bottom: 12px;"></div> |
| <div class="detail-row"> |
| <span class="detail-label">Depth</span> |
| <span class="detail-value" id="detailDepth"></span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">In-Degree</span> |
| <span class="detail-value" id="detailInDegree"></span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Out-Degree</span> |
| <span class="detail-value" id="detailOutDegree"></span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Actions Available</span> |
| <span class="detail-value" id="detailActions"></span> |
| </div> |
| <div class="actions-list" id="actionsList"> |
| <div class="actions-title">Available Actions:</div> |
| <div id="actionsContainer"></div> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Screenshots</span> |
| <span class="detail-value" id="detailScreenshotCount">0</span> |
| </div> |
| <button class="btn btn-primary" id="viewScreenshotBtn" style="width: 100%; margin-top: 16px; justify-content: center;"> |
| 📷 View Screenshot |
| </button> |
| <button class="btn" id="viewAllScreenshotsBtn" style="width: 100%; margin-top: 8px; justify-content: center;"> |
| 🖼 Browse All Screenshots |
| </button> |
| </div> |
| |
| <div class="detail-content" id="edgeDetailContent"> |
| <div class="detail-type-badge edge-badge">Transition</div> |
| <div class="edge-flow"> |
| <span class="edge-flow-node" id="edgeFromState"></span> |
| <span class="edge-flow-arrow">→</span> |
| <span class="edge-flow-node" id="edgeToState"></span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Action Type</span> |
| <span class="detail-value" id="edgeActionType"></span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Element Tag</span> |
| <span class="detail-value" id="edgeTag"></span> |
| </div> |
| <div class="edge-section" id="edgeDescSection"> |
| <div class="edge-section-title">Description</div> |
| <div class="edge-section-content" id="edgeDescription"></div> |
| </div> |
| <div class="edge-section" id="edgeSelectorSection"> |
| <div class="edge-section-title">CSS Selector</div> |
| <div class="edge-section-content code" id="edgeSelector"></div> |
| </div> |
| <div class="edge-section" id="edgeTextSection"> |
| <div class="edge-section-title">Element Text</div> |
| <div class="edge-section-content" id="edgeText"></div> |
| </div> |
| <div class="edge-section" id="edgeValueSection"> |
| <div class="edge-section-title">Input Value</div> |
| <div class="edge-section-content" id="edgeValue"></div> |
| </div> |
| <button class="btn btn-primary" id="replayBtn" style="width: 100%; margin-top: 16px; justify-content: center;"> |
| ▶ Replay Transition |
| </button> |
| </div> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="modal-overlay" id="replayModal"> |
| <div class="modal-content"> |
| <div class="modal-header"> |
| <span class="modal-title">📺 Transition Replay</span> |
| <button class="modal-close" id="modalClose">×</button> |
| </div> |
| <div class="modal-body"> |
| <div class="replay-container"> |
| <div class="replay-state"> |
| <div class="replay-state-label">From State</div> |
| <div class="replay-state-id" id="replayFromId"></div> |
| <div class="replay-screenshot-container" id="replayFromContainer"> |
| <img class="replay-screenshot" id="replayFromImg" src="" alt="Source state screenshot"> |
| <div class="click-marker" id="clickMarker"></div> |
| </div> |
| </div> |
| <div class="replay-arrow">➡</div> |
| <div class="replay-state"> |
| <div class="replay-state-label">To State</div> |
| <div class="replay-state-id" id="replayToId"></div> |
| <div class="replay-screenshot-container"> |
| <img class="replay-screenshot" id="replayToImg" src="" alt="Target state screenshot"> |
| </div> |
| </div> |
| </div> |
| <div class="replay-action-info"> |
| <span class="replay-action-type" id="replayActionType"></span> |
| <div class="replay-action-desc" id="replayActionDesc"></div> |
| </div> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="modal-overlay" id="screenshotModal"> |
| <div class="modal-content" style="max-width: 80vw;"> |
| <div class="modal-header"> |
| <span class="modal-title">📷 State Screenshot</span> |
| <button class="modal-close" id="screenshotModalClose">×</button> |
| </div> |
| <div class="modal-body" style="text-align: center;"> |
| <div class="replay-state-label" id="screenshotStateLabel">State</div> |
| <div class="replay-state-id" id="screenshotStateId"></div> |
| <div class="replay-screenshot-container" style="display: inline-block;"> |
| <img class="replay-screenshot" id="screenshotImg" src="" alt="State screenshot" style="max-height: 70vh;"> |
| </div> |
| <div class="detail-url" id="screenshotUrl" style="margin-top: 12px;"></div> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="modal-overlay" id="galleryModal"> |
| <div class="modal-content" style="max-width: 90vw; max-height: 90vh;"> |
| <div class="modal-header"> |
| <span class="modal-title">🖼 Screenshots Gallery</span> |
| <button class="modal-close" id="galleryModalClose">×</button> |
| </div> |
| <div class="modal-body" style="padding: 20px;"> |
| <div class="gallery-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;"> |
| <div> |
| <span class="replay-state-label">State:</span> |
| <span class="replay-state-id" id="galleryStateId"></span> |
| </div> |
| <div class="gallery-nav" style="display: flex; align-items: center; gap: 12px;"> |
| <button class="btn" id="galleryPrevBtn">◀ Prev</button> |
| <span id="galleryCounter" style="font-size: 14px; color: var(--text-secondary);">1 / 1</span> |
| <button class="btn" id="galleryNextBtn">Next ▶</button> |
| </div> |
| </div> |
| <div class="gallery-main" style="text-align: center; margin-bottom: 16px;"> |
| <div class="replay-screenshot-container" style="display: inline-block; max-width: 100%;"> |
| <img class="replay-screenshot" id="galleryImg" src="" alt="Screenshot" style="max-height: 60vh; max-width: 100%;"> |
| </div> |
| </div> |
| <div class="gallery-info" style="background: var(--bg-secondary); padding: 12px; border-radius: 8px;"> |
| <div class="detail-row"> |
| <span class="detail-label">Triggered by action</span> |
| <span class="detail-value" id="galleryAction">N/A</span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">From state</span> |
| <span class="detail-value" id="galleryFromState">N/A</span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Timestamp</span> |
| <span class="detail-value" id="galleryTimestamp">N/A</span> |
| </div> |
| <div class="detail-row"> |
| <span class="detail-label">Visit #</span> |
| <span class="detail-value" id="galleryVisitIndex">0</span> |
| </div> |
| </div> |
| <div class="gallery-thumbnails" id="galleryThumbnails" style="display: flex; gap: 8px; margin-top: 16px; overflow-x: auto; padding: 8px 0;"> |
| </div> |
| </div> |
| </div> |
| </div> |
|
|
| |
| <div class="footer"> |
| <span>Generated by Web UTG Crawler</span> |
| <span id="hoverInfo">Hover over nodes or edges to see details</span> |
| </div> |
| </div> |
|
|
| <script> |
| |
| const html = document.documentElement; |
| const themeToggle = document.getElementById('themeToggle'); |
| const themeIcon = document.getElementById('themeIcon'); |
| const themeText = document.getElementById('themeText'); |
| |
| |
| const savedTheme = localStorage.getItem('utg-theme') || 'light'; |
| html.setAttribute('data-theme', savedTheme); |
| updateThemeUI(savedTheme); |
| |
| themeToggle.addEventListener('click', () => { |
| const currentTheme = html.getAttribute('data-theme'); |
| const newTheme = currentTheme === 'dark' ? 'light' : 'dark'; |
| html.setAttribute('data-theme', newTheme); |
| localStorage.setItem('utg-theme', newTheme); |
| updateThemeUI(newTheme); |
| updateCyStyle(); |
| }); |
| |
| function updateThemeUI(theme) { |
| if (theme === 'dark') { |
| themeIcon.innerHTML = '☀'; |
| themeText.textContent = 'Light'; |
| } else { |
| themeIcon.innerHTML = '☾'; |
| themeText.textContent = 'Dark'; |
| } |
| } |
| |
| |
| const elements = [{"data": {"id": "state_e93a8ab532a87dd1", "label": "state_e9", "url": "https://www.bbb.org/", "actions": 0, "actionList": [], "inCycle": "no", "depth": 0, "inDegree": 0, "outDegree": 0, "isRoot": "yes", "isLeaf": "yes", "screenshotPath": "output/mind2web/bbb_org/20260129_202208/screenshots/state_e93a8ab532a87dd1.png", "screenshots": [{"path": "output/mind2web/bbb_org/20260129_202208/screenshots/state_e93a8ab532a87dd1.png", "timestamp": "2026-01-29T20:22:12.587456", "from_action": null, "visit_index": 0}], "screenshotCount": 1}}]; |
| let showEdgeLabels = false; |
| |
| function getCyStyle() { |
| const isDark = html.getAttribute('data-theme') === 'dark'; |
| return [ |
| { |
| selector: 'node', |
| style: { |
| 'content': 'data(label)', |
| 'text-valign': 'center', |
| 'text-halign': 'center', |
| 'background-color': function(ele) { |
| if (ele.data('isRoot') === 'yes') return '#9C27B0'; |
| if (ele.data('isLeaf') === 'yes') return '#66BB6A'; |
| if (ele.data('inCycle') === 'yes') return '#FF6B6B'; |
| return '#4ECDC4'; |
| }, |
| 'width': function(ele) { |
| const actions = ele.data('actions') || 0; |
| return Math.max(40, Math.min(80, 40 + actions * 2)) + 'px'; |
| }, |
| 'height': function(ele) { |
| const actions = ele.data('actions') || 0; |
| return Math.max(40, Math.min(80, 40 + actions * 2)) + 'px'; |
| }, |
| 'font-size': '10px', |
| 'color': '#fff', |
| 'text-outline-color': isDark ? '#1a1a2e' : '#333', |
| 'text-outline-width': 1, |
| 'border-width': 2, |
| 'border-color': isDark ? '#2d3748' : '#fff' |
| } |
| }, |
| { |
| selector: 'edge', |
| style: { |
| 'target-arrow-shape': 'triangle', |
| 'target-arrow-color': isDark ? '#5a6578' : '#666', |
| 'line-color': isDark ? '#5a6578' : '#999', |
| 'width': 2, |
| 'curve-style': 'bezier', |
| 'opacity': 0.7, |
| 'label': showEdgeLabels ? 'data(label)' : '', |
| 'font-size': '9px', |
| 'text-rotation': 'autorotate', |
| 'text-margin-y': -10, |
| 'color': isDark ? '#a0a0a0' : '#555', |
| 'text-background-color': isDark ? '#1a1a2e' : '#fff', |
| 'text-background-opacity': 0.8, |
| 'text-background-padding': '2px' |
| } |
| }, |
| { |
| selector: 'node:selected', |
| style: { |
| 'border-width': 4, |
| 'border-color': '#FFD700' |
| } |
| }, |
| { |
| selector: 'edge:selected', |
| style: { |
| 'line-color': '#FFA726', |
| 'target-arrow-color': '#FFA726', |
| 'width': 4, |
| 'opacity': 1, |
| 'label': 'data(label)', |
| 'font-size': '10px', |
| 'font-weight': 'bold', |
| 'color': isDark ? '#FFB74D' : '#E65100', |
| 'text-background-color': isDark ? '#1a1a2e' : '#fff', |
| 'text-background-opacity': 0.9 |
| } |
| }, |
| { |
| selector: '.highlighted', |
| style: { |
| 'background-color': '#FFD700', |
| 'transition-property': 'background-color', |
| 'transition-duration': '0.3s' |
| } |
| }, |
| { |
| selector: '.faded', |
| style: { |
| 'opacity': 0.2 |
| } |
| }, |
| { |
| selector: 'edge.highlighted-edge', |
| style: { |
| 'line-color': '#FFA726', |
| 'target-arrow-color': '#FFA726', |
| 'width': 3, |
| 'opacity': 1 |
| } |
| } |
| ]; |
| } |
| |
| var cy = cytoscape({ |
| container: document.getElementById('cy'), |
| elements: elements, |
| style: getCyStyle(), |
| layout: { |
| name: 'cose', |
| animate: true, |
| animationDuration: 500, |
| nodeRepulsion: 8000, |
| idealEdgeLength: 100 |
| } |
| }); |
| |
| function updateCyStyle() { |
| cy.style(getCyStyle()); |
| } |
| |
| |
| document.getElementById('layoutSelect').addEventListener('change', function(e) { |
| const layoutName = e.target.value; |
| let layoutOptions = { name: layoutName, animate: true, animationDuration: 500 }; |
| |
| if (layoutName === 'breadthfirst') { |
| layoutOptions.directed = true; |
| layoutOptions.spacingFactor = 1.5; |
| } else if (layoutName === 'concentric') { |
| layoutOptions.concentric = function(node) { |
| return node.data('depth') !== undefined ? -node.data('depth') : 0; |
| }; |
| layoutOptions.levelWidth = function() { return 2; }; |
| } else if (layoutName === 'cose') { |
| layoutOptions.nodeRepulsion = 8000; |
| layoutOptions.idealEdgeLength = 100; |
| } |
| |
| cy.layout(layoutOptions).run(); |
| }); |
| |
| |
| document.getElementById('searchInput').addEventListener('input', function(e) { |
| const query = e.target.value.toLowerCase(); |
| if (!query) { |
| cy.elements().removeClass('faded highlighted'); |
| return; |
| } |
| |
| cy.elements().addClass('faded'); |
| cy.nodes().forEach(node => { |
| const id = node.data('id').toLowerCase(); |
| const url = (node.data('url') || '').toLowerCase(); |
| if (id.includes(query) || url.includes(query)) { |
| node.removeClass('faded').addClass('highlighted'); |
| node.connectedEdges().removeClass('faded'); |
| node.neighborhood('node').removeClass('faded'); |
| } |
| }); |
| }); |
| |
| |
| document.getElementById('fitBtn').addEventListener('click', function() { |
| cy.fit(undefined, 50); |
| }); |
| |
| |
| document.getElementById('exportBtn').addEventListener('click', function() { |
| const png = cy.png({ scale: 2, bg: html.getAttribute('data-theme') === 'dark' ? '#0d1b2a' : '#f8f9fa' }); |
| const link = document.createElement('a'); |
| link.download = 'utg_graph.png'; |
| link.href = png; |
| link.click(); |
| }); |
| |
| |
| const edgeLabelBtn = document.getElementById('edgeLabelBtn'); |
| edgeLabelBtn.addEventListener('click', function() { |
| showEdgeLabels = !showEdgeLabels; |
| this.classList.toggle('active', showEdgeLabels); |
| updateCyStyle(); |
| }); |
| |
| |
| document.querySelectorAll('.chip').forEach(chip => { |
| chip.addEventListener('click', function() { |
| document.querySelectorAll('.chip').forEach(c => c.classList.remove('active')); |
| this.classList.add('active'); |
| |
| const filter = this.dataset.filter; |
| cy.elements().removeClass('faded'); |
| |
| if (filter === 'all') return; |
| |
| cy.nodes().forEach(node => { |
| let match = false; |
| if (filter === 'cycle' && node.data('inCycle') === 'yes') match = true; |
| if (filter === 'root' && node.data('isRoot') === 'yes') match = true; |
| if (filter === 'leaf' && node.data('isLeaf') === 'yes') match = true; |
| |
| if (!match) { |
| node.addClass('faded'); |
| node.connectedEdges().addClass('faded'); |
| } |
| }); |
| }); |
| }); |
| |
| |
| function hideAllDetails() { |
| document.getElementById('detailPlaceholder').style.display = 'block'; |
| document.getElementById('nodeDetailContent').style.display = 'none'; |
| document.getElementById('edgeDetailContent').style.display = 'none'; |
| } |
| |
| |
| let currentNodeData = null; |
| |
| |
| cy.on('dblclick', 'node', function(evt) { |
| const node = evt.target; |
| const data = node.data(); |
| currentNodeData = data; |
| |
| |
| if (data.screenshotCount > 1) { |
| viewAllScreenshotsBtn.click(); |
| } else { |
| viewScreenshotBtn.click(); |
| } |
| }); |
| |
| |
| cy.on('tap', 'node', function(evt) { |
| const node = evt.target; |
| const data = node.data(); |
| |
| |
| currentNodeData = data; |
| |
| document.getElementById('detailPlaceholder').style.display = 'none'; |
| document.getElementById('nodeDetailContent').style.display = 'block'; |
| document.getElementById('edgeDetailContent').style.display = 'none'; |
| |
| document.getElementById('detailStateId').textContent = data.id; |
| document.getElementById('detailUrl').textContent = data.url || 'N/A'; |
| document.getElementById('detailDepth').textContent = data.depth; |
| document.getElementById('detailInDegree').textContent = data.inDegree; |
| document.getElementById('detailOutDegree').textContent = data.outDegree; |
| document.getElementById('detailActions').textContent = data.actions; |
| document.getElementById('detailScreenshotCount').textContent = data.screenshotCount || 0; |
| |
| |
| const galleryBtn = document.getElementById('viewAllScreenshotsBtn'); |
| if (data.screenshotCount > 1) { |
| galleryBtn.style.display = 'flex'; |
| galleryBtn.textContent = `📂 Browse All Screenshots (${data.screenshotCount})`; |
| } else { |
| galleryBtn.style.display = 'none'; |
| } |
| |
| |
| let badges = ''; |
| if (data.isRoot === 'yes') badges += '<span class="badge badge-root">Entry Point</span> '; |
| if (data.isLeaf === 'yes') badges += '<span class="badge badge-leaf">Leaf</span> '; |
| if (data.inCycle === 'yes') badges += '<span class="badge badge-cycle">In Cycle</span> '; |
| document.getElementById('detailBadges').innerHTML = badges; |
| |
| |
| const actionsList = data.actionList || []; |
| const container = document.getElementById('actionsContainer'); |
| if (actionsList.length > 0) { |
| container.innerHTML = actionsList.map(a => `<div class="action-item">${a}</div>`).join(''); |
| document.getElementById('actionsList').style.display = 'block'; |
| } else { |
| document.getElementById('actionsList').style.display = 'none'; |
| } |
| }); |
| |
| |
| let currentEdgeData = null; |
| |
| |
| cy.on('dblclick', 'edge', function(evt) { |
| const edge = evt.target; |
| currentEdgeData = edge.data(); |
| replayBtn.click(); |
| }); |
| |
| |
| cy.on('tap', 'edge', function(evt) { |
| const edge = evt.target; |
| const data = edge.data(); |
| |
| |
| currentEdgeData = data; |
| |
| document.getElementById('detailPlaceholder').style.display = 'none'; |
| document.getElementById('nodeDetailContent').style.display = 'none'; |
| document.getElementById('edgeDetailContent').style.display = 'block'; |
| |
| |
| document.getElementById('edgeFromState').textContent = data.fromStateLabel || data.source.substring(0, 8); |
| document.getElementById('edgeToState').textContent = data.toStateLabel || data.target.substring(0, 8); |
| |
| |
| document.getElementById('edgeActionType').textContent = data.actionType || 'unknown'; |
| document.getElementById('edgeTag').textContent = data.tag || 'N/A'; |
| |
| |
| const descSection = document.getElementById('edgeDescSection'); |
| if (data.fullLabel) { |
| document.getElementById('edgeDescription').textContent = data.fullLabel; |
| descSection.style.display = 'block'; |
| } else { |
| descSection.style.display = 'none'; |
| } |
| |
| |
| const selectorSection = document.getElementById('edgeSelectorSection'); |
| if (data.selector) { |
| document.getElementById('edgeSelector').textContent = data.selector; |
| selectorSection.style.display = 'block'; |
| } else { |
| selectorSection.style.display = 'none'; |
| } |
| |
| |
| const textSection = document.getElementById('edgeTextSection'); |
| if (data.text) { |
| document.getElementById('edgeText').textContent = data.text; |
| textSection.style.display = 'block'; |
| } else { |
| textSection.style.display = 'none'; |
| } |
| |
| |
| const valueSection = document.getElementById('edgeValueSection'); |
| if (data.inputValue) { |
| document.getElementById('edgeValue').textContent = data.inputValue; |
| valueSection.style.display = 'block'; |
| } else { |
| valueSection.style.display = 'none'; |
| } |
| }); |
| |
| |
| cy.on('tap', function(evt) { |
| if (evt.target === cy) { |
| hideAllDetails(); |
| } |
| }); |
| |
| |
| cy.on('mouseover', 'node', function(evt) { |
| const url = evt.target.data('url'); |
| document.getElementById('hoverInfo').textContent = url || 'No URL'; |
| }); |
| |
| cy.on('mouseout', 'node', function() { |
| document.getElementById('hoverInfo').textContent = 'Hover over nodes or edges to see details'; |
| }); |
| |
| |
| cy.on('mouseover', 'edge', function(evt) { |
| const data = evt.target.data(); |
| const info = data.fullLabel || data.label || 'No description'; |
| document.getElementById('hoverInfo').textContent = `${data.actionType}: ${info}`; |
| }); |
| |
| cy.on('mouseout', 'edge', function() { |
| document.getElementById('hoverInfo').textContent = 'Hover over nodes or edges to see details'; |
| }); |
| |
| |
| const stateScreenshots = {}; |
| elements.forEach(el => { |
| if (el.data && el.data.screenshotPath) { |
| stateScreenshots[el.data.id] = el.data.screenshotPath; |
| } |
| }); |
| |
| |
| const replayModal = document.getElementById('replayModal'); |
| const replayBtn = document.getElementById('replayBtn'); |
| const modalClose = document.getElementById('modalClose'); |
| |
| replayBtn.addEventListener('click', function() { |
| if (!currentEdgeData) return; |
| |
| const fromState = currentEdgeData.source; |
| const toState = currentEdgeData.target; |
| |
| |
| const fromScreenshot = stateScreenshots[fromState] || ''; |
| |
| const toScreenshot = currentEdgeData.transitionScreenshot || stateScreenshots[toState] || ''; |
| |
| |
| document.getElementById('replayFromId').textContent = fromState; |
| document.getElementById('replayToId').textContent = toState; |
| |
| const fromImg = document.getElementById('replayFromImg'); |
| const toImg = document.getElementById('replayToImg'); |
| |
| |
| if (fromScreenshot) { |
| |
| const fromPath = fromScreenshot.split('/').slice(-2).join('/'); |
| fromImg.src = fromPath; |
| fromImg.style.display = 'block'; |
| fromImg.onerror = function() { |
| this.style.display = 'none'; |
| this.parentElement.innerHTML = '<div class="replay-screenshot placeholder">Screenshot not found</div>'; |
| }; |
| } else { |
| fromImg.parentElement.innerHTML = '<div class="replay-screenshot placeholder">No screenshot available</div>'; |
| } |
| |
| if (toScreenshot) { |
| const toPath = toScreenshot.split('/').slice(-2).join('/'); |
| toImg.src = toPath; |
| toImg.style.display = 'block'; |
| toImg.onerror = function() { |
| this.style.display = 'none'; |
| this.parentElement.innerHTML = '<div class="replay-screenshot placeholder">Screenshot not found</div>'; |
| }; |
| } else { |
| toImg.parentElement.innerHTML = '<div class="replay-screenshot placeholder">No screenshot available</div>'; |
| } |
| |
| |
| const clickMarker = document.getElementById('clickMarker'); |
| const clickX = currentEdgeData.clickX || 0; |
| const clickY = currentEdgeData.clickY || 0; |
| const clickWidth = currentEdgeData.clickWidth || 40; |
| const clickHeight = currentEdgeData.clickHeight || 20; |
| |
| if (clickX > 0 || clickY > 0) { |
| |
| fromImg.onload = function() { |
| const imgRect = fromImg.getBoundingClientRect(); |
| const containerRect = fromImg.parentElement.getBoundingClientRect(); |
| |
| |
| const scaleX = imgRect.width / 1920; |
| const scaleY = imgRect.height / 1080; |
| |
| |
| clickMarker.style.left = (clickX * scaleX) + 'px'; |
| clickMarker.style.top = (clickY * scaleY) + 'px'; |
| clickMarker.style.width = (clickWidth * scaleX) + 'px'; |
| clickMarker.style.height = (clickHeight * scaleY) + 'px'; |
| clickMarker.style.display = 'block'; |
| }; |
| } else { |
| clickMarker.style.display = 'none'; |
| } |
| |
| |
| document.getElementById('replayActionType').textContent = currentEdgeData.actionType || 'unknown'; |
| document.getElementById('replayActionDesc').textContent = currentEdgeData.fullLabel || currentEdgeData.label || 'No description'; |
| |
| |
| replayModal.classList.add('active'); |
| }); |
| |
| |
| modalClose.addEventListener('click', function() { |
| replayModal.classList.remove('active'); |
| }); |
| |
| replayModal.addEventListener('click', function(e) { |
| if (e.target === replayModal) { |
| replayModal.classList.remove('active'); |
| } |
| }); |
| |
| |
| document.addEventListener('keydown', function(e) { |
| if (e.key === 'Escape') { |
| if (replayModal.classList.contains('active')) { |
| replayModal.classList.remove('active'); |
| } |
| if (screenshotModal.classList.contains('active')) { |
| screenshotModal.classList.remove('active'); |
| } |
| if (galleryModal.classList.contains('active')) { |
| galleryModal.classList.remove('active'); |
| } |
| } |
| }); |
| |
| |
| const screenshotModal = document.getElementById('screenshotModal'); |
| const viewScreenshotBtn = document.getElementById('viewScreenshotBtn'); |
| const screenshotModalClose = document.getElementById('screenshotModalClose'); |
| |
| viewScreenshotBtn.addEventListener('click', function() { |
| if (!currentNodeData) return; |
| |
| const stateId = currentNodeData.id; |
| const screenshotPath = currentNodeData.screenshotPath || ''; |
| const url = currentNodeData.url || 'N/A'; |
| |
| |
| document.getElementById('screenshotStateId').textContent = stateId; |
| document.getElementById('screenshotUrl').textContent = url; |
| |
| const screenshotImg = document.getElementById('screenshotImg'); |
| |
| if (screenshotPath) { |
| |
| const imgPath = screenshotPath.split('/').slice(-2).join('/'); |
| screenshotImg.src = imgPath; |
| screenshotImg.style.display = 'block'; |
| screenshotImg.onerror = function() { |
| this.style.display = 'none'; |
| this.parentElement.innerHTML = '<div class="replay-screenshot placeholder">Screenshot not found<br><small>' + screenshotPath + '</small></div>'; |
| }; |
| } else { |
| screenshotImg.parentElement.innerHTML = '<div class="replay-screenshot placeholder">No screenshot available</div>'; |
| } |
| |
| |
| screenshotModal.classList.add('active'); |
| }); |
| |
| |
| screenshotModalClose.addEventListener('click', function() { |
| screenshotModal.classList.remove('active'); |
| }); |
| |
| screenshotModal.addEventListener('click', function(e) { |
| if (e.target === screenshotModal) { |
| screenshotModal.classList.remove('active'); |
| } |
| }); |
| |
| |
| const galleryModal = document.getElementById('galleryModal'); |
| const viewAllScreenshotsBtn = document.getElementById('viewAllScreenshotsBtn'); |
| const galleryModalClose = document.getElementById('galleryModalClose'); |
| const galleryPrevBtn = document.getElementById('galleryPrevBtn'); |
| const galleryNextBtn = document.getElementById('galleryNextBtn'); |
| |
| let currentGalleryIndex = 0; |
| let currentGalleryScreenshots = []; |
| |
| function updateGalleryDisplay() { |
| if (currentGalleryScreenshots.length === 0) return; |
| |
| const screenshot = currentGalleryScreenshots[currentGalleryIndex]; |
| const galleryImg = document.getElementById('galleryImg'); |
| |
| |
| const imgPath = (screenshot.path || '').split('/').slice(-2).join('/'); |
| galleryImg.src = imgPath; |
| galleryImg.onerror = function() { |
| this.style.display = 'none'; |
| this.parentElement.innerHTML = '<div class="replay-screenshot placeholder">Screenshot not found</div>'; |
| }; |
| |
| |
| document.getElementById('galleryCounter').textContent = `${currentGalleryIndex + 1} / ${currentGalleryScreenshots.length}`; |
| |
| |
| document.getElementById('galleryAction').textContent = screenshot.from_action || 'Initial state'; |
| document.getElementById('galleryFromState').textContent = screenshot.from_state ? screenshot.from_state.substring(0, 16) : 'N/A'; |
| document.getElementById('galleryTimestamp').textContent = screenshot.timestamp || 'N/A'; |
| document.getElementById('galleryVisitIndex').textContent = screenshot.visit_index !== undefined ? screenshot.visit_index : 'N/A'; |
| |
| |
| const thumbnails = document.querySelectorAll('.gallery-thumbnail'); |
| thumbnails.forEach((thumb, idx) => { |
| thumb.classList.toggle('active', idx === currentGalleryIndex); |
| }); |
| |
| |
| galleryPrevBtn.disabled = currentGalleryIndex === 0; |
| galleryNextBtn.disabled = currentGalleryIndex === currentGalleryScreenshots.length - 1; |
| } |
| |
| function buildGalleryThumbnails() { |
| const container = document.getElementById('galleryThumbnails'); |
| container.innerHTML = ''; |
| |
| currentGalleryScreenshots.forEach((screenshot, idx) => { |
| const imgPath = (screenshot.path || '').split('/').slice(-2).join('/'); |
| const img = document.createElement('img'); |
| img.className = 'gallery-thumbnail' + (idx === currentGalleryIndex ? ' active' : ''); |
| img.src = imgPath; |
| img.alt = `Screenshot ${idx + 1}`; |
| img.title = screenshot.from_action || 'Initial state'; |
| img.onerror = function() { |
| this.src = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="80"><rect fill="%23333" width="120" height="80"/><text fill="%23999" font-size="12" x="50%" y="50%" dominant-baseline="middle" text-anchor="middle">N/A</text></svg>'; |
| }; |
| img.addEventListener('click', () => { |
| currentGalleryIndex = idx; |
| updateGalleryDisplay(); |
| }); |
| container.appendChild(img); |
| }); |
| } |
| |
| viewAllScreenshotsBtn.addEventListener('click', function() { |
| if (!currentNodeData || !currentNodeData.screenshots) return; |
| |
| currentGalleryScreenshots = currentNodeData.screenshots; |
| currentGalleryIndex = 0; |
| |
| document.getElementById('galleryStateId').textContent = currentNodeData.id; |
| |
| buildGalleryThumbnails(); |
| updateGalleryDisplay(); |
| |
| galleryModal.classList.add('active'); |
| }); |
| |
| galleryPrevBtn.addEventListener('click', function() { |
| if (currentGalleryIndex > 0) { |
| currentGalleryIndex--; |
| updateGalleryDisplay(); |
| } |
| }); |
| |
| galleryNextBtn.addEventListener('click', function() { |
| if (currentGalleryIndex < currentGalleryScreenshots.length - 1) { |
| currentGalleryIndex++; |
| updateGalleryDisplay(); |
| } |
| }); |
| |
| |
| document.addEventListener('keydown', function(e) { |
| if (galleryModal.classList.contains('active')) { |
| if (e.key === 'ArrowLeft') { |
| galleryPrevBtn.click(); |
| } else if (e.key === 'ArrowRight') { |
| galleryNextBtn.click(); |
| } |
| } |
| }); |
| |
| |
| galleryModalClose.addEventListener('click', function() { |
| galleryModal.classList.remove('active'); |
| }); |
| |
| galleryModal.addEventListener('click', function(e) { |
| if (e.target === galleryModal) { |
| galleryModal.classList.remove('active'); |
| } |
| }); |
| </script> |
| </body> |
| </html> |