add bear warning
This commit is contained in:
parent
eed4d3cf00
commit
05d5320455
15
dashboard.py
15
dashboard.py
@ -698,20 +698,21 @@ function flashCam(cid){
|
|||||||
if(mk){mk.classList.add('active');setTimeout(()=>mk.classList.remove('active'),6000);}
|
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 c=CAMS[cid]; if(!c)return;
|
||||||
const wrap=document.getElementById('map-wrap');
|
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();
|
if(old)old.remove();
|
||||||
const oldLbl=document.getElementById('wolf-lbl-'+cid);
|
const oldLbl=document.getElementById('warn-lbl-'+key);
|
||||||
if(oldLbl)oldLbl.remove();
|
if(oldLbl)oldLbl.remove();
|
||||||
const circle=document.createElement('div');
|
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+'%';
|
circle.style.left=c.px+'%';circle.style.top=c.py+'%';
|
||||||
const lbl=document.createElement('div');
|
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.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);
|
wrap.appendChild(circle);wrap.appendChild(lbl);
|
||||||
setTimeout(()=>{circle.classList.add('fade');lbl.classList.add('fade');},10000);
|
setTimeout(()=>{circle.classList.add('fade');lbl.classList.add('fade');},10000);
|
||||||
setTimeout(()=>{circle.remove();lbl.remove();},11500);
|
setTimeout(()=>{circle.remove();lbl.remove();},11500);
|
||||||
@ -726,7 +727,7 @@ async function simulate(){
|
|||||||
const d=await r.json();
|
const d=await r.json();
|
||||||
dets.push(d);
|
dets.push(d);
|
||||||
flashCam(d.cam);
|
flashCam(d.cam);
|
||||||
if(d.pred==='wolf') showWolfWarning(d.cam);
|
if(d.pred==='wolf'||d.pred==='bear') showDangerWarning(d.cam,d.pred);
|
||||||
toast(`<b>${ICONS[d.pred]||''} ${d.pred[0].toUpperCase()+d.pred.slice(1)}</b> detected at ${d.cam} (${d.cam_name}) \u2014 ${d.conf.toFixed(0)}%`);
|
toast(`<b>${ICONS[d.pred]||''} ${d.pred[0].toUpperCase()+d.pred.slice(1)}</b> detected at ${d.cam} (${d.cam_name}) \u2014 ${d.conf.toFixed(0)}%`);
|
||||||
renderList();renderChart();renderHeatmap();
|
renderList();renderChart();renderHeatmap();
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user