bowser/assets/pages/dom_graph.html

236 lines
6.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Graph Visualization</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'SF Mono', Monaco, monospace;
background: #1e1e1e;
color: #d4d4d4;
min-height: 100vh;
display: flex;
flex-direction: column;
}
.header {
background: #2d2d2d;
padding: 16px 24px;
border-bottom: 1px solid #3e3e3e;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header h1 {
font-size: 20px;
font-weight: 600;
color: #4ec9b0;
margin-bottom: 8px;
}
.header .info {
font-size: 13px;
color: #858585;
font-family: 'SF Mono', Monaco, monospace;
}
.container {
flex: 1;
padding: 24px;
overflow: auto;
}
.graph-wrapper {
background: white;
border-radius: 8px;
padding: 24px;
box-shadow: 0 4px 12px rgba(0,0,0,0.4);
display: inline-block;
min-width: 100%;
}
.graph-wrapper svg {
max-width: 100%;
height: auto;
}
.dot-content {
background: #2d2d2d;
border: 1px solid #3e3e3e;
border-radius: 8px;
padding: 20px;
font-family: 'SF Mono', Monaco, 'Courier New', monospace;
font-size: 13px;
line-height: 1.6;
overflow-x: auto;
color: #d4d4d4;
white-space: pre;
}
.dot-content::before {
content: "DOT Graph Definition:";
display: block;
color: #4ec9b0;
font-weight: 600;
margin-bottom: 16px;
font-size: 14px;
}
.error {
background: #f14c4c;
color: white;
padding: 16px 24px;
border-radius: 8px;
margin: 24px;
font-size: 14px;
box-shadow: 0 4px 12px rgba(241, 76, 76, 0.3);
}
.error::before {
content: "⚠ ";
font-size: 18px;
}
.install-note {
background: #0e639c;
color: white;
padding: 16px 24px;
border-radius: 8px;
margin: 24px;
font-size: 14px;
line-height: 1.6;
box-shadow: 0 4px 12px rgba(14, 99, 156, 0.3);
}
.install-note strong {
display: block;
margin-bottom: 8px;
font-size: 15px;
}
.install-note code {
background: rgba(255,255,255,0.1);
padding: 2px 6px;
border-radius: 3px;
font-family: 'SF Mono', Monaco, monospace;
font-size: 13px;
}
.legend {
background: #2d2d2d;
border: 1px solid #3e3e3e;
border-radius: 8px;
padding: 20px;
margin-bottom: 24px;
}
.legend h3 {
color: #4ec9b0;
font-size: 16px;
margin-bottom: 16px;
}
.legend-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 12px;
}
.legend-item {
display: flex;
align-items: center;
gap: 12px;
font-size: 13px;
}
.legend-color {
width: 32px;
height: 24px;
border-radius: 4px;
border: 1px solid #555;
}
.footer {
background: #2d2d2d;
padding: 12px 24px;
border-top: 1px solid #3e3e3e;
text-align: center;
font-size: 12px;
color: #858585;
}
</style>
</head>
<body>
<div class="header">
<h1>🌳 DOM Tree Visualization</h1>
{% if graph_path %}
<div class="info">Source: {{ graph_path }}</div>
{% endif %}
</div>
<div class="container">
{% if error %}
<div class="error">
{{ error }}
</div>
{% elif is_svg or is_png %}
<div class="legend">
<h3>Color Legend</h3>
<div class="legend-grid">
<div class="legend-item">
<div class="legend-color" style="background: lightgreen;"></div>
<span>&lt;html&gt;, &lt;body&gt;</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: lightyellow;"></div>
<span>Headings (h1-h6)</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: lightgray;"></div>
<span>Block elements</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: lightcyan;"></div>
<span>Lists (ul, ol, li)</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: lightpink;"></div>
<span>Interactive (a, button)</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: lightblue;"></div>
<span>Text nodes</span>
</div>
</div>
</div>
<div class="graph-wrapper" {% if is_png %}style="display: block; width: 100%;"{% endif %}>
{% if is_png %}
<img src="data:image/png;base64,{{ graph_content }}" alt="DOM Graph" style="max-width: 100%; height: auto; display: block;">
{% else %}
{{ graph_content|safe }}
{% endif %}
</div>
{% else %}
<div class="install-note">
<strong>📦 Graphviz not installed</strong>
Showing DOT format instead. For visual graphs, install Graphviz:
<br><br>
<code>sudo apt install graphviz</code>
</div>
<div class="dot-content">{{ graph_content }}</div>
{% endif %}
</div>
<div class="footer">
Bowser Browser • DOM Graph Visualization • Press Ctrl+Shift+D to regenerate
</div>
</body>
</html>