feat: real URL routes for tabs (/detection, /court, /trajectory)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-03-07 12:45:03 +07:00
parent 22c24c0296
commit 08e280d617
2 changed files with 16 additions and 10 deletions

View File

@@ -29,8 +29,9 @@ state = {
@app.route('/')
def index():
return render_template('index.html')
@app.route('/<tab>')
def index(tab='detection'):
return render_template('index.html', active_tab=tab)
@app.route('/frame/<int:sensor_id>')

View File

@@ -367,7 +367,7 @@
<script>
// ===================== Tab switching =====================
var activeTab = 'detection';
var activeTab = '{{ active_tab | default("detection") }}';
function switchTab(target) {
activeTab = target;
@@ -378,18 +378,23 @@ function switchTab(target) {
document.getElementById('infoPanel').style.display = (target === 'trajectory') ? 'flex' : 'none';
if (target === 'court' && !courtSceneInitialized) initCourtScene();
if (target === 'trajectory' && !trajSceneInitialized) initTrajectoryScene();
history.replaceState(null, '', '#' + target);
history.pushState(null, '', '/' + target);
}
document.querySelectorAll('.tab').forEach(function(tab) {
tab.addEventListener('click', function() { switchTab(this.dataset.tab); });
tab.addEventListener('click', function(e) {
e.preventDefault();
switchTab(this.dataset.tab);
});
});
// Init from URL hash
var hash = location.hash.replace('#', '');
if (['detection', 'court', 'trajectory'].indexOf(hash) !== -1) {
switchTab(hash);
}
window.addEventListener('popstate', function() {
var path = location.pathname.replace('/', '') || 'detection';
switchTab(path);
});
// Init active tab from server
if (activeTab !== 'detection') switchTab(activeTab);
// ===================== Calibration =====================
function doCalibrate() {