217 lines
6.9 KiB
HTML
217 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Stream Info - go2rtc</title>
|
|
<style>
|
|
.page-header {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.page-subtitle {
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
}
|
|
|
|
.stream-name-display {
|
|
color: var(--accent);
|
|
font-weight: 600;
|
|
}
|
|
|
|
.info-card {
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 12px;
|
|
padding-bottom: 8px;
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
.json-viewer {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 6px;
|
|
padding: 14px;
|
|
overflow-x: auto;
|
|
font-size: 13px;
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
}
|
|
|
|
.json-key { color: var(--accent); }
|
|
.json-string { color: var(--green); }
|
|
.json-number { color: var(--yellow); }
|
|
.json-boolean { color: var(--accent-hover); font-weight: 600; }
|
|
.json-null { color: var(--text-muted); font-style: italic; }
|
|
.json-bracket { color: var(--text-secondary); }
|
|
.json-line { margin: 2px 0; }
|
|
.json-indent { display: inline-block; width: 18px; }
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 40px 20px;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.loading-spinner {
|
|
display: inline-block;
|
|
width: 28px;
|
|
height: 28px;
|
|
border: 2px solid var(--border-color);
|
|
border-top-color: var(--accent);
|
|
border-radius: 50%;
|
|
animation: spin 0.8s linear infinite;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.error {
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--red);
|
|
border-radius: 8px;
|
|
padding: 20px;
|
|
color: var(--red);
|
|
text-align: center;
|
|
}
|
|
|
|
.error-title {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
margin-bottom: 4px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<script src="main.js"></script>
|
|
|
|
<main>
|
|
<div class="container">
|
|
<a href="index.html" class="back-link">← Back to Streams</a>
|
|
|
|
<div class="page-header">
|
|
<h1 class="page-title">Stream Information</h1>
|
|
<p class="page-subtitle">Details for: <span class="stream-name-display" id="stream-name"></span></p>
|
|
</div>
|
|
|
|
<div id="content">
|
|
<div class="loading">
|
|
<div class="loading-spinner"></div>
|
|
<div>Loading stream information...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<script>
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const streamName = urlParams.get('src');
|
|
|
|
if (!streamName) {
|
|
document.getElementById('content').innerHTML = `
|
|
<div class="error">
|
|
<div class="error-title">Error</div>
|
|
<div>No stream name provided</div>
|
|
</div>
|
|
`;
|
|
} else {
|
|
document.getElementById('stream-name').textContent = decodeURIComponent(streamName);
|
|
|
|
const url = new URL('api/streams', location.href);
|
|
url.searchParams.set('src', streamName);
|
|
|
|
fetch(url, {cache: 'no-cache'})
|
|
.then(r => {
|
|
if (!r.ok) throw new Error(`HTTP ${r.status}: ${r.statusText}`);
|
|
return r.json();
|
|
})
|
|
.then(data => {
|
|
displayInfo(data);
|
|
})
|
|
.catch(error => {
|
|
document.getElementById('content').innerHTML = `
|
|
<div class="error">
|
|
<div class="error-title">Failed to load stream information</div>
|
|
<div>${error.message}</div>
|
|
</div>
|
|
`;
|
|
});
|
|
}
|
|
|
|
function displayInfo(data) {
|
|
const content = document.getElementById('content');
|
|
let html = '<div class="info-card">';
|
|
html += '<div class="card-title">Stream Data</div>';
|
|
html += '<div class="json-viewer">';
|
|
html += formatJSON(data, 0);
|
|
html += '</div></div>';
|
|
content.innerHTML = html;
|
|
}
|
|
|
|
function formatJSON(obj, indent = 0) {
|
|
const indentStr = '<span class="json-indent"></span>'.repeat(indent);
|
|
let html = '';
|
|
|
|
if (obj === null) return `<span class="json-null">null</span>`;
|
|
if (typeof obj === 'string') return `<span class="json-string">"${escapeHtml(obj)}"</span>`;
|
|
if (typeof obj === 'number') return `<span class="json-number">${obj}</span>`;
|
|
if (typeof obj === 'boolean') return `<span class="json-boolean">${obj}</span>`;
|
|
|
|
if (Array.isArray(obj)) {
|
|
if (obj.length === 0) return '<span class="json-bracket">[]</span>';
|
|
html += '<span class="json-bracket">[</span>\n';
|
|
obj.forEach((item, i) => {
|
|
html += '<div class="json-line">' + indentStr + '<span class="json-indent"></span>';
|
|
html += formatJSON(item, indent + 1);
|
|
if (i < obj.length - 1) html += '<span class="json-bracket">,</span>';
|
|
html += '</div>';
|
|
});
|
|
html += '<div class="json-line">' + indentStr + '<span class="json-bracket">]</span></div>';
|
|
return html;
|
|
}
|
|
|
|
if (typeof obj === 'object') {
|
|
const keys = Object.keys(obj);
|
|
if (keys.length === 0) return '<span class="json-bracket">{}</span>';
|
|
html += '<span class="json-bracket">{</span>\n';
|
|
keys.forEach((key, i) => {
|
|
html += '<div class="json-line">' + indentStr + '<span class="json-indent"></span>';
|
|
html += `<span class="json-key">"${escapeHtml(key)}"</span>: `;
|
|
html += formatJSON(obj[key], indent + 1);
|
|
if (i < keys.length - 1) html += '<span class="json-bracket">,</span>';
|
|
html += '</div>';
|
|
});
|
|
html += '<div class="json-line">' + indentStr + '<span class="json-bracket">}</span></div>';
|
|
return html;
|
|
}
|
|
|
|
return String(obj);
|
|
}
|
|
|
|
function escapeHtml(text) {
|
|
const div = document.createElement('div');
|
|
div.textContent = text;
|
|
return div.innerHTML;
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|