mind2web-utg-crawl / bbb_org /20260129_202208 /utg_interactive.html
PHY041's picture
Add files using upload-large-folder tool
7f45827 verified
<!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%;
}
/* Header / Toolbar */
.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 */
.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 Selector */
.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 */
.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 */
.main-content {
display: flex;
flex: 1;
overflow: hidden;
}
/* Graph Container */
#cy {
flex: 1;
background: var(--graph-bg);
}
/* Side Panel */
.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;
}
/* Statistics Grid */
.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 */
.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 */
.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 */
.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 */
.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 */
.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;
}
/* Active button state */
.btn.active {
background: var(--accent-blue);
border-color: var(--accent-blue);
color: white;
}
/* Footer */
.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;
}
/* Buttons */
.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 */
.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);
}
/* Responsive */
@media (max-width: 768px) {
.side-panel {
display: none;
}
.toolbar {
padding: 10px;
}
.search-input {
width: 150px;
}
}
/* Replay Modal */
.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 Thumbnails */
.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">
<!-- Toolbar -->
<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">&#128269;</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">&#128279;</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">&#9790;</span>
<span id="themeText">Dark</span>
</div>
</div>
</div>
<!-- Main Content -->
<div class="main-content">
<!-- Graph -->
<div id="cy"></div>
<!-- Side Panel -->
<div class="side-panel">
<!-- Statistics -->
<div class="panel-section">
<div class="panel-title">&#128202; 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>
<!-- Legend -->
<div class="panel-section">
<div class="panel-title">&#127912; 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>
<!-- Details Panel -->
<div class="node-details">
<div class="detail-placeholder" id="detailPlaceholder">
&#128073; Click a node or edge to see details
</div>
<!-- Node Details -->
<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;">
&#128247; View Screenshot
</button>
<button class="btn" id="viewAllScreenshotsBtn" style="width: 100%; margin-top: 8px; justify-content: center;">
&#128444; Browse All Screenshots
</button>
</div>
<!-- Edge Details -->
<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">&#8594;</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;">
&#9654; Replay Transition
</button>
</div>
</div>
</div>
</div>
<!-- Replay Modal -->
<div class="modal-overlay" id="replayModal">
<div class="modal-content">
<div class="modal-header">
<span class="modal-title">&#128250; Transition Replay</span>
<button class="modal-close" id="modalClose">&times;</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">&#10145;</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>
<!-- Screenshot Modal -->
<div class="modal-overlay" id="screenshotModal">
<div class="modal-content" style="max-width: 80vw;">
<div class="modal-header">
<span class="modal-title">&#128247; State Screenshot</span>
<button class="modal-close" id="screenshotModalClose">&times;</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>
<!-- Screenshots Gallery Modal -->
<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">&#128444; Screenshots Gallery</span>
<button class="modal-close" id="galleryModalClose">&times;</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">&#9664; Prev</button>
<span id="galleryCounter" style="font-size: 14px; color: var(--text-secondary);">1 / 1</span>
<button class="btn" id="galleryNextBtn">Next &#9654;</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>
<!-- Footer -->
<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>
// Theme Management
const html = document.documentElement;
const themeToggle = document.getElementById('themeToggle');
const themeIcon = document.getElementById('themeIcon');
const themeText = document.getElementById('themeText');
// Check for saved theme preference or default to light
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 = '&#9728;'; // Sun
themeText.textContent = 'Light';
} else {
themeIcon.innerHTML = '&#9790;'; // Moon
themeText.textContent = 'Dark';
}
}
// Cytoscape initialization
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; // Edge label toggle state
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());
}
// Layout selection
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();
});
// Search functionality
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');
}
});
});
// Fit view button
document.getElementById('fitBtn').addEventListener('click', function() {
cy.fit(undefined, 50);
});
// Export PNG
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();
});
// Edge label toggle
const edgeLabelBtn = document.getElementById('edgeLabelBtn');
edgeLabelBtn.addEventListener('click', function() {
showEdgeLabels = !showEdgeLabels;
this.classList.toggle('active', showEdgeLabels);
updateCyStyle();
});
// Filter chips
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');
}
});
});
});
// Helper function to hide all detail panels
function hideAllDetails() {
document.getElementById('detailPlaceholder').style.display = 'block';
document.getElementById('nodeDetailContent').style.display = 'none';
document.getElementById('edgeDetailContent').style.display = 'none';
}
// Store currently selected node data for screenshot view
let currentNodeData = null;
// Node double-click - open screenshot viewer/gallery
cy.on('dblclick', 'node', function(evt) {
const node = evt.target;
const data = node.data();
currentNodeData = data;
// If multiple screenshots, open gallery; otherwise open single screenshot
if (data.screenshotCount > 1) {
viewAllScreenshotsBtn.click();
} else {
viewScreenshotBtn.click();
}
});
// Node click - show node details
cy.on('tap', 'node', function(evt) {
const node = evt.target;
const data = node.data();
// Store for screenshot functionality
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;
// Show/hide gallery button based on screenshot count
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';
}
// Badges
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;
// Actions list
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';
}
});
// Store currently selected edge data for replay
let currentEdgeData = null;
// Edge double-click - open replay modal
cy.on('dblclick', 'edge', function(evt) {
const edge = evt.target;
currentEdgeData = edge.data();
replayBtn.click();
});
// Edge click - show edge details
cy.on('tap', 'edge', function(evt) {
const edge = evt.target;
const data = edge.data();
// Store for replay functionality
currentEdgeData = data;
document.getElementById('detailPlaceholder').style.display = 'none';
document.getElementById('nodeDetailContent').style.display = 'none';
document.getElementById('edgeDetailContent').style.display = 'block';
// Flow display
document.getElementById('edgeFromState').textContent = data.fromStateLabel || data.source.substring(0, 8);
document.getElementById('edgeToState').textContent = data.toStateLabel || data.target.substring(0, 8);
// Basic info
document.getElementById('edgeActionType').textContent = data.actionType || 'unknown';
document.getElementById('edgeTag').textContent = data.tag || 'N/A';
// Description section
const descSection = document.getElementById('edgeDescSection');
if (data.fullLabel) {
document.getElementById('edgeDescription').textContent = data.fullLabel;
descSection.style.display = 'block';
} else {
descSection.style.display = 'none';
}
// Selector section
const selectorSection = document.getElementById('edgeSelectorSection');
if (data.selector) {
document.getElementById('edgeSelector').textContent = data.selector;
selectorSection.style.display = 'block';
} else {
selectorSection.style.display = 'none';
}
// Text section
const textSection = document.getElementById('edgeTextSection');
if (data.text) {
document.getElementById('edgeText').textContent = data.text;
textSection.style.display = 'block';
} else {
textSection.style.display = 'none';
}
// Value section (for input actions)
const valueSection = document.getElementById('edgeValueSection');
if (data.inputValue) {
document.getElementById('edgeValue').textContent = data.inputValue;
valueSection.style.display = 'block';
} else {
valueSection.style.display = 'none';
}
});
// Click background to deselect
cy.on('tap', function(evt) {
if (evt.target === cy) {
hideAllDetails();
}
});
// Hover info for nodes
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';
});
// Hover info for edges
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';
});
// Build a map of state IDs to screenshot paths
const stateScreenshots = {};
elements.forEach(el => {
if (el.data && el.data.screenshotPath) {
stateScreenshots[el.data.id] = el.data.screenshotPath;
}
});
// Replay Modal functionality
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;
// Get screenshot paths - prefer transition-specific screenshot for target
const fromScreenshot = stateScreenshots[fromState] || '';
// Use transition screenshot if available, otherwise fall back to state screenshot
const toScreenshot = currentEdgeData.transitionScreenshot || stateScreenshots[toState] || '';
// Update modal content
document.getElementById('replayFromId').textContent = fromState;
document.getElementById('replayToId').textContent = toState;
const fromImg = document.getElementById('replayFromImg');
const toImg = document.getElementById('replayToImg');
// Handle screenshots - convert absolute paths to relative
if (fromScreenshot) {
// Extract just the filename portion for relative path
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>';
}
// Show click marker on source screenshot
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) {
// Wait for image to load to calculate position
fromImg.onload = function() {
const imgRect = fromImg.getBoundingClientRect();
const containerRect = fromImg.parentElement.getBoundingClientRect();
// Calculate scale factor (assuming original screenshot was taken at a known size)
const scaleX = imgRect.width / 1920; // Assuming 1920px original width
const scaleY = imgRect.height / 1080; // Assuming 1080px original height
// Position the marker
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';
}
// Update action info
document.getElementById('replayActionType').textContent = currentEdgeData.actionType || 'unknown';
document.getElementById('replayActionDesc').textContent = currentEdgeData.fullLabel || currentEdgeData.label || 'No description';
// Show modal
replayModal.classList.add('active');
});
// Close modal handlers
modalClose.addEventListener('click', function() {
replayModal.classList.remove('active');
});
replayModal.addEventListener('click', function(e) {
if (e.target === replayModal) {
replayModal.classList.remove('active');
}
});
// Close modal with Escape key
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');
}
}
});
// Screenshot Modal functionality
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';
// Update modal content
document.getElementById('screenshotStateId').textContent = stateId;
document.getElementById('screenshotUrl').textContent = url;
const screenshotImg = document.getElementById('screenshotImg');
if (screenshotPath) {
// Extract relative path for HTML
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>';
}
// Show modal
screenshotModal.classList.add('active');
});
// Close screenshot modal handlers
screenshotModalClose.addEventListener('click', function() {
screenshotModal.classList.remove('active');
});
screenshotModal.addEventListener('click', function(e) {
if (e.target === screenshotModal) {
screenshotModal.classList.remove('active');
}
});
// Gallery Modal functionality
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');
// Extract relative path for HTML
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>';
};
// Update counter
document.getElementById('galleryCounter').textContent = `${currentGalleryIndex + 1} / ${currentGalleryScreenshots.length}`;
// Update info
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';
// Update thumbnails
const thumbnails = document.querySelectorAll('.gallery-thumbnail');
thumbnails.forEach((thumb, idx) => {
thumb.classList.toggle('active', idx === currentGalleryIndex);
});
// Update navigation buttons
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();
}
});
// Keyboard navigation for gallery
document.addEventListener('keydown', function(e) {
if (galleryModal.classList.contains('active')) {
if (e.key === 'ArrowLeft') {
galleryPrevBtn.click();
} else if (e.key === 'ArrowRight') {
galleryNextBtn.click();
}
}
});
// Close gallery modal handlers
galleryModalClose.addEventListener('click', function() {
galleryModal.classList.remove('active');
});
galleryModal.addEventListener('click', function(e) {
if (e.target === galleryModal) {
galleryModal.classList.remove('active');
}
});
</script>
</body>
</html>