diff --git a/dashboard.py b/dashboard.py index 2fd4efb..4b19ad5 100644 --- a/dashboard.py +++ b/dashboard.py @@ -698,20 +698,21 @@ function flashCam(cid){ if(mk){mk.classList.add('active');setTimeout(()=>mk.classList.remove('active'),6000);} } -function showWolfWarning(cid){ +function showDangerWarning(cid,species){ const c=CAMS[cid]; if(!c)return; const wrap=document.getElementById('map-wrap'); - const old=document.getElementById('wolf-'+cid); + const key=species+'-'+cid; + const old=document.getElementById('warn-'+key); if(old)old.remove(); - const oldLbl=document.getElementById('wolf-lbl-'+cid); + const oldLbl=document.getElementById('warn-lbl-'+key); if(oldLbl)oldLbl.remove(); const circle=document.createElement('div'); - circle.className='wolf-warn';circle.id='wolf-'+cid; + circle.className='wolf-warn';circle.id='warn-'+key; circle.style.left=c.px+'%';circle.style.top=c.py+'%'; const lbl=document.createElement('div'); - lbl.className='wolf-warn-label';lbl.id='wolf-lbl-'+cid; + lbl.className='wolf-warn-label';lbl.id='warn-lbl-'+key; lbl.style.left=c.px+'%';lbl.style.top=c.py+'%'; - lbl.textContent='\u26A0 Wolf detected'; + lbl.textContent='\u26A0 '+species[0].toUpperCase()+species.slice(1)+' detected'; wrap.appendChild(circle);wrap.appendChild(lbl); setTimeout(()=>{circle.classList.add('fade');lbl.classList.add('fade');},10000); setTimeout(()=>{circle.remove();lbl.remove();},11500); @@ -726,7 +727,7 @@ async function simulate(){ const d=await r.json(); dets.push(d); flashCam(d.cam); - if(d.pred==='wolf') showWolfWarning(d.cam); + if(d.pred==='wolf'||d.pred==='bear') showDangerWarning(d.cam,d.pred); toast(`${ICONS[d.pred]||''} ${d.pred[0].toUpperCase()+d.pred.slice(1)} detected at ${d.cam} (${d.cam_name}) \u2014 ${d.conf.toFixed(0)}%`); renderList();renderChart();renderHeatmap(); }catch(e){}