| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"/> |
| <meta name="viewport" content="width=device-width,initial-scale=1"/> |
| <meta name="description" content="VaneView — live F1 track-condition and driver-radio intelligence. Runs fully in your browser."/> |
| <title>VaneView® — Track Intelligence</title> |
| <link rel="preconnect" href="https://fonts.googleapis.com"/> |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/> |
| <link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,700;0,9..144,900;1,9..144,600&family=Space+Grotesk:wght@400;500;700&family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet" media="print" onload="this.media='all'"/> |
| <style> |
| /* ============ VANEVIEW · RACE LOGBOOK (paper editorial) ============ */ |
| :root{ |
| --paper:#f6f1e7;--card:#fffdf8;--ink:#1f2430;--ink2:#5b6472; |
| --line:#e0d8c6;--line2:#c9bfa8; |
| --red:#d7263d;--blue:#2f6db3;--yellow:#e8a13c;--green:#2e9e5b; |
| --disp:'Fraunces',serif;--sans:'Space Grotesk',sans-serif;--mono:'JetBrains Mono',monospace; |
| --ease:cubic-bezier(.16,1,.3,1); |
| --shadow:0 10px 30px rgba(31,36,48,.08); |
| } |
| *{box-sizing:border-box;margin:0;padding:0} |
| html{scroll-behavior:smooth} |
| body{background:var(--paper);color:var(--ink);font-family:var(--sans);font-size:15.5px;line-height:1.6;overflow-x:hidden; |
| background-image:radial-gradient(1000px 400px at 85% -5%,rgba(47,109,179,.06),transparent 60%)} |
| ::selection{background:rgba(215,38,61,.18)} |
| a{color:var(--blue);text-decoration:none}button{font-family:inherit;cursor:pointer} |
| .hide{display:none!important} |
| .wrap{max-width:1180px;margin:0 auto;padding:0 24px} |
| /* checkered bands */ |
| .checker{height:8px;background:repeating-conic-gradient(var(--ink) 0% 25%,transparent 0% 50%) 0 0/16px 8px;opacity:.9} |
| .checker.red{background:repeating-conic-gradient(var(--red) 0% 25%,transparent 0% 50%) 0 0/16px 8px} |
| /* wipe transition */ |
| #wipe{position:fixed;inset:0;z-index:250;pointer-events:none;opacity:0; |
| background:repeating-conic-gradient(var(--ink) 0% 25%,var(--red) 0% 50%) 0 0/20px 7px; |
| transition:opacity .3s var(--ease)} |
| #wipe.on{opacity:.9} |
| #splash{position:fixed;inset:0;z-index:300;background:var(--paper);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;transition:opacity .5s var(--ease)} |
| #splash.done{opacity:0;pointer-events:none} |
| #splash .logo{font-family:var(--disp);font-weight:900;font-size:clamp(38px,6vw,64px);letter-spacing:-.02em} |
| #splash .logo em{font-style:italic;color:var(--red)} |
| #splash .boot{font-family:var(--mono);font-size:11px;color:var(--ink2);letter-spacing:.1em} |
| #splash .bar{width:min(300px,70vw);height:3px;background:var(--line2);overflow:hidden} |
| #splash .bar i{display:block;height:100%;width:0;background:var(--red);transition:width .3s} |
| header{position:sticky;top:0;z-index:120;background:rgba(246,241,231,.92);backdrop-filter:blur(10px);border-bottom:1px solid var(--line)} |
| .hbar{display:flex;align-items:center;gap:18px;height:62px} |
| .brand{font-family:var(--disp);font-weight:900;font-size:21px;letter-spacing:-.01em;white-space:nowrap} |
| .brand em{font-style:italic;color:var(--red)} |
| .brand small{display:block;font-family:var(--mono);font-weight:400;font-size:8px;letter-spacing:.32em;color:var(--ink2)} |
| nav.top{display:flex;gap:0;margin-left:auto;overflow-x:auto;scrollbar-width:none} |
| nav.top::-webkit-scrollbar{display:none} |
| nav.top a{font-family:var(--mono);font-size:10.5px;letter-spacing:.1em;color:var(--ink2);padding:9px 11px;white-space:nowrap;border-bottom:2px solid transparent;transition:.2s} |
| nav.top a:hover{color:var(--ink)} |
| nav.top a.on{color:var(--ink);border-bottom-color:var(--red)} |
| .tab{display:none} |
| .tab.active{display:block;animation:tabIn .45s var(--ease)} |
| @keyframes tabIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}} |
| .section{padding:42px 0 66px} |
| .kicker{font-family:var(--mono);font-size:10px;letter-spacing:.28em;color:var(--red);text-transform:uppercase;margin-bottom:12px} |
| .bigTitle{font-family:var(--disp);font-weight:900;font-size:clamp(36px,6.2vw,66px);line-height:1;letter-spacing:-.03em;margin-bottom:16px} |
| .bigTitle em{font-style:italic;color:var(--red)} |
| .sub{color:var(--ink2);max-width:640px;font-size:16.5px} |
| /* index cards */ |
| .card{background:var(--card);border:1px solid var(--line);box-shadow:var(--shadow);padding:22px 24px;position:relative} |
| .card::before{content:"";position:absolute;top:-7px;left:18px;width:52px;height:14px;background:rgba(232,161,60,.35);transform:rotate(-1.5deg)} |
| .card .num{font-family:var(--mono);font-size:9px;letter-spacing:.24em;color:var(--blue);text-transform:uppercase;margin-bottom:8px} |
| .card h3{font-family:var(--disp);font-weight:700;font-size:19px;margin-bottom:5px} |
| .card p{color:var(--ink2);font-size:13.5px} |
| .grid{display:grid;gap:18px} |
| .g2{grid-template-columns:repeat(2,1fr)} |
| .g3{grid-template-columns:repeat(3,1fr)} |
| @media(max-width:900px){.g2,.g3{grid-template-columns:1fr}} |
| .cta{display:inline-flex;align-items:center;justify-content:center;gap:8px;font-family:var(--mono);font-size:11.5px;letter-spacing:.12em;text-transform:uppercase;background:transparent;color:var(--ink);border:1.5px solid var(--ink);padding:12px 20px;transition:.2s var(--ease)} |
| .cta:hover{background:var(--ink);color:var(--paper)} |
| .cta.solid{background:var(--red);border-color:var(--red);color:#fff} |
| .cta.solid:hover{background:#b81e32;color:#fff} |
| .cta.danger{background:var(--red);border-color:var(--red);color:#fff} |
| .miniBtn{font-family:var(--mono);font-size:10px;letter-spacing:.12em;background:transparent;border:1px solid var(--line2);color:var(--ink);padding:8px 13px;transition:.2s} |
| .miniBtn:hover{border-color:var(--yellow);color:var(--yellow)} |
| .stage{position:relative;border:1.5px solid var(--ink);background:#101318;aspect-ratio:16/9;overflow:hidden;box-shadow:var(--shadow)} |
| .stage video{width:100%;height:100%;object-fit:contain;display:block} |
| .stage .ph{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;color:#9aa3b2;font-family:var(--mono);font-size:11.5px;letter-spacing:.14em;text-align:center;padding:20px} |
| .stage .ph .big{font-size:42px} |
| #aiPill{position:absolute;top:10px;left:10px;z-index:5;font-family:var(--mono);font-size:9px;letter-spacing:.12em;background:rgba(16,19,24,.85);border:1px solid rgba(255,255,255,.2);color:#c6cdd8;padding:5px 9px} |
| #aiPill.ok{color:var(--green);border-color:rgba(46,158,91,.5)} |
| #stateBadge{position:absolute;right:10px;top:10px;z-index:5;font-family:var(--disp);font-weight:900;font-size:24px;letter-spacing:.05em;text-transform:uppercase;background:rgba(16,19,24,.88);border:1px solid rgba(255,255,255,.2);padding:6px 14px;color:var(--paper)} |
| #stateBadge.dry{color:var(--green)}#stateBadge.drying{color:var(--yellow)}#stateBadge.damp{color:var(--blue)}#stateBadge.wet{color:var(--red)} |
| .ctrlRow{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-top:14px} |
| .ctrlRow label{font-family:var(--mono);font-size:10px;letter-spacing:.14em;color:var(--ink2);text-transform:uppercase} |
| select,input[type=text]{background:var(--card);color:var(--ink);border:1px solid var(--line2);font-family:var(--sans);font-size:13.5px;padding:10px 12px;outline:none;transition:.2s;min-width:180px} |
| select:focus,input:focus{border-color:var(--blue)} |
| .metrics{display:grid;grid-template-columns:repeat(6,1fr);gap:0;margin-top:16px;border:1px solid var(--line);background:var(--card)} |
| @media(max-width:900px){.metrics{grid-template-columns:repeat(3,1fr)}} |
| .metric{padding:12px 14px;border-right:1px solid var(--line)} |
| .metric:last-child{border-right:0} |
| .metric .l{font-family:var(--mono);font-size:8.5px;letter-spacing:.18em;color:var(--ink2);text-transform:uppercase} |
| .metric .v{font-family:var(--disp);font-weight:900;font-size:21px;margin-top:3px} |
| .metric .v small{font-size:10px;color:var(--ink2);font-weight:500} |
| .chartBox{margin-top:18px;background:var(--card);border:1px solid var(--line);padding:16px} |
| .chartBox canvas{width:100%;height:180px;display:block} |
| .why{font-size:13.5px;color:var(--ink2);margin-top:12px;line-height:1.75} |
| .why b{color:var(--ink)} |
| .pit{display:flex;align-items:center;gap:12px;margin-top:16px;flex-wrap:wrap;border-top:1px dashed var(--line2);padding-top:14px} |
| .pitCall{font-family:var(--disp);font-weight:900;font-size:15px;letter-spacing:.04em;text-transform:uppercase} |
| .pitCall.go{color:var(--red)} |
| .pitCall.ok{color:var(--green)} |
| .audioDrop{background:var(--card);border:2px dashed var(--line2);padding:30px 18px;text-align:center;color:var(--ink2);transition:.2s;cursor:pointer} |
| .audioDrop:hover{border-color:var(--red);color:var(--ink)} |
| .audioDrop .ic{font-size:38px;margin-bottom:8px} |
| .emotionBig{font-family:var(--disp);font-weight:900;font-size:38px;letter-spacing:.02em;text-transform:uppercase;line-height:1} |
| .bars{margin-top:14px;display:flex;flex-direction:column;gap:7px} |
| .bar{display:grid;grid-template-columns:104px 1fr 30px;align-items:center;gap:10px;font-family:var(--mono);font-size:9px;color:var(--ink2);letter-spacing:.08em} |
| .bar .track{height:6px;background:var(--line);overflow:hidden} |
| .bar .fill{height:100%;background:var(--red);width:0;transition:width .5s var(--ease)} |
| .tran{background:#fff;border:1px solid var(--line);padding:14px;font-size:14px;line-height:1.8;min-height:104px;white-space:pre-wrap} |
| .tran .ph{color:var(--ink2);font-style:italic} |
| .clipRow{display:flex;align-items:center;gap:12px;background:var(--card);border:1px solid var(--line);padding:11px 14px;margin-top:9px} |
| .clipRow .emo{font-size:20px;width:32px;text-align:center} |
| .clipRow .meta{flex:1;min-width:0} |
| .clipRow .meta .t{font-family:var(--mono);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} |
| .clipRow .meta .s{font-family:var(--mono);font-size:9px;color:var(--ink2);letter-spacing:.1em;text-transform:uppercase} |
| .wxCards{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px;margin-top:12px} |
| .wxCard{background:var(--card);border:1px solid var(--line);padding:12px;text-align:center} |
| .wxCard .d{font-family:var(--mono);font-size:9px;color:var(--ink2);letter-spacing:.08em;text-transform:uppercase} |
| .wxCard .ic{font-size:28px;margin:6px 0} |
| .wxCard .t{font-family:var(--disp);font-weight:900;font-size:17px} |
| .wxCard .s{font-family:var(--mono);font-size:9px;color:var(--ink2)} |
| .tireRow{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:14px} |
| .tireCard{background:var(--card);border:1px solid var(--line);padding:16px;box-shadow:var(--shadow);transition:.25s} |
| .tireCard:hover{transform:translateY(-2px)} |
| .tireCard .stripe{height:6px;margin-bottom:11px} |
| .tireCard h4{font-family:var(--disp);font-weight:700;font-size:16px;text-transform:uppercase} |
| .tireCard .cond{font-family:var(--mono);font-size:9px;letter-spacing:.12em;color:var(--ink2);margin:5px 0 9px} |
| .tireCard p{color:var(--ink2);font-size:12.5px} |
| .gal{display:grid;grid-template-columns:repeat(auto-fill,minmax(270px,1fr));gap:14px;margin-top:14px} |
| .galItem{background:var(--card);border:1px solid var(--line);box-shadow:var(--shadow)} |
| .galItem img{width:100%;aspect-ratio:16/9;object-fit:cover;display:block;background:#000} |
| .galItem .cap{padding:10px 13px} |
| .galItem .cap .t{font-family:var(--mono);font-size:10px;color:var(--blue)} |
| .galItem .cap .s{font-size:12px;color:var(--ink2);margin-top:3px} |
| .riskBig{font-family:var(--disp);font-weight:900;font-size:clamp(50px,7vw,80px);line-height:1;letter-spacing:-.04em} |
| .riskTag{font-family:var(--mono);font-size:10px;letter-spacing:.22em;text-transform:uppercase;margin-top:6px} |
| #toast{position:fixed;bottom:22px;left:50%;transform:translateX(-50%) translateY(18px);z-index:200;background:var(--ink);color:var(--paper);font-family:var(--mono);font-size:11px;padding:11px 16px;opacity:0;pointer-events:none;transition:.3s var(--ease);max-width:90vw} |
| #toast.on{opacity:1;transform:translateX(-50%) translateY(0)} |
| footer{border-top:1px solid var(--line);padding:24px 0 36px;font-family:var(--mono);font-size:10px;letter-spacing:.12em;color:var(--ink2)} |
| #errBanner{position:fixed;top:0;left:0;right:0;z-index:400;background:var(--red);color:#fff;font-family:var(--mono);font-size:11px;padding:9px 16px;display:none} |
| </style> |
| </head> |
| <body> |
| <div id="errBanner"></div> |
| <div id="wipe"></div> |
| <div id="splash"> |
| <div class="logo">Vane<em>View</em></div> |
| <div class="boot" id="bootLine">INITIALISING…</div> |
| <div class="bar"><i id="bootBar"></i></div> |
| </div> |
| <div id="toast"></div> |
|
|
| <header> |
| <div class="wrap hbar"> |
| <div class="brand">Vane<em>View</em><small>TRACK INTELLIGENCE</small></div> |
| <nav class="top" id="topNav"></nav> |
| </div> |
| </header> |
| <div class="checker"></div> |
|
|
| <main class="wrap"> |
|
|
| <section class="tab active" id="tab-home" data-tab="home"> |
| <div class="section"> |
| <div class="kicker">Live F1 track-condition & driver-radio intelligence</div> |
| <h1 class="bigTitle">Know the track.<br/><em>Read the driver.</em></h1> |
| <p class="sub">VaneView watches your onboard feed frame by frame, blends it with the circuit weather, and tells the pit wall whether the track is getting safer or riskier — then listens to the driver to confirm it.</p> |
| <div class="ctrlRow" style="margin-top:24px"> |
| <button class="cta solid" data-go="live">Open the live detector</button> |
| <button class="cta" data-go="audio">Driver radio desk</button> |
| <button class="cta" data-go="intel">Combined call</button> |
| </div> |
| </div> |
| <div class="grid g3" style="padding-bottom:54px"> |
| <div class="card"><div class="num">Per-frame condition</div><h3>Dry · Damp · Drying · Wet</h3><p>Texture, reflections and the dry racing line, cross-checked against labeled track shots and the circuit's live weather. Shade and tyre rubber are read as dry, never as water.</p></div> |
| <div class="card"><div class="num">Driver radio</div><h3>Transcript + emotion</h3><p>A speech model writes out the radio message while two fine-tuned emotion models read the tone — stressed, angry, sarcastic, calm — against a library of known emotion clips.</p></div> |
| <div class="card"><div class="num">One joint call</div><h3>Risk score & tire advice</h3><p>Track × tyre × driver folded into a 0–100 risk read with a clear box-or-stay recommendation, updated live.</p></div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-live" data-tab="live"> |
| <div class="section"> |
| <div class="kicker">Live detector · vision</div> |
| <h2 class="bigTitle">Per-frame <em>condition</em></h2> |
| <div class="stage"> |
| <div class="ph" id="stagePh"><div class="big">🏁</div>Upload race footage or start the camera.</div> |
| <video id="vid" class="hide" playsinline muted></video> |
| <div id="aiPill">CLASSIFIER · OFF</div> |
| <div id="stateBadge">—</div> |
| </div> |
| <div class="ctrlRow"> |
| <button class="cta" id="vidBtn">Upload video</button> |
| <button class="cta" id="camBtn">Live camera</button> |
| <button class="cta" id="stopBtn">■ Stop</button> |
| <button class="cta" id="resumeBtn">▶ Resume</button> |
| <input type="file" id="vidIn" accept="video/*" class="hide"/> |
| </div> |
| <div class="ctrlRow"> |
| <label>Team</label><select id="teamSel"></select> |
| <label>Track</label><select id="trackSel"></select> |
| <label>Tyre</label><select id="tireSel"></select> |
| </div> |
| <div class="ctrlRow"> |
| <label style="display:flex;align-items:center;gap:8px;cursor:pointer"><input type="checkbox" id="wxPriorChk" checked/> Blend in circuit weather (auto-on for live)</label> |
| <span id="wxPriorRead" style="font-family:var(--mono);font-size:11px;color:var(--ink2)">prior · off</span> |
| </div> |
| <div class="metrics"> |
| <div class="metric"><div class="l">Frame</div><div class="v" id="mFrame">0</div></div> |
| <div class="metric"><div class="l">State</div><div class="v" id="mState" style="font-size:15px">—</div></div> |
| <div class="metric"><div class="l">Wet ratio</div><div class="v" id="mWet">0<small>%</small></div></div> |
| <div class="metric"><div class="l">Dry ratio</div><div class="v" id="mDry">0<small>%</small></div></div> |
| <div class="metric"><div class="l">Confidence</div><div class="v" id="mConf">0<small>%</small></div></div> |
| <div class="metric"><div class="l">DB match</div><div class="v" id="mDb" style="font-size:11px">—</div></div> |
| </div> |
| <div class="chartBox"> |
| <div class="num" style="font-family:var(--mono);font-size:9px;letter-spacing:.22em;color:var(--ink2)">TREND · 4-FRAME BASELINE · PER FRAME</div> |
| <canvas id="trendChart"></canvas> |
| </div> |
| <div class="why" id="whyLine">Upload or start a feed to begin analysis.</div> |
| <div class="pit"> |
| <div class="pitCall" id="pitCall">PIT CALL · —</div> |
| <button class="cta danger hide" id="pcYes">Accept & switch compound</button> |
| <button class="miniBtn hide" id="pcNo">Deny</button> |
| </div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-tracks" data-tab="tracks"> |
| <div class="section"> |
| <div class="kicker">Tracks & weather</div> |
| <h2 class="bigTitle">Circuit <em>forecast</em></h2> |
| <div class="ctrlRow" style="margin-bottom:18px"><label>Select circuit</label><select id="wxTrackSel"></select></div> |
| <div class="card" style="margin-bottom:18px"> |
| <div class="num">Live conditions</div> |
| <h3 id="wxNowName">Select a circuit</h3> |
| <div id="wxNowBody" style="color:var(--ink2);margin-top:8px;font-size:13.5px">Loading…</div> |
| </div> |
| <div class="kicker" style="margin-top:22px">Past 3 days</div> |
| <div class="wxCards" id="wxPast"></div> |
| <div class="kicker" style="margin-top:22px">7-day forecast</div> |
| <div class="wxCards" id="wxFuture"></div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-tires" data-tab="tires"> |
| <div class="section"> |
| <div class="kicker">Pirelli compound guide</div> |
| <h2 class="bigTitle">Know your <em>rubber</em></h2> |
| <div class="tireRow" id="tireList"></div> |
| <div class="card" style="margin-top:20px"><div class="num">Compound → condition map</div><div id="tireMatrix" style="color:var(--ink2);font-size:13px;line-height:2"></div></div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-audio" data-tab="audio"> |
| <div class="section"> |
| <div class="kicker">Driver radio</div> |
| <h2 class="bigTitle">Read the <em>voice</em></h2> |
| <div class="grid g2"> |
| <div> |
| <div class="audioDrop" id="audioDrop"> |
| <div class="ic">🎙️</div><p>Drop a driver radio clip here, or</p> |
| <button class="cta solid" id="audioBtn" style="margin-top:12px;display:inline-block">Choose audio file</button> |
| <input type="file" id="audioIn" accept="audio/*" class="hide"/> |
| </div> |
| <div class="ctrlRow" style="margin-top:12px"><label>Lap time (auto · editable)</label><input type="text" id="lapIn" placeholder="01:32.480" style="flex:1;min-width:140px"/></div> |
| <button class="cta solid" id="analyzeBtn" style="width:100%;text-align:center;margin-top:9px">Analyze clip</button> |
| </div> |
| <div class="card" style="min-height:290px"> |
| <div class="num">Emotion · dual model</div> |
| <div id="emoBig" style="margin-top:12px"><div class="emotionBig" style="color:var(--ink2);font-size:22px">Awaiting clip</div></div> |
| <div class="why" id="emoWhy" style="margin-top:10px">Load a clip and press Analyze.</div> |
| <div class="bars" id="emoBars"></div> |
| </div> |
| </div> |
| <div class="grid g2" style="margin-top:16px"> |
| <div class="card"><div class="num">Transcript</div><div class="tran" id="tranOut"><span class="ph">Transcript appears here.</span></div></div> |
| <div class="card"><div class="num">Acoustic context</div><div class="why" id="astOut" style="margin-top:4px">Waiting…</div><div class="num" style="margin-top:16px">Model verdicts</div><div class="why" id="featOut">—</div></div> |
| </div> |
| <div class="ctrlRow" style="margin-top:14px"><button class="cta" id="saveClipBtn">+ Save clip to library</button></div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-clips" data-tab="clips"> |
| <div class="section"> |
| <div class="kicker">Radio clips</div> |
| <h2 class="bigTitle">Saved <em>transmissions</em></h2> |
| <div id="clipsList"><p class="sub">No clips saved yet.</p></div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-intel" data-tab="intel"> |
| <div class="section"> |
| <div class="kicker">Combined call</div> |
| <h2 class="bigTitle">Vision × <em>voice</em></h2> |
| <p class="sub" style="margin-bottom:20px">Track state × tyre compound × driver emotion — one confidence-weighted read, updating live.</p> |
| <div class="grid g3" style="margin-bottom:16px"> |
| <div class="card"><div class="num">Joint risk</div><div class="riskBig" id="intelRisk">—<small>/100</small></div><div class="riskTag" id="intelRiskTag">AWAITING DATA</div></div> |
| <div class="card" style="grid-column:span 2"><div class="num">Joint verdict</div><div id="intelOut" style="color:var(--ink2);font-size:14.5px;line-height:1.9">Run at least one video and one radio analysis, then return here.</div></div> |
| </div> |
| <div class="grid g3" style="margin-bottom:16px"> |
| <div class="card"><div class="num">Track</div><h3 id="intelTrack">—</h3><p id="intelTrackWhy">No analysis yet.</p></div> |
| <div class="card"><div class="num">Driver</div><h3 id="intelEmo">—</h3><p id="intelEmoWhy">No analysis yet.</p></div> |
| <div class="card"><div class="num">Recommendation</div><h3 id="intelCall" style="color:var(--ink2)">—</h3><p id="intelCallWhy">Awaiting data.</p></div> |
| </div> |
| <div class="card"><div class="num">Decision table</div><div id="intelTable" style="color:var(--ink2);font-size:13px;line-height:2"></div></div> |
| <div class="card" style="margin-top:16px"><div class="num">Combined timeline</div><div id="intelTime" style="color:var(--ink2);font-size:12px;line-height:1.9;font-family:var(--mono)">No events yet.</div></div> |
| </div> |
| </section> |
|
|
| <section class="tab" id="tab-gallery" data-tab="gallery"> |
| <div class="section"> |
| <div class="kicker">Frame gallery</div> |
| <h2 class="bigTitle">Analysed <em>frames</em></h2> |
| <p class="sub" style="margin-bottom:18px">Frames captured from your feed, each with its verdict.</p> |
| <div class="gal" id="gal"></div> |
| </div> |
| </section> |
|
|
| </main> |
| <footer><div class="wrap" style="display:flex;justify-content:space-between;flex-wrap:wrap;gap:10px"><span>VANEVIEW — TRACK INTELLIGENCE</span><span>RUNS IN YOUR BROWSER</span></div></footer> |
|
|
| <script> |
| "use strict"; |
| var VV=window.VV={}; |
| VV.$=function(id){return document.getElementById(id)}; |
| VV.toast=function(msg){var t=VV.$("toast");if(!t)return;t.textContent=msg;t.classList.add("on");clearTimeout(t._h);t._h=setTimeout(function(){t.classList.remove("on")},3000)}; |
| VV.TRACKS=[ |
| ["Albert Park Circuit","Melbourne, Australia",-37.8497,144.9688], |
| ["Shanghai International Circuit","Shanghai, China",31.3389,121.2202], |
| ["Suzuka International Racing Course","Suzuka, Japan",34.8431,136.5411], |
| ["Bahrain International Circuit","Sakhir, Bahrain",26.0325,50.5106], |
| ["Jeddah Corniche Circuit","Jeddah, Saudi Arabia",21.6319,39.1044], |
| ["Miami International Autodrome","Miami Gardens, United States",25.9581,-80.2389], |
| ["Circuit Gilles Villeneuve","Montreal, Canada",45.5017,-73.5272], |
| ["Circuit de Monaco","Monte Carlo, Monaco",43.7347,7.4206], |
| ["Circuit de Barcelona-Catalunya","Barcelona, Spain",41.5691,2.2594], |
| ["Red Bull Ring","Spielberg, Austria",47.2197,14.7647], |
| ["Silverstone Circuit","Silverstone, United Kingdom",52.0786,-1.0169], |
| ["Circuit de Spa-Francorchamps","Stavelot, Belgium",50.4372,5.9714], |
| ["Hungaroring","Mogyoród, Hungary",47.5789,19.2486], |
| ["Circuit Zandvoort","Zandvoort, Netherlands",52.3888,4.5409], |
| ["Autodromo Nazionale Monza","Monza, Italy",45.6156,9.2811], |
| ["Madring (Madrid Circuit)","Madrid, Spain",40.4168,-3.7038], |
| ["Baku City Circuit","Baku, Azerbaijan",40.3756,49.8533], |
| ["Marina Bay Street Circuit","Singapore, Singapore",1.2914,103.8639], |
| ["Circuit of the Americas","Austin, United States",30.1328,-97.6411], |
| ["Autódromo Hermanos Rodríguez","Mexico City, Mexico",19.4042,-99.0907], |
| ["Autódromo José Carlos Pace (Interlagos)","São Paulo, Brazil",-23.7036,-46.6997], |
| ["Las Vegas Strip Circuit","Las Vegas, United States",36.1147,-115.1728], |
| ["Lusail International Circuit","Lusail, Qatar",25.4900,51.4550], |
| ["Yas Marina Circuit","Abu Dhabi, United Arab Emirates",24.4672,54.6031] |
| ]; |
| VV.TEAMS=["Alpine","Aston Martin","Audi","Cadillac","Ferrari","Haas","McLaren","Mercedes","Racing Bulls","Red Bull Racing","Williams"]; |
| VV.TIRES=[ |
| {name:"Soft",stripe:"#ef4444",cond:"Dry · high grip, high degradation",desc:"Fastest compound; ideal for short dry stints.",states:["dry"]}, |
| {name:"Medium",stripe:"#f7c948",cond:"Dry · balanced",desc:"Versatile dry compound — pace and durability.",states:["dry","drying"]}, |
| {name:"Hard",stripe:"#e5e7eb",cond:"Dry · durable",desc:"Toughest slick for abrasive circuits and long stints.",states:["dry"]}, |
| {name:"Intermediate",stripe:"#4ade80",cond:"Damp · drying",desc:"Semi-treaded crossover for light rain and a drying line.",states:["damp","drying"]}, |
| {name:"Wet",stripe:"#38bdf8",cond:"Wet · heavy rain",desc:"Full-tread Cinturato Blue — up to 65 L/s water dispersal.",states:["wet"]} |
| ]; |
| var NAV=[["home","Home"],["live","Live Detector"],["tracks","Tracks & Weather"],["tires","Tyre Guide"],["audio","Driver Radio"],["clips","Radio Clips"],["intel","Combined Call"],["gallery","Frame Gallery"]]; |
| var navEl=VV.$("topNav"); |
| NAV.forEach(function(n){ |
| var a=document.createElement("a");a.href="#";a.textContent=n[1];a.setAttribute("data-go",n[0]); |
| a.addEventListener("click",function(e){e.preventDefault();go(n[0])}); |
| navEl.appendChild(a); |
| }); |
| function go(name){ |
| var wipe=VV.$("wipe");if(wipe){wipe.classList.add("on");setTimeout(function(){wipe.classList.remove("on")},280)} |
| setTimeout(function(){ |
| document.querySelectorAll(".tab").forEach(function(t){t.classList.remove("active")}); |
| document.querySelectorAll("nav.top a").forEach(function(a){a.classList.remove("on")}); |
| var tab=VV.$("tab-"+name);if(tab)tab.classList.add("active"); |
| var link=document.querySelector('nav.top a[data-go="'+name+'"]');if(link)link.classList.add("on"); |
| window.scrollTo({top:0,behavior:"smooth"}); |
| if(name==="intel"&&VV.updateIntel)VV.updateIntel(true); |
| },140); |
| } |
| document.querySelectorAll("[data-go]").forEach(function(el){ |
| if(!el.closest("nav.top"))el.addEventListener("click",function(e){e.preventDefault();go(el.getAttribute("data-go"))}); |
| }); |
| function fillSel(id,list,label){ |
| var s=VV.$(id);if(!s)return; |
| s.innerHTML=""; |
| if(label){var o0=document.createElement("option");o0.value="";o0.textContent=label;s.appendChild(o0)} |
| list.forEach(function(x,i){var o=document.createElement("option");o.value=String(i);o.textContent=typeof x==="string"?x:x[0]+" · "+x[1];s.appendChild(o)}); |
| } |
| fillSel("teamSel",VV.TEAMS,"Select team"); |
| fillSel("trackSel",VV.TRACKS,"Select circuit"); |
| fillSel("tireSel",VV.TIRES,"Select compound"); |
| fillSel("wxTrackSel",VV.TRACKS,"Select circuit"); |
| function wxLabelShort(c){if(c===0)return"Clear";if(c<=2)return"Partly cloudy";if(c<=3)return"Overcast";if(c<=48)return"Fog";if(c<=57)return"Drizzle";if(c<=67)return"Rain";if(c<=77)return"Snow";if(c<=82)return"Storm";return"Rain"} |
| function rainFromLabel(l,p){return/Storm|Rain|Drizzle/.test(l)?0.9:l==="Snow"?0.7:l==="Fog"?0.55:l==="Overcast"?0.45:l==="Partly cloudy"?0.3:p>0?0.75:0.2} |
| function fetchWxPrior(idx){ |
| var t=VV.TRACKS[idx]||VV.TRACKS[0]; |
| fetch("https://api.open-meteo.com/v1/forecast?latitude="+t[2]+"&longitude="+t[3]+"¤t=temperature_2m,relative_humidity_2m,weather_code,precipitation&timezone=auto") |
| .then(function(r){return r.json()}).then(function(j){ |
| var c=j.current,label=wxLabelShort(c.weather_code); |
| VV.wxRain=rainFromLabel(label,c.precipitation); |
| VV.lastWx=label; |
| var r2=VV.$("wxPriorRead");if(r2)r2.textContent="prior · "+label+" → rain "+(VV.wxRain*100).toFixed(0)+"%"; |
| }).catch(function(){}); |
| } |
| VV.$("trackSel").addEventListener("change",function(){fetchWxPrior(+this.value||0)}); |
| var tireList=VV.$("tireList"); |
| VV.TIRES.forEach(function(t){ |
| var d=document.createElement("div");d.className="tireCard"; |
| d.innerHTML='<div class="stripe" style="background:'+t.stripe+'"></div><h4>'+t.name+'</h4><div class="cond">'+t.cond+'</div><p>'+t.desc+'</p>'; |
| tireList.appendChild(d); |
| }); |
| VV.$("tireMatrix").innerHTML=VV.TIRES.map(function(t){return "<b style='color:var(--ink)'>"+t.name+"</b> → "+t.states.map(function(s){return s.toUpperCase()}).join(" · ")+" — "+t.cond}).join("<br/>"); |
| document.querySelectorAll(".cta").forEach(function(b){ |
| b.addEventListener("mousemove",function(e){var r=b.getBoundingClientRect();b.style.transform="translate("+((e.clientX-r.left-r.width/2)/r.width*8)+"px,"+((e.clientY-r.top-r.height/2)/r.height*6)+"px)"}); |
| b.addEventListener("mouseleave",function(){b.style.transform=""}); |
| }); |
| var bootBar=VV.$("bootBar"),bootLine=VV.$("bootLine"),bp=0; |
| var bootInt=setInterval(function(){ |
| bp+=10;if(bp>100)bp=100; |
| bootBar.style.width=bp+"%"; |
| bootLine.textContent=bp<34?"INITIALISING…":bp<70?"LOADING REFERENCE DATABASE…":"READY"; |
| if(bp>=100){clearInterval(bootInt);setTimeout(function(){VV.$("splash").classList.add("done")},200)} |
| },110); |
| setTimeout(function(){var s=VV.$("splash");if(s&&!s.classList.contains("done"))s.classList.add("done")},4000); |
| var missing=["vid","vidIn","stagePh","aiPill","stateBadge","trendChart","whyLine","pitCall","teamSel","trackSel","tireSel","wxPriorChk","wxPriorRead","audioIn","audioDrop","analyzeBtn","tranOut","emoBig","emoBars","astOut","featOut","clipsList","wxTrackSel","wxNowName","wxNowBody","wxPast","wxFuture","gal","intelRisk","intelRiskTag","intelOut","intelTrack","intelTrackWhy","intelEmo","intelEmoWhy","intelCall","intelCallWhy","intelTable","intelTime"].filter(function(id){return !VV.$(id)}); |
| if(missing.length)console.warn("VaneView missing:",missing); |
| console.log("VaneView core ready —",VV.TRACKS.length,"circuits"); |
| </script> |
| <script> |
| "use strict"; |
| |
| try{ |
| (function(V){ |
| var $=V.$; |
| var vid=$("vid"),stagePh=$("stagePh"); |
| if(!vid)return; |
| |
| V.Models={ready:false,T:null}; |
| function loadT(){return V.Models.ready?Promise.resolve(V.Models.T): |
| import("https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1").then(function(m){ |
| var env=m.env; |
| try{env.localModelPath="./models/"}catch(e){} |
| try{env.allowLocalModels=true}catch(e){} |
| try{env.allowRemoteModels=true}catch(e){} |
| try{env.backends.onnx.wasm.wasmPaths="https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1/dist/"}catch(e){} |
| V.Models.T=m;V.Models.ready=true;return m; |
| })} |
| |
| var status=$("aiPill"); |
| var state={running:false,procOn:false,frame:0,raf:null,stream:null,lastGall:0,win:[],locked:null,applyWx:true,baseFrames:[],baseL:null}; |
| var Hc=document.createElement("canvas"),Hx=Hc.getContext("2d",{willReadFrequently:true}); |
| var Rc=document.createElement("canvas"),Rx=Rc.getContext("2d",{willReadFrequently:true}); |
| Rc.width=16;Rc.height=16; |
| function setStatus(t,c){if(status){status.textContent=t;status.className=c||""}} |
| function toast(m){V.toast(m)} |
| |
| |
| V.cfg={token:(localStorage.getItem("vv_token")||""),mode:(localStorage.getItem("vv_mode")||"auto")}; |
| V.hasAPI=function(){return V.cfg.token.length>8}; |
| |
| |
| |
| |
| |
| var API_PROMPTS=["dry asphalt race track, matte, no water","damp asphalt race track, patchy moisture","drying race track with bright dry racing line","wet asphalt race track with standing water and reflections","wet asphalt with water spray and spray streaks"]; |
| var API={last:0,busy:false,state:null,streak:0,verdict:"—",ok:false}; |
| function apiLabel(i){return i===1?"damp":i===2?"drying":(i===3||i===4)?"wet":"dry"} |
| function apiVision(canvas){ |
| if(!V.hasAPI()||API.busy||Date.now()-API.last<1200)return; |
| API.last=Date.now();API.busy=true; |
| canvas.toBlob(function(blob){ |
| if(!blob){API.busy=false;return} |
| var fd=new FormData(); |
| fd.append("inputs",blob,"frame.jpg"); |
| fd.append("parameters",JSON.stringify({candidate_labels:API_PROMPTS})); |
| fetch("https://api-inference.huggingface.co/models/openai/clip-vit-base-patch32",{ |
| method:"POST",headers:{Authorization:"Bearer "+V.cfg.token},body:fd |
| }).then(function(r){if(!r.ok)throw new Error("API "+r.status);return r.json()}).then(function(out){ |
| API.busy=false;API.ok=true; |
| var best=null; |
| (out||[]).forEach(function(o){ |
| var idx=API_PROMPTS.indexOf(o.label); |
| if(idx>=0&&(!best||o.score>best.score))best={idx:idx,score:o.score}; |
| }); |
| if(!best)return; |
| var st=apiLabel(best.idx); |
| if(best.score>=0.60){ |
| if(API.state===st)API.streak++;else{API.state=st;API.streak=1} |
| if(API.streak>=2)API.verdict=st+" · "+(best.score*100).toFixed(0)+"%"; |
| }else API.streak=0; |
| setStatus("API · CLIP ONLINE","ok"); |
| }).catch(function(e){ |
| API.busy=false;API.ok=false;setStatus("API · unavailable (check token)","warn"); |
| }); |
| },"image/jpeg",0.8); |
| } |
| |
| |
| var LABELS=["damp","dry","wet"]; |
| var DATASETS=[{name:"weather-whiplash/trackside-condition",config:"default",split:"train"}, |
| {name:"weather-whiplash/trackside-condition",config:"default",split:"validation"}, |
| {name:"weather-whiplash/trackside-condition",config:"default",split:"test"}]; |
| var REFS=[{cls:"dry",src:"refs/dry1.jpg"},{cls:"dry",src:"refs/dry2.jpg"}, |
| {cls:"damp",src:"refs/damp1.jpg"},{cls:"damp",src:"refs/damp2.jpg"}, |
| {cls:"wet",src:"refs/wet1.jpg"},{cls:"wet",src:"refs/wet2.jpg"}]; |
| var DB={loaded:false,refs:[]}; |
| function loadImage(src){return new Promise(function(res){var im=new Image();im.crossOrigin="anonymous";im.onload=function(){res(im)};im.onerror=function(){res(null)};im.src=src})} |
| function pHash(im){var w=8,h=8;Rc.width=w;Rc.height=h;Rx.drawImage(im,0,0,w,h);var d=Rx.getImageData(0,0,w,h).data,pix=[],sum=0;for(var i=0;i<w*h;i++){var lum=0.299*d[i*4]+0.587*d[i*4+1]+0.114*d[i*4+2];pix.push(lum);sum+=lum}var avg=sum/pix.length,hash=0;for(var j=0;j<pix.length;j++)hash=(hash<<1)|(pix[j]>avg?1:0);return hash} |
| function hist(im){Rc.width=16;Rc.height=16;Rx.drawImage(im,0,0,16,16);var d=Rx.getImageData(0,0,16,16).data,b=[0,0,0,0,0,0,0,0],lum,sum=0;for(var i=0;i<256;i++){lum=0.299*d[i*4]+0.587*d[i*4+1]+0.114*d[i*4+2];b[Math.min(7,Math.floor(lum/32))]++;sum++}for(var k=0;k<8;k++)b[k]/=sum;return b} |
| function hamming(a,b){var x=a^b,c=0;while(x){c+=x&1;x>>>=1}return c} |
| function histDist(a,b){var s=0;for(var i=0;i<8;i++)s+=Math.abs(a[i]-b[i]);return s/2} |
| function loadLocalRefs(){var jobs=REFS.map(function(r){return loadImage(r.src).then(function(im){return im?{cls:r.cls,hash:pHash(im),hist:hist(im)}:null})});Promise.all(jobs).then(function(list){DB.refs=DB.refs.concat(list.filter(Boolean));DB.loaded=DB.refs.length>=3})} |
| function fetchDS(ds){return fetch("https://datasets-server.huggingface.co/rows?dataset="+ds.name+"&config="+ds.config+"&split="+ds.split+"&offset=0&length=100").then(function(r){return r.json()}).then(function(data){return data&&data.rows||[]}).catch(function(){return[]})} |
| function loadDB(){var seen={},gathered=[];Promise.all(DATASETS.map(fetchDS)).then(function(pages){pages.forEach(function(rows){rows.forEach(function(item){var cls=LABELS[item.row.label],src=item.row.image&&item.row.image.src;if(!src||!cls||(seen[cls]||0)>=6)return;seen[cls]=(seen[cls]||0)+1;gathered.push({cls:cls,src:src})})});if(!gathered.length){loadLocalRefs();return}var jobs=gathered.map(function(g){return loadImage(g.src).then(function(im){return im?{cls:g.cls,hash:pHash(im),hist:hist(im)}:null})});Promise.all(jobs).then(function(list){DB.refs=list.filter(Boolean);DB.loaded=DB.refs.length>=3})})} |
| loadDB(); |
| |
| |
| function feats(){ |
| var w=96,h=54;Hc.width=w;Hc.height=h; |
| try{Hx.drawImage(vid,0,0,w,h)}catch(e){return null} |
| var d=Hx.getImageData(0,0,w,h).data,n=w*h,i,j,lum,meanL=0; |
| var lums=new Float32Array(n),spec=0,cool=0,smooth=0,tex=0; |
| for(i=0;i<n;i++){var r=d[i*4],g=d[i*4+1],b=d[i*4+2];lum=0.299*r+0.587*g+0.114*b;lums[i]=lum;meanL+=lum;cool+=b-r;if(lum>200&&Math.abs(r-g)<15&&Math.abs(g-b)<15)spec++} |
| meanL/=n;spec/=n;cool/=n/255; |
| for(i=0;i<n-1;i++){var dl=lums[i+1]-lums[i];tex+=dl*dl;if(Math.abs(dl)<12)smooth++} |
| tex=Math.sqrt(tex/(n-1));smooth/=(n-1); |
| var gy=0;for(i=0;i<n-w;i++){var dv=lums[i+w]-lums[i];gy+=dv*dv} |
| gy=Math.sqrt(gy/(n-w));var streak=gy/(tex+1e-6); |
| var colM=new Float32Array(w),colMean=0,colVar=0; |
| for(i=0;i<w;i++){var s=0;for(j=0;j<h;j++)s+=lums[j*w+i];colM[i]=s/h;colMean+=colM[i]} |
| colMean/=w;for(i=0;i<w;i++)colVar+=(colM[i]-colMean)*(colM[i]-colMean);colVar/=w; |
| var bw=Math.floor(w/8),bh=Math.floor(h/6),pm=[],pmean=0; |
| for(var by=0;by<6;by++)for(var bx=0;bx<8;bx++){var s2=0,c2=0;for(j=by*bh;j<(by+1)*bh;j++)for(i=bx*bw;i<(bx+1)*bw;i++){s2+=lums[j*w+i];c2++}pm.push(s2/(c2||1));pmean+=s2/(c2||1)} |
| pmean/=pm.length;var patch=0;for(i=0;i<pm.length;i++)patch+=(pm[i]-pmean)*(pm[i]-pmean);patch/=pm.length; |
| return{L:meanL,tex:tex,streak:streak,spec:spec,cool:cool,smooth:smooth,colVar:colVar,patch:patch}; |
| } |
| function clamp(x,a,b){return Math.max(a,Math.min(b,x))} |
| function normN(v,s){return clamp(v/s,0,1)} |
| function dbMatch(){ |
| if(!DB.loaded)return null; |
| Rc.width=16;Rc.height=16; |
| try{Rx.drawImage(vid,0,0,16,16)}catch(e){return null} |
| var d=Rx.getImageData(0,0,16,16).data,pix=[],sum=0; |
| for(var i=0;i<256;i++){var lum=0.299*d[i*4]+0.587*d[i*4+1]+0.114*d[i*4+2];pix.push(lum);sum+=lum} |
| var avg=sum/pix.length,hash=0;for(var j=0;j<pix.length;j++)hash=(hash<<1)|(pix[j]>avg?1:0); |
| var b=[0,0,0,0,0,0,0,0],s2=0;for(var k=0;k<256;k++){var l2=0.299*d[k*4]+0.587*d[k*4+1]+0.114*d[k*4+2];b[Math.min(7,Math.floor(l2/32))]++;s2++} |
| for(var m=0;m<8;m++)b[m]/=s2; |
| var best=null,bestD=1e9;DB.refs.forEach(function(r){var dist=hamming(hash,r.hash)+0.5*histDist(b,r.hist);if(dist<bestD){bestD=dist;best=r}}); |
| if(!best||bestD>24)return null; |
| return{cls:best.cls,conf:clamp(1-bestD/24,0,1)}; |
| } |
| var STEP={dry:0,drying:1,damp:2,wet:3}; |
| function classifyFrame(f){ |
| if(state.baseFrames.length<4){state.baseFrames.push(f.L);if(state.baseFrames.length===4)state.baseL=state.baseFrames.reduce(function(a,b){return a+b},0)/4} |
| var dL=state.baseL!==null?f.L-state.baseL:0,dLN=clamp(dL/60,-1,1); |
| var specN=clamp(f.spec*6,0,1),smoothN=clamp(f.smooth,0,1),streakN=f.streak,coolN=clamp((f.cool+0.2)/0.5,0,1),patchN=normN(f.patch,2500),colVarN=normN(f.colVar,4000); |
| var st="dry",reason="texture: dry matte surface"; |
| if(dLN<-0.10&&specN<0.15&&streakN<1.0){st=(state.locked==="wet"||state.locked==="damp")?"damp":"dry";reason="dark patch, no reflections — shade or rubber, not water"} |
| else if(specN>0.35&&streakN>1.3&&smoothN>0.55){st="wet";reason="glints + streak reflections: standing water"} |
| else if(colVarN>0.35&&streakN<1.1){st="drying";reason="dry racing line forming"} |
| else if(patchN>0.30&&coolN>0.25&&smoothN>0.40){st="damp";reason="patchy moisture"} |
| var wxUsed=false,rain=V.wxRain||0.2; |
| if(state.applyWx){wxUsed=true;if(rain>0.7&&(st==="dry"||st==="drying")){st="damp";reason="wet weather prior"}else if(rain<0.3&&st==="wet"&&specN<0.25){st="damp";reason="dry prior softens weak water signal"}} |
| var db=dbMatch();if(db&&db.conf>=0.65&&Math.abs(STEP[st]-STEP[db.cls])<=1){st=db.cls;reason="reference DB ("+db.cls+")"} |
| state.win.push(st);if(state.win.length>6)state.win.shift(); |
| var cand=st;if(state.locked&&cand!==state.locked){var votes=state.win.filter(function(x){return x===cand}).length;if(votes<4)cand=state.locked} |
| state.locked=cand; |
| return{st:cand,dL:dL,specN:specN,patchN:patchN,reason:reason,wxUsed:wxUsed,rain:rain}; |
| } |
| |
| |
| var tcv=$("trendChart"),tcx=tcv.getContext("2d"),chart=[]; |
| var colors={wet:"#d7263d",damp:"#2f6db3",drying:"#e8a13c",dry:"#2e9e5b"}; |
| function drawChart(){ |
| var w=tcv.clientWidth||600,h=tcv.clientHeight||180,dpr=window.devicePixelRatio||1; |
| tcv.width=w*dpr;tcv.height=h*dpr;tcx.setTransform(dpr,0,0,dpr,0,0);tcx.clearRect(0,0,w,h); |
| tcx.strokeStyle="#d8d0be";for(var i=0;i<=4;i++){var y=h*i/4;tcx.beginPath();tcx.moveTo(0,y);tcx.lineTo(w,y);tcx.stroke()} |
| tcx.fillStyle="#8a8372";tcx.font="9px JetBrains Mono, monospace";tcx.fillText("WET",8,14);tcx.fillText("DRY",8,h-8); |
| if(chart.length<2)return; |
| var pts=chart.length,last=null; |
| for(var p=0;p<pts;p++){var x=p/(pts-1)*w,y=h-(chart[p].ratio*h);tcx.fillStyle=colors[chart[p].st]||"#2f6db3";tcx.globalAlpha=.5;tcx.beginPath();tcx.arc(x,y,1.6,0,Math.PI*2);tcx.fill();tcx.globalAlpha=1;if(last){tcx.strokeStyle=colors[chart[p].st]||"#2f6db3";tcx.lineWidth=1.4;tcx.beginPath();tcx.moveTo(last.x,last.y);tcx.lineTo(x,y);tcx.stroke()}last={x:x,y:y}} |
| } |
| |
| |
| function analyze(){ |
| if(!state.procOn)return; |
| var f=feats();if(!f)return; |
| state.frame++; |
| var cl=classifyFrame(f),st=cl.st; |
| var apiV=null; |
| if(API.streak>=2&&API.state){apiV=API.state;st=API.state;cl.reason="API CLIP verdict ("+API.verdict+")"} |
| var ratio=clamp(0.45*cl.specN+0.4*(cl.specN)+0.15*cl.patchN,0,1); |
| var db=dbMatch(),dbTxt=db?db.cls.toUpperCase()+" · "+(db.conf*100).toFixed(0)+"%":"—"; |
| $("mDb").textContent=dbTxt; |
| var conf=apiV?0.9:db?db.conf:Math.max(0.3,1-Math.abs(cl.dL/60)); |
| chart.push({st:st,ratio:ratio});if(chart.length>420)chart.shift();drawChart(); |
| $("mFrame").textContent=state.frame; |
| $("mState").textContent=st.toUpperCase(); |
| $("mWet").innerHTML=(ratio*100).toFixed(0)+"<small>%</small>"; |
| $("mDry").innerHTML=((1-ratio)*100).toFixed(0)+"<small>%</small>"; |
| $("mConf").innerHTML=(conf*100).toFixed(0)+"<small>%</small>"; |
| var sb=$("stateBadge");sb.textContent=st.toUpperCase();sb.className=st; |
| var tire=VV.TIRES[+($("tireSel").value||0)]||VV.TIRES[0]; |
| var okTire=tire.states.indexOf(st)>=0; |
| $("whyLine").innerHTML="<b>Verdict:</b> "+st.toUpperCase()+" — "+cl.reason+ |
| "<br/><b>Engine:</b> "+(apiV?"HF Inference API (CLIP)":V.hasAPI()?"API warm-up → heuristic":"client heuristic")+" · <b>DB:</b> "+dbTxt+ |
| (cl.wxUsed?" · <b>weather prior</b> "+(cl.rain*100).toFixed(0)+"%":"")+ |
| "<br/><b>Tyre check:</b> "+tire.name+" → "+(okTire?"suitable":"<span style='color:var(--red)'>NOT suitable</span> for "+st.toUpperCase()); |
| var pc=$("pitCall"),py=$("pcYes"),pn=$("pcNo"); |
| if(okTire){pc.textContent="PIT CALL · STAY OUT";pc.className="pitCall ok";py.classList.add("hide");pn.classList.add("hide")} |
| else{var rec=VV.TIRES.filter(function(t){return t.states.indexOf(st)>=0})[0]; |
| pc.textContent="PIT CALL · SWITCH TO "+rec.name.toUpperCase();pc.className="pitCall go"; |
| py.classList.remove("hide");pn.classList.remove("hide"); |
| py.onclick=function(){$("tireSel").value=String(VV.TIRES.indexOf(rec));toast("Compound → "+rec.name);py.classList.add("hide");pn.classList.add("hide");pc.textContent="PIT CALL · SWITCHED TO "+rec.name.toUpperCase();pc.className="pitCall ok"}; |
| pn.onclick=function(){py.classList.add("hide");pn.classList.add("hide");pc.textContent="PIT CALL · DENIED";pc.className="pitCall"}} |
| if(Date.now()-state.lastGall>1000){state.lastGall=Date.now();try{var c=document.createElement("canvas");c.width=320;c.height=180;c.getContext("2d").drawImage(vid,0,0,320,180);var cap=document.createElement("div");cap.className="galItem";cap.innerHTML='<img src="'+c.toDataURL("image/jpeg",.6)+'" alt="frame"/><div class="cap"><div class="t">'+st.toUpperCase()+' · '+(apiV?"API":"heuristic")+'</div><div class="s">Frame '+state.frame+'</div></div>';var gal=$("gal");while(gal.firstChild&&gal.children.length>=12)gal.removeChild(gal.firstChild);gal.appendChild(cap)}catch(e){}} |
| V.lastVision={state:st,conf:conf,ratio:ratio,frame:state.frame,db:dbTxt,reason:cl.reason,wx:cl.wxUsed}; |
| if(V.hasAPI()){var c2=document.createElement("canvas");c2.width=224;c2.height=126;c2.getContext("2d").drawImage(vid,0,0,224,126);apiVision(c2)} |
| if(V.intelTick)V.intelTick(); |
| } |
| |
| |
| function loop(){if(!state.running){state.raf=null;return}analyze();state.raf=requestAnimationFrame(loop)} |
| function resetVision(){state.frame=0;state.win=[];state.locked=null;state.baseFrames=[];state.baseL=null;chart=[];API.streak=0;API.state=null;API.verdict="—";$("mFrame").textContent="0";$("mState").textContent="—";$("mWet").innerHTML='0<small>%</small>';$("mDry").innerHTML='0<small>%</small>';$("mConf").innerHTML='0<small>%</small>';$("mDb").textContent="—";$("stateBadge").textContent="—";$("stateBadge").className="";$("whyLine").textContent="Analysis reset — new feed loaded.";var pc=$("pitCall");pc.textContent="PIT CALL · —";pc.className="pitCall";$("pcYes").classList.add("hide");$("pcNo").classList.add("hide");tcx.clearRect(0,0,tcv.width,tcv.height)} |
| function stopAll(){state.running=false;state.procOn=false;if(state.raf){cancelAnimationFrame(state.raf);state.raf=null}try{vid.pause()}catch(e){}if(state.stream){state.stream.getTracks().forEach(function(t){t.stop()});state.stream=null}} |
| $("vidBtn").onclick=function(){$("vidIn").click()}; |
| $("vidIn").onchange=function(e){var f=e.target.files[0];if(!f)return;resetVision();stopAll();state.applyWx=!!($("wxPriorChk")&&$("wxPriorChk").checked);vid.src=URL.createObjectURL(f);vid.loop=false;vid.onloadeddata=function(){state.running=true;state.procOn=true;stagePh.classList.add("hide");vid.classList.remove("hide");vid.play().catch(function(){});if(!state.raf)state.raf=requestAnimationFrame(loop)};vid.onended=function(){state.procOn=false;if(state.raf){cancelAnimationFrame(state.raf);state.raf=null};toast("Footage analysed once — upload again for a new run")};toast("Video loaded — analysing frame by frame")}; |
| $("camBtn").onclick=function(){var nav=navigator.mediaDevices;if(!nav||!nav.getUserMedia){toast("Camera not available");return}nav.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:false}).then(function(s){resetVision();stopAll();state.stream=s;vid.srcObject=s;vid.loop=true;state.applyWx=true;if($("wxPriorChk"))$("wxPriorChk").checked=true;vid.onloadeddata=function(){state.running=true;state.procOn=true;stagePh.classList.add("hide");vid.classList.remove("hide");vid.play().catch(function(){});if(!state.raf)state.raf=requestAnimationFrame(loop)};toast("Live camera online — API mode "+(V.hasAPI()?"active":"needs token"))}).catch(function(){toast("Camera access denied")})}; |
| $("stopBtn").onclick=function(){stopAll();toast("Feed stopped — Resume continues")}; |
| $("resumeBtn").onclick=function(){if(!state.running){state.running=true;state.procOn=true;vid.play().catch(function(){});if(!state.raf)state.raf=requestAnimationFrame(loop)}toast("Resumed")}; |
| if($("wxPriorChk"))$("wxPriorChk").addEventListener("change",function(){state.applyWx=this.checked;toast(this.checked?"Weather prior ON":"Weather prior OFF")}); |
| setStatus(V.hasAPI()?"API READY — paste token in Settings if missing":"CLASSIFIER · heuristic (add token for API accuracy)","ok"); |
| })(VV); |
| }catch(err){var b=VV.$("errBanner");if(b){b.style.display="block";b.textContent="⚠ VisionEngine: "+err.message}console.error("VisionEngine:",err)} |
| </script> |
| <script> |
| "use strict"; |
| |
| try{ |
| (function(V){ |
| var $=V.$; |
| function loadT(){return V.Models&&V.Models.ready?Promise.resolve(V.Models.T): |
| import("https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1").then(function(m){ |
| var env=m.env; |
| try{env.localModelPath="./models/"}catch(e){} |
| try{env.allowLocalModels=true}catch(e){} |
| try{env.allowRemoteModels=true}catch(e){} |
| try{env.backends.onnx.wasm.wasmPaths="https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1/dist/"}catch(e){} |
| V.Models.T=m;V.Models.ready=true;return m; |
| })} |
| function loadPipe(task,model,opts){return loadT().then(function(m){return m.pipeline(task,model,opts||{})})} |
| function withTimeout(p,ms){return Promise.race([p,new Promise(function(_,rej){setTimeout(function(){rej(new Error("timeout"))},ms)})])} |
| function apiHeaders(){return{Authorization:"Bearer "+V.cfg.token}} |
| |
| |
| function apiTranscribe(blob){ |
| return fetch("https://api-inference.huggingface.co/models/openai/whisper-small",{method:"POST",headers:apiHeaders(),body:blob}) |
| .then(function(r){if(!r.ok)throw new Error("API "+r.status);return r.json()}) |
| .then(function(j){return j&&j.text||""}); |
| } |
| var SER_LABELS={angry:"angry",calm:"calm",disgust:"frustrated",fear:"afraid",fearful:"afraid",happy:"happy",neutral:"neutral",sad:"sad",sadness:"sad",surprise:"excited",surprised:"excited"}; |
| function mapSerLabel(l){ |
| var k=String(l||"").toLowerCase().trim(); |
| return SER_LABELS[k]||(k.indexOf("ang")===0?"angry":k.indexOf("cal")===0?"calm":k.indexOf("fear")===0?"afraid":k.indexOf("hap")===0?"happy":k.indexOf("neu")===0?"neutral":k.indexOf("sad")===0?"sad":k.indexOf("sur")===0?"excited":"neutral"); |
| } |
| function apiEmotion(blob){ |
| return fetch("https://api-inference.huggingface.co/models/ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition",{method:"POST",headers:apiHeaders(),body:blob}) |
| .then(function(r){if(!r.ok)throw new Error("API "+r.status);return r.json()}) |
| .then(function(out){return (out||[]).map(function(o){return{emo:mapSerLabel(o.label),conf:o.score}})||[]}); |
| } |
| |
| |
| var ASR={pipe:null,mode:"none"}; |
| function ensureASR(){ |
| if(ASR.pipe||ASR._busy)return ASR._busy||Promise.resolve(); |
| V.toast("Loading client transcript AI (fallback)…"); |
| ASR._busy=withTimeout(loadPipe("automatic-speech-recognition","Xenova/wav2vec2-base-960h"),60000) |
| .then(function(p){ASR.pipe=p;ASR.mode="base";V.toast("Client transcript AI ready")}) |
| .catch(function(){ASR.mode="none"}).then(function(){ASR._busy=null}); |
| return ASR._busy; |
| } |
| var AST={pipe:null}; |
| function ensureAST(){if(AST.pipe||AST._busy)return AST._busy||Promise.resolve();AST._busy=withTimeout(loadPipe("audio-classification","Xenova/ast-finetuned-audioset-10-10-0.4593"),60000).then(function(p){AST.pipe=p}).catch(function(){}).then(function(){AST._busy=null});return AST._busy} |
| var SER1={pipe:null},SER2={pipe:null}; |
| function ensureSERs(){ |
| if((SER1.pipe&&SER2.pipe)||SER._busy)return SER._busy||Promise.resolve(); |
| SER._busy=withTimeout(loadPipe("audio-classification","onnx-community/wav2vec2-base-Speech_Emotion_Recognition-ONNX",{dtype:"q4"}),60000) |
| .then(function(p){SER1.pipe=p}).catch(function(){}) |
| .then(function(){return withTimeout(loadPipe("audio-classification","onnx-community/Speech-Emotion-Classification-ONNX",{dtype:"q4"}),60000).then(function(p){SER2.pipe=p}).catch(function(){})}) |
| .then(function(){SER._busy=null}); |
| return SER._busy; |
| } |
| |
| |
| var EMO_DB={loaded:false,refs:[]}; |
| var EMO_LABELS={neutral:"neutral",calm:"calm",happy:"happy",sad:"sad",angry:"angry",fearful:"afraid",surprised:"excited",disgust:"frustrated"}; |
| function fetchAudio(url){return fetch(url).then(function(r){return r.ok?r.arrayBuffer():null}).then(function(ab){return ab?ctx().decodeAudioData(ab).then(mixdown).catch(function(){return null}):null})} |
| function loadEmoDB(){ |
| if(EMO_DB.loaded||EMO_DB._busy)return; |
| EMO_DB._busy=true; |
| fetch("https://datasets-server.huggingface.co/rows?dataset=xbgoose/ravdess&config=default&split=train&offset=0&length=100").then(function(r){return r.json()}).then(function(data){ |
| if(!data||!data.rows)return; |
| var gathered=[],seen={}; |
| data.rows.forEach(function(item){var raw=item.row.emotion||item.row.label;var src=item.row.audio&&item.row.audio.src;var cls=EMO_LABELS[String(raw).toLowerCase()];if(!src||!cls||(seen[cls]||0)>=2)return;seen[cls]=(seen[cls]||0)+1;gathered.push({emo:cls,src:src})}); |
| var jobs=gathered.map(function(g){return fetchAudio(g.src).then(function(buf){return buf?{emo:g.emo,vec:acoustic(buf)}:null})}); |
| return Promise.all(jobs); |
| }).then(function(list){EMO_DB.refs=(list||[]).filter(Boolean);EMO_DB.loaded=EMO_DB.refs.length>=6;EMO_DB._busy=false;if(EMO_DB.loaded){var c={};EMO_DB.refs.forEach(function(r){c[r.emo]=(c[r.emo]||0)+1});V.toast("Emotion clip DB ready: "+Object.keys(c).map(function(k){return k+"×"+c[k]}).join(" "))}}).catch(function(){EMO_DB._busy=false}); |
| } |
| function emoDBMatch(buf){if(!EMO_DB.loaded)return null;var v=acoustic(buf),best=null,bestD=1e9;EMO_DB.refs.forEach(function(r){var d=0.3*Math.abs(v.loud-r.vec.loud)+0.3*Math.abs(v.rate-r.vec.rate)+0.25*Math.abs(v.pv-r.vec.pv)+0.15*Math.abs(v.breathy-r.vec.breathy);if(d<bestD){bestD=d;best=r}});if(!best)return null;return{emo:best.emo,conf:Math.max(0,1-bestD/0.8)}} |
| |
| |
| var Ctx=null; |
| function ctx(){if(!Ctx)Ctx=new(window.AudioContext||window.webkitAudioContext)();if(Ctx.state==="suspended")Ctx.resume();return Ctx} |
| function mixdown(buf){if(!buf||buf.numberOfChannels===1)return buf;var n=buf.length,sr=buf.sampleRate,out=ctx().createBuffer(1,n,sr);var od=out.getChannelData(0),chs=[];for(var c=0;c<buf.numberOfChannels;c++)chs.push(buf.getChannelData(c));for(var i=0;i<n;i++){var s=0;for(var k=0;k<chs.length;k++)s+=chs[k][i];od[i]=s/chs.length}return out} |
| function resample16k(buf){var src=buf.getChannelData(0),sr=buf.sampleRate,step=sr/16000;var out=new Float32Array(Math.max(1,Math.ceil(src.length/step)));for(var i=0;i<out.length;i++)out[i]=src[Math.min(src.length-1,Math.floor(i*step))];return out} |
| function decode(file){return new Promise(function(res){var fr=new FileReader();fr.onload=function(){ctx().decodeAudioData(fr.result).then(function(b){res(mixdown(b))}).catch(function(){res(null)})};fr.readAsArrayBuffer(file)})} |
| function acoustic(buf){ |
| var data=buf.getChannelData(0),n=data.length,sr=buf.sampleRate; |
| if(!n)return{loud:.5,rate:.5,pv:.3,breathy:.4}; |
| var frame=2048,hop=512,frames=Math.max(1,Math.floor((n-frame)/hop)),rmsArr=[],pitchArr=[],voiced=0,i,j,k; |
| for(i=0;i<frames;i++){var start=i*hop,sum=0;for(j=0;j<frame;j++){var s=data[start+j];sum+=s*s}rmsArr.push(Math.sqrt(sum/frame));var ac=new Float32Array(Math.floor(frame/2));for(k=0;k<ac.length;k++){var a=0;for(var t=0;t<ac.length;t++)a+=data[start+t]*data[start+t+k];ac[k]=a}var tau0=Math.max(1,Math.floor(sr/400)),tau1=Math.min(ac.length-1,Math.floor(sr/80)),best=0,bestVal=1e9;for(var t2=tau0;t2<tau1;t2++){var cm=ac[0]>1e-9?ac[t2]/ac[0]:1;if(cm<bestVal){bestVal=cm;best=t2}}var f0=best>0?sr/best:0;if(f0>90&&f0<380&&rmsArr[rmsArr.length-1]>0.015){pitchArr.push(f0);voiced++}} |
| var rmsMed=rmsArr.slice().sort(function(a,b){return a-b})[Math.floor(rmsArr.length/2)]||0; |
| var pitch=pitchArr.length?pitchArr.reduce(function(a,b){return a+b},0)/pitchArr.length:0; |
| var pVar=0;if(pitchArr.length){for(i=0;i<pitchArr.length;i++)pVar+=(pitchArr[i]-pitch)*(pitchArr[i]-pitch);pVar=Math.sqrt(pVar/pitchArr.length)/pitch} |
| return{loud:Math.min(1,rmsMed*8),rate:Math.min(1,(voiced/frames)*2.2),pv:Math.min(1,pVar*6),breathy:Math.min(1,Math.max(0,1-pVar*6))}; |
| } |
| |
| |
| var EMOTIONS={neutral:"#8b97a8",calm:"#2f6db3",focused:"#2e9e5b",happy:"#e8a13c",excited:"#d97706",frustrated:"#7c3aed",stressed:"#e11d48",angry:"#d7263d",sarcastic:"#c026d3",afraid:"#4f46e5",sad:"#64748b"}; |
| var LEX={ |
| angry:["fucking","bloody hell","idiot","stupid","what the hell","come on","wake up","useless","shut up","ridiculous","joke","unbelievable","fuming","angry"], |
| frustrated:["can't","cannot","no grip","not working","something's wrong","lost it","spinning","understeer","oversteer","struggling","struggle","terrible","awful","bad","slow","pain"], |
| stressed:["pressure","push","under pressure","hurry","quick quick","no time","tight","closing","faster","go go go","they're catching","box box box","must","need","worried","anxious","stress"], |
| afraid:["scared","fear","dangerous","scary","careful","risk","crash","impact","avoid","afraid","frightened","oh no"], |
| happy:["great","nice","good job","perfect","love","awesome","fantastic","brilliant","superb","well done","beautiful","thank you","amazing"], |
| excited:["wow","let's go","yes yes","come on come on","let's push","attack","charge","overtake","hype","pumped","yess"], |
| sarcastic:["sure","yeah right","obviously","of course","great job","nice one","well done","as usual","typical","really","clearly","naturally","surely","funny","hilarious"] |
| }; |
| function lexScore(txt,words){var t=" "+(txt||"").toLowerCase()+" ",s=0;words.forEach(function(w){if(t.indexOf(w)>=0)s++});return s} |
| function normLabel(l){l=(l||"").toUpperCase().replace(/[^A-Z]/g,"");if(l.indexOf("ANG")===0)return"angry";if(l.indexOf("CAL")===0)return"calm";if(l.indexOf("DIS")===0)return"frustrated";if(l.indexOf("FEA")===0)return"afraid";if(l.indexOf("HAP")===0)return"happy";if(l.indexOf("NEU")===0)return"neutral";if(l.indexOf("SAD")===0)return"sad";if(l.indexOf("SUR")===0)return"excited";return"neutral"} |
| function emotionEngine(txt,ac,ast,serVotes,db){ |
| var scores={};Object.keys(LEX).forEach(function(k){scores[k]=lexScore(txt,LEX[k])}); |
| var top=null,topV=0;Object.keys(scores).forEach(function(k){if(scores[k]>topV){topV=scores[k];top=k}}); |
| var serAgg={},serTop=null,serConf=0; |
| (serVotes||[]).forEach(function(v){if(v&&v.conf>=0.55)serAgg[v.emo]=(serAgg[v.emo]||0)+v.conf}); |
| Object.keys(serAgg).forEach(function(e){if(serAgg[e]>serConf){serConf=serAgg[e];serTop=e}}); |
| var dbEmo=db&&db.conf>=0.55?db.emo:null,dbConf=db?db.conf:0; |
| var emo="neutral",conf=.5,why="No strong signal — neutral."; |
| if(topV>0){ |
| if(top==="sarcastic"){if(ac.pv<0.35){emo="sarcastic";conf=.72;why="Irony + flat tone → sarcastic."}else if(ac.loud>0.7){emo="angry";conf=.66;why="Negative words + loud delivery → angry."}else{emo="sarcastic";conf=.55;why="Irony cues with neutral tone."}} |
| else if(top==="angry"){if(ac.loud>0.65&&ac.pv>0.4){emo="angry";conf=.8;why="Aggressive lexicon + loud variable pitch → angry."}else{emo="frustrated";conf=.6;why="Harsh words, controlled tone → frustrated."}} |
| else if(top==="stressed"){if(ac.rate>0.6&&ac.pv>0.35){emo="stressed";conf=.75;why="Urgency words + fast shaky delivery → stressed."}else{emo="frustrated";conf=.5;why="Urgency words, steady delivery → frustrated."}} |
| else if(top==="afraid"){emo="afraid";conf=.7;why="Fear/risk lexicon present."} |
| else if(top==="happy"){emo=(ac.pv>0.4&&ac.loud>0.5)?"excited":"happy";conf=.7;why="Positive lexicon"+(emo==="excited"?" + energetic delivery":"")+"."} |
| else if(top==="excited"){emo="excited";conf=.7;why="High-energy positive lexicon."} |
| else if(top==="frustrated"){emo="frustrated";conf=.62;why="Complaint/struggle lexicon."} |
| if(serTop&&serTop!==emo&&serConf>0.7)why+=" (SER says "+serTop+")"; |
| }else if(serTop){emo=serTop;conf=Math.min(1,serConf);why="Speech-emotion model: "+emo+" (score "+(serConf*100).toFixed(0)+"%)."+(dbEmo===emo?" Emotion clip DB agrees.":"");if(dbEmo===emo)conf=Math.min(1,conf+0.08)} |
| else if(dbEmo){emo=dbEmo;conf=dbConf;why="Emotion clip DB match: "+emo+" (acoustic fingerprint)."} |
| else{if(ac.loud>0.7&&ac.rate>0.7&&ac.pv>0.45){emo="stressed";conf=.5;why="Very high arousal, no words — acoustic stress."}else if(ac.pv>0.5&&ac.loud>0.5){emo="excited";conf=.45;why="High pitch variability + loudness (acoustic)."}else if(ac.loud<0.25&&ac.rate<0.3){emo="calm";conf=.5;why="Low energy, steady delivery → calm."}} |
| return{emo:emo,conf:conf,why:why,scores:scores}; |
| } |
| |
| |
| var RACING_LEXICON=[ |
| [/bocks? bocks? bocks?/gi,"box box box"],[/bocks? bocks?/gi,"box box"],[/pops? bocks?/gi,"box box"], |
| [/in the media/gi,"intermediates"],[/intermittent/gi,"intermediates"],[/intermediate is/gi,"intermediates"],[/in to the media/gi,"intermediates"], |
| [/under steer/gi,"understeer"],[/over steer/gi,"oversteer"],[/graining/gi,"graining"],[/grain ing/gi,"graining"], |
| [/d r s/gi,"DRS"],[/kerbs?/gi,"kerbs"],[/front left/gi,"front left"],[/front right/gi,"front right"], |
| [/box now/gi,"box now"],[/stay out/gi,"stay out"],[/tire(s)?/gi,"tyre$1"] |
| ]; |
| function correctTranscript(txt){if(!txt)return{text:"",fixes:[]};var out=txt,fixes=[];RACING_LEXICON.forEach(function(f){if(f[0].test(out)){out=out.replace(f[0],f[1]);if(fixes.indexOf(f[1])<0)fixes.push(f[1])}});return{text:out,fixes:fixes}} |
| |
| |
| var audioState=null,lastEmo=null,lastTxt="",lastAst=[],lastFeat=null,lastDur=0; |
| function resetAudio(){lastEmo=null;lastTxt="";lastAst=[];lastFeat=null;lastDur=0;$("tranOut").innerHTML='<span class="ph">Transcript appears here.</span>';$("emoBig").innerHTML='<div class="emotionBig" style="color:var(--ink2);font-size:22px">Awaiting clip</div>';$("emoWhy").textContent="Load a clip and press Analyze.";$("emoBars").innerHTML="";$("astOut").textContent="Waiting…";$("featOut").textContent="—"} |
| function fmtLap(sec){if(!isFinite(sec)||sec<=0)return"";var mm=Math.floor(sec/60),ss=Math.floor(sec%60),ms=Math.floor((sec%1)*1000);function p2(n){return(n<10?"0":"")+n}function p3(n){return(n<10?"00":n<100?"0":"")+n}return p2(mm)+":"+p2(ss)+"."+p3(ms)} |
| function esc(s){return String(s).replace(/[&<>"]/g,function(c){return{"&":"&","<":"<",">":">",'"':"""}[c]})} |
| |
| |
| async function analyzeAudio(){ |
| var btn=$("analyzeBtn"); |
| try{ |
| var f=audioState; |
| if(!f){V.toast("Choose an audio clip first");return} |
| resetAudio(); |
| btn.disabled=true;btn.textContent="Decoding…"; |
| var buf=await decode(f); |
| if(!buf){V.toast("Could not decode this file");return} |
| lastDur=buf.duration||0; |
| if(!$("lapIn").value)$("lapIn").value=fmtLap(lastDur); |
| var pcm=resample16k(buf); |
| var asrPcm=pcm.subarray(0,Math.min(pcm.length,16000*30)); |
| var serPcm=pcm.subarray(0,Math.min(pcm.length,16000*8)); |
| var txt="",serVotes=[],ast=[],usedAPI=false; |
| if(V.hasAPI()){ |
| btn.textContent="Sending to HF API…"; |
| $("tranOut").innerHTML='<span class="ph">Running Whisper + SER on Hugging Face…</span>'; |
| |
| var wavBlob=encodeWav(serPcm,16000); |
| var apiRes=await Promise.allSettled([ |
| withTimeout(apiTranscribe(encodeWav(asrPcm,16000)),60000), |
| withTimeout(apiEmotion(wavBlob),30000) |
| ]); |
| if(apiRes[0].status==="fulfilled")txt=apiRes[0].value; |
| if(apiRes[1].status==="fulfilled")serVotes=apiRes[1].value.slice(0,3); |
| usedAPI=true; |
| } |
| if(!txt&&!V.hasAPI()){ |
| |
| btn.textContent="Loading models…"; |
| $("tranOut").innerHTML='<span class="ph">Loading speech models (first run only)…</span>'; |
| await Promise.all([ensureASR(),ensureAST(),ensureSERs(),loadEmoDB()]); |
| btn.textContent="Analysing…"; |
| $("tranOut").innerHTML='<span class="ph">Running transcript + emotion…</span>'; |
| var res=await Promise.allSettled([ |
| ASR.pipe?withTimeout(ASR.pipe(asrPcm),45000):Promise.resolve(null), |
| AST.pipe?withTimeout(AST.pipe(pcm,{top_k:5}),15000):Promise.resolve(null), |
| SER1.pipe?withTimeout(SER1.pipe(serPcm),15000):Promise.resolve(null), |
| SER2.pipe?withTimeout(SER2.pipe(serPcm),15000):Promise.resolve(null) |
| ]); |
| if(res[0].status==="fulfilled"&&res[0].value)txt=res[0].value.text||""; |
| if(res[1].status==="fulfilled"&&res[1].value)ast=res[1].value; |
| if(res[2].status==="fulfilled"&&res[2].value&&res[2].value[0])serVotes.push({emo:normLabel(res[2].value[0].label),conf:res[2].value[0].score}); |
| if(res[3].status==="fulfilled"&&res[3].value&&res[3].value[0])serVotes.push({emo:normLabel(res[3].value[0].label),conf:res[3].value[0].score}); |
| } |
| var corr=correctTranscript(txt);txt=corr.text; |
| lastTxt=txt;lastAst=ast; |
| var feat=acoustic(buf);lastFeat=feat; |
| var db=emoDBMatch(buf); |
| var res2=emotionEngine(txt,feat,ast,serVotes,db); |
| lastEmo=res2; |
| $("tranOut").innerHTML=txt?esc(txt):'<span class="ph">No speech recognised — engine/tyre noise dominant.</span>'; |
| $("emoBig").innerHTML='<div class="emotionBig" style="color:'+EMOTIONS[res2.emo]+'">'+res2.emo.toUpperCase()+'</div>'; |
| $("emoWhy").textContent=res2.why; |
| var order=["happy","excited","calm","neutral","frustrated","stressed","angry","sarcastic","afraid","sad"]; |
| var max=Math.max(1,res2.scores.sarcastic||0,res2.scores.angry||0,res2.scores.stressed||0,res2.scores.happy||0,res2.scores.excited||0,res2.scores.frustrated||0,res2.scores.afraid||0); |
| var bars=""; |
| order.forEach(function(k){var v=res2.scores[k]||0,frac=Math.min(1,v/max);bars+='<div class="bar"><span>'+k.toUpperCase()+'</span><div class="track"><div class="fill" style="width:'+(frac*100)+'%;background:'+(k===res2.emo?EMOTIONS[k]:'#d8d0be')+'"></div></div><span>'+v+'</span></div>'}); |
| $("emoBars").innerHTML=bars; |
| $("astOut").innerHTML=(usedAPI?"Whisper-small transcript + wav2vec2-large SER (HF API)":ast.length?ast.map(function(a){return esc(a.label)+" · "+(a.score*100).toFixed(0)+"%"}).join(" | "):"client models")+(corr.fixes.length?"<br/>Lexicon fixes: "+corr.fixes.join(", "):""); |
| var serLine=serVotes.length?serVotes.map(function(v){return v.emo+" "+(v.conf*100).toFixed(0)+"%"}).join(" | "):"none"; |
| $("featOut").innerHTML="Mode: "+(usedAPI?"API":(ASR.mode||"client"))+" · SER: "+serLine; |
| V.lastAudio={emo:res2.emo,conf:res2.conf,text:txt,why:res2.why,lap:$("lapIn").value||fmtLap(lastDur)}; |
| if(V.intelTick)V.intelTick(); |
| }catch(err){ |
| console.error("analyzeAudio:",err); |
| $("tranOut").innerHTML='<span class="ph" style="color:var(--red)">Analysis error: '+esc(err&&err.message||err)+'</span>'; |
| }finally{btn.disabled=false;btn.textContent="Analyze clip"} |
| } |
| |
| |
| function encodeWav(pcm,sr){ |
| var n=pcm.length,buf=new ArrayBuffer(44+n*2),v=new DataView(buf); |
| function w(off,s){for(var i=0;i<s.length;i++)v.setUint8(off+i,s.charCodeAt(i))} |
| w(0,"RIFF");v.setUint32(4,36+n*2,true);w(8,"WAVE");w(12,"fmt "); |
| v.setUint32(16,16,true);v.setUint16(20,1,true);v.setUint16(22,1,true); |
| v.setUint32(24,sr,true);v.setUint32(28,sr*2,true);v.setUint16(32,2,true);v.setUint16(34,16,true); |
| w(36,"data");v.setUint32(40,n*2,true); |
| for(var i=0;i<n;i++){var s=Math.max(-1,Math.min(1,pcm[i]));v.setInt16(44+i*2,s<0?s*0x8000:s*0x7FFF,true)} |
| return new Blob([buf],{type:"audio/wav"}); |
| } |
| |
| |
| function loadClips(){try{return JSON.parse(localStorage.getItem("vaneview_clips")||"[]")}catch(e){return[]}} |
| function saveClips(c){localStorage.setItem("vaneview_clips",JSON.stringify(c))} |
| function renderClips(){ |
| var list=loadClips(),box=$("clipsList"); |
| if(!list.length){box.innerHTML='<p class="sub">No clips saved yet.</p>';return} |
| box.innerHTML=""; |
| list.slice().reverse().forEach(function(c){var d=document.createElement("div");d.className="clipRow";var icon={happy:"😄",excited:"🤩",calm:"😌",neutral:"😐",focused:"🎯",frustrated:"😤",stressed:"😰",angry:"😡",sarcastic:"🙄",afraid:"😨",sad:"😢"}[c.emo]||"🎙️";d.innerHTML='<div class="emo">'+icon+'</div><div class="meta"><div class="t">'+esc(c.text||"(no transcript)")+'</div><div class="s">'+c.emo.toUpperCase()+' · '+(c.lap||"—")+' · '+new Date(c.ts).toLocaleString()+'</div></div>';box.appendChild(d)}); |
| } |
| $("saveClipBtn").onclick=function(){if(!lastEmo){V.toast("Analyze a clip first");return}var clips=loadClips();clips.push({emo:lastEmo.emo,conf:lastEmo.conf,text:lastTxt,why:lastEmo.why,lap:$("lapIn").value||fmtLap(lastDur),ts:Date.now()});saveClips(clips);renderClips();V.toast("Clip saved to library")}; |
| |
| |
| var dropEl=$("audioDrop"); |
| function acceptAudio(f){if(f&&f.type&&f.type.indexOf("audio/")!==0&&f.name.indexOf(".mp3")<0&&f.name.indexOf(".wav")<0&&f.name.indexOf(".m4a")<0&&f.name.indexOf(".ogg")<0&&f.name.indexOf(".flac")<0){V.toast("That doesn't look like an audio file");return}resetAudio();audioState=f;$("audioDrop").querySelector("p").textContent=f.name+" ("+(f.size/1048576).toFixed(1)+" MB)"} |
| ["dragenter","dragover"].forEach(function(ev){dropEl.addEventListener(ev,function(e){e.preventDefault();e.stopPropagation();dropEl.style.borderColor="var(--red)";dropEl.querySelector("p").textContent="Release to load the clip"})}); |
| ["dragleave","drop"].forEach(function(ev){dropEl.addEventListener(ev,function(e){e.preventDefault();e.stopPropagation();dropEl.style.borderColor="";dropEl.querySelector("p").textContent="Drop a driver radio clip here, or"})}); |
| dropEl.addEventListener("drop",function(e){e.preventDefault();e.stopPropagation();dropEl.style.borderColor="";var f=e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files[0];if(f)acceptAudio(f)}); |
| $("audioIn").addEventListener("change",function(e){var f=e.target.files[0];if(f)acceptAudio(f)}); |
| $("audioDrop").onclick=function(){$("audioIn").click()}; |
| $("audioBtn").onclick=function(e){e.stopPropagation();$("audioIn").click()}; |
| $("analyzeBtn").onclick=analyzeAudio; |
| renderClips(); |
| })(VV); |
| }catch(err){var b=VV.$("errBanner");if(b){b.style.display="block";b.textContent="⚠ AudioEngine: "+err.message}console.error("AudioEngine:",err)} |
| </script> |
| <script> |
| "use strict"; |
| |
| try{ |
| (function(V){ |
| var $=V.$; |
| |
| |
| V.cfg=V.cfg||{token:""}; |
| try{V.cfg.token=localStorage.getItem("vv_token")||""}catch(e){} |
| var settingsBtn=$("settingsBtn"),settingsModal=$("settingsModal"); |
| function setPill(t,c){var p=$("aiPill");if(p){p.textContent=t;p.className=c||""}} |
| function openSettings(){ |
| if(!settingsModal)return; |
| var inp=$("tokenIn"); |
| if(inp)inp.value=V.cfg.token; |
| settingsModal.classList.add("on"); |
| } |
| function closeSettings(){ |
| if(settingsModal)settingsModal.classList.remove("on"); |
| } |
| if(settingsBtn)settingsBtn.onclick=openSettings; |
| var settingsX=$("settingsX"); |
| if(settingsX)settingsX.onclick=closeSettings; |
| var settingsSave=$("settingsSave"); |
| if(settingsSave)settingsSave.onclick=function(){ |
| var inp=$("tokenIn"); |
| V.cfg.token=inp?inp.value.trim():""; |
| try{localStorage.setItem("vv_token",V.cfg.token)}catch(e){} |
| setPill(V.cfg.token?"API · HF token saved":"API · no token (client mode)",V.cfg.token?"ok":""); |
| V.toast(V.cfg.token?"Token saved — API-first mode active":"Token cleared — using client engines"); |
| closeSettings(); |
| }; |
| document.addEventListener("keydown",function(e){if(e.key==="Escape")closeSettings()}); |
| setPill(V.cfg.token?"API · HF token ready":"API · no token (client mode)",V.cfg.token?"ok":""); |
| |
| |
| var intelLast=0,timeline=[]; |
| function tlog(msg){timeline.push(new Date().toLocaleTimeString()+" · "+msg);if(timeline.length>12)timeline.shift()} |
| function riskBase(st){return{ dry:10, drying:30, damp:60, wet:85 }[st]||0} |
| function riskTag(r){return r<30?"LOW":r<55?"MEDIUM":r<75?"HIGH":"CRITICAL"} |
| function riskColor(r){return r<30?"#2e9e5b":r<55?"#e8a13c":r<75?"#d97706":"#d7263d"} |
| function updateIntel(force){ |
| var now=Date.now(); |
| if(!force&&now-intelLast<1000)return; |
| intelLast=now; |
| var vis=V.lastVision,aud=V.lastAudio,out=$("intelOut"); |
| if(!out)return; |
| if(!vis&&!aud){out.textContent="Run at least one video and one radio analysis, then return here.";return} |
| var st=vis?vis.state:null,emo=aud?aud.emo:null; |
| var tire=VV.TIRES[+($("tireSel").value||0)]||VV.TIRES[0]; |
| var conf=(vis?vis.conf:0)*(aud?0.5+aud.conf*0.5:1); |
| var r=st?riskBase(st):0; |
| if(st&&tire.states.indexOf(st)<0)r+=25; |
| if(emo==="afraid"||emo==="stressed")r+=20; |
| else if(emo==="angry"||emo==="frustrated")r+=10; |
| else if(emo==="calm"||emo==="focused"||emo==="happy")r-=10; |
| r=Math.max(0,Math.min(100,r)); |
| var riskEl=$("intelRisk"); |
| if(riskEl){riskEl.innerHTML=r+"<small>/100</small>";riskEl.style.color=riskColor(r)} |
| var tagEl=$("intelRiskTag"); |
| if(tagEl){tagEl.textContent=riskTag(r)+" · CONF "+(conf*100).toFixed(0)+"%";tagEl.style.color=riskColor(r)} |
| if($("homeRisk"))$("homeRisk").textContent=r; |
| if($("intelTrack"))$("intelTrack").textContent=vis?st.toUpperCase()+" · conf "+(vis.conf*100).toFixed(0)+"%" : "—"; |
| if($("intelTrackWhy"))$("intelTrackWhy").textContent=vis?("Frame "+vis.frame+(vis.wx?" · weather prior":" · footage-only")):"No analysis yet."; |
| if($("intelEmo"))$("intelEmo").textContent=aud?emo.toUpperCase()+" · conf "+(aud.conf*100).toFixed(0)+"%" : "—"; |
| if($("intelEmoWhy"))$("intelEmoWhy").textContent=aud?(aud.why+" · Lap "+(aud.lap||"—")):"No analysis yet."; |
| var rec="—",recWhy="Awaiting data."; |
| if(st&&emo){ |
| var suitable=tire.states.indexOf(st)>=0; |
| if(st==="wet"&&!suitable&&(emo==="stressed"||emo==="afraid")){ |
| rec="CRITICAL · BOX FOR WETS";recWhy="Standing water + driver losing confidence. Pit immediately."; |
| }else if(st==="damp"&&!suitable&&emo==="frustrated"){ |
| rec="BOX FOR INTERS";recWhy="Track greasy, driver reports poor grip. Box for Intermediates."; |
| }else if(st==="drying"&&tire.name==="Intermediate"&&(emo==="calm"||emo==="happy")){ |
| rec="STAY OUT · CROSSOVER";recWhy="Dry line forming but driver is managing temps. Wait for full slicks."; |
| }else if(st==="dry"&&(tire.name==="Wet"||tire.name==="Intermediate")){ |
| rec="BOX FOR SLICKS";recWhy="Track is dry — tread will overheat and blister rapidly."; |
| }else if(suitable&&(emo==="angry"||emo==="frustrated")){ |
| rec="STAY OUT · SETTLE DRIVER";recWhy="Tyres fine, but driver is hot. Recommend a settling lap and tyre-temp coaching."; |
| }else if(suitable){ |
| rec="HOLD · NO CHANGE";recWhy="Tyres suit the track and the driver is composed. Keep current plan."; |
| }else{ |
| rec="MONITOR · NEXT LAP";recWhy="Track shifting — re-evaluate at the next reference point."; |
| } |
| } |
| if($("intelCall"))$("intelCall").textContent=rec; |
| if($("intelCallWhy"))$("intelCallWhy").textContent=recWhy; |
| var tbl=$("intelTable"); |
| if(tbl){ |
| tbl.innerHTML="<tr><td>Track</td><td>"+(st?st.toUpperCase():"—")+"</td></tr>"+ |
| "<tr><td>Driver state</td><td>"+(emo?emo.toUpperCase():"—")+"</td></tr>"+ |
| "<tr><td>Compound</td><td>"+tire.name+"</td></tr>"+ |
| "<tr><td>Fit</td><td>"+(st&&tire.states.indexOf(st)>=0?"SUITABLE":"MISMATCH")+"</td></tr>"+ |
| "<tr><td>Weather prior</td><td>"+(vis&&vis.wx?"ON":"OFF")+"</td></tr>"+ |
| "<tr><td>Confidence</td><td>"+(conf*100).toFixed(0)+"%</td></tr>"; |
| } |
| if($("intelTime"))$("intelTime").textContent=timeline.join(" · "); |
| tlog("Risk "+r+" ("+riskTag(r)+") · "+st+" / "+emo); |
| } |
| V.intelTick=function(){updateIntel(true)}; |
| setInterval(function(){updateIntel(false)},1200); |
| |
| |
| var TRACKS=VV.TRACKS||[]; |
| function labelToWx(label){return String(label||"").toLowerCase()} |
| function rainFromLabel(label){ |
| var l=labelToWx(label); |
| if(l.indexOf("rain")>=0||l.indexOf("drizzle")>=0||l.indexOf("storm")>=0||l.indexOf("thunder")>=0)return 0.9; |
| if(l.indexOf("snow")>=0)return 0.85; |
| if(l.indexOf("overcast")>=0)return 0.5; |
| if(l.indexOf("fog")>=0||l.indexOf("mist")>=0)return 0.55; |
| if(l.indexOf("cloud")>=0)return 0.3; |
| return 0.2; |
| } |
| function fetchWxPrior(idx){ |
| var t=TRACKS[idx]||TRACKS[0]; |
| if(!t)return; |
| var url="https://api.open-meteo.com/v1/forecast?latitude="+t.lat+"&longitude="+t.lon+ |
| "¤t=temperature_2m,relative_humidity_2m,precipitation,weather_code,wind_speed_10m"+ |
| "&daily=temperature_2m_max,temperature_2m_min,precipitation_sum,weather_code"+ |
| "&past_days=3&forecast_days=4&timezone=auto"; |
| fetch(url).then(function(r){return r.json()}).then(function(j){ |
| V.lastWx=j; |
| var cur=j.current||{},code=(cur.weather_code!=null)?cur.weather_code:0; |
| var label=wxCodeName(code); |
| V.wxRain=rainFromLabel(label); |
| var cityEl=$("wxCity"); |
| if(cityEl)cityEl.textContent=t.name+" · "+t.city+", "+t.country; |
| var nowEl=$("wxNow"); |
| if(nowEl){ |
| nowEl.innerHTML="<b>"+label+"</b> · "+(cur.temperature_2m!=null?cur.temperature_2m.toFixed(1)+"°C":"—")+ |
| " · RH "+(cur.relative_humidity_2m!=null?cur.relative_humidity_2m+"%":"—")+ |
| " · wind "+(cur.wind_speed_10m!=null?cur.wind_speed_10m+" km/h":"—")+ |
| " · rain prior "+(V.wxRain*100).toFixed(0)+"%"; |
| } |
| renderWxPast(j); |
| renderWxFore(j); |
| V.toast("Weather updated · "+t.city); |
| }).catch(function(){if($("wxNow"))$("wxNow").textContent="Weather unavailable — offline or blocked."}); |
| } |
| function wxCodeName(c){ |
| c=+c||0; |
| if(c===0)return"Clear"; |
| if(c===1||c===2)return"Partly cloudy"; |
| if(c===3)return"Overcast"; |
| if(c===45||c===48)return"Fog"; |
| if(c>=51&&c<=57)return"Drizzle"; |
| if(c>=61&&c<=67)return"Rain"; |
| if(c>=71&&c<=77)return"Snow"; |
| if(c>=80&&c<=82)return"Rain showers"; |
| if(c>=85&&c<=86)return"Snow showers"; |
| if(c>=95)return"Thunderstorm"; |
| return"Unknown"; |
| } |
| function wxIcon(c){ |
| c=+c||0; |
| if(c===0)return"☀️"; |
| if(c===1||c===2)return"⛅"; |
| if(c===3)return"☁️"; |
| if(c===45||c===48)return"🌫️"; |
| if(c>=51&&c<=57)return"🌦️"; |
| if(c>=61&&c<=67)return"🌧️"; |
| if(c>=71&&c<=77)return"🌨️"; |
| if(c>=80&&c<=82)return"🌧️"; |
| if(c>=95)return"⛈️"; |
| return"🌡️"; |
| } |
| function renderWxPast(j){ |
| var el=$("wxPast"); |
| if(!el)return; |
| var d=(j&&j.daily)||{},dates=d.time||[],codes=d.weather_code||[],mx=d.temperature_2m_max||[],mn=d.temperature_2m_min||[]; |
| var rows=""; |
| for(var i=0;i<dates.length;i++){ |
| var dt=dates[i].slice(5); |
| rows+="<tr><td>"+dt+"</td><td>"+wxIcon(codes[i])+" "+wxCodeName(codes[i])+"</td>"+ |
| "<td>"+(mx[i]!=null?mx[i].toFixed(0)+"°":"—")+" / "+(mn[i]!=null?mn[i].toFixed(0)+"°":"—")+"</td></tr>"; |
| } |
| el.innerHTML=rows; |
| } |
| function renderWxFore(j){ |
| var el=$("wxFore"); |
| if(!el)return; |
| var d=(j&&j.daily)||{},dates=d.time||[],codes=d.weather_code||[],mx=d.temperature_2m_max||[],mn=d.temperature_2m_min||[]; |
| var cards=""; |
| for(var i=0;i<dates.length;i++){ |
| cards+='<div class="wxCard"><div class="wxIcon">'+wxIcon(codes[i])+'</div>'+ |
| '<div class="wxDay">'+dates[i].slice(5)+'</div><div>'+wxCodeName(codes[i])+'</div>'+ |
| '<div class="wxTemp">'+(mx[i]!=null?mx[i].toFixed(0)+"°":"—")+' / '+(mn[i]!=null?mn[i].toFixed(0)+"°":"—")+'</div></div>'; |
| } |
| el.innerHTML=cards; |
| } |
| var wxSel=$("wxTrack"); |
| if(wxSel&&TRACKS.length){ |
| TRACKS.forEach(function(t,i){ |
| var o=document.createElement("option"); |
| o.value=i; |
| o.textContent=t.name+" — "+t.city+", "+t.country; |
| wxSel.appendChild(o); |
| }); |
| wxSel.onchange=function(){fetchWxPrior(+wxSel.value)}; |
| fetchWxPrior(0); |
| }else if(!wxSel){ |
| console.warn("VaneView: #wxTrack not found — weather select skipped."); |
| } |
| var trackSel=$("trackSel"); |
| if(trackSel&&TRACKS.length){ |
| trackSel.innerHTML=""; |
| TRACKS.forEach(function(t,i){ |
| var o=document.createElement("option"); |
| o.value=i; |
| o.textContent=t.name+" — "+t.city+", "+t.country; |
| trackSel.appendChild(o); |
| }); |
| if(trackSel.onchange)trackSel.onchange(); |
| } |
| |
| |
| if(settingsModal)settingsModal.addEventListener("click",function(e){if(e.target===settingsModal)closeSettings()}); |
| |
| |
| var required=["tireSel","trackSel","aiPill","vid","stagePh","analyzeBtn","audioIn","intelRisk","intelCall","intelTable","wxNow","wxPast","wxFore"]; |
| var missing=required.filter(function(id){return !$(id)}); |
| if(missing.length)console.warn("VaneView missing:",missing.join(", ")); |
| else console.log("VaneView self-test OK — all "+required.length+" anchors present."); |
| console.log("VaneView ready —",TRACKS.length,"circuits ·",VV.TIRES.length,"compounds · token:",V.cfg.token?"saved":"none"); |
| })(VV); |
| }catch(err){ |
| var b=VV.$("errBanner"); |
| if(b){b.style.display="block";b.textContent="⚠ Part5: "+err.message} |
| console.error("Part5:",err); |
| } |
| </script> |
|
|