This commit is contained in:
1 parent
331ac9c2d2
commit
c9eea41bbe
1 file changed
+3
-2
@@ -219,10 +219,11 @@ async function loadHeat(){
|
|||||||
drawHeat();
|
drawHeat();
|
||||||
}
|
}
|
||||||
function showHeat(){ if(!S.product) return; setView('heat'); setTimeout(()=>{ const sel=$('#heatdevice'); if(sel) sel.value=S.product.name; drawHeat(); },50); }
|
function showHeat(){ if(!S.product) return; setView('heat'); setTimeout(()=>{ const sel=$('#heatdevice'); if(sel) sel.value=S.product.name; drawHeat(); },50); }
|
||||||
function drawHeat(){
|
async function drawHeat(){
|
||||||
const c=$('#heatcanvas'); if(!c) return; const ctx=c.getContext('2d');
|
const c=$('#heatcanvas'); if(!c) return; const ctx=c.getContext('2d');
|
||||||
const W=Math.max(2,parseFloat($('#heatw').value)||6), D=Math.max(2,parseFloat($('#heatd').value)||5);
|
const W=Math.max(2,parseFloat($('#heatw').value)||6), D=Math.max(2,parseFloat($('#heatd').value)||5);
|
||||||
const name=$('#heatdevice').value; const p=(S.heatItems||[]).find(x=>x.name===name) || (S.product&&S.product.name===name?S.product:null);
|
const name=$('#heatdevice').value; let p=(S.heatItems||[]).find(x=>x.name===name) || (S.product&&S.product.name===name?S.product:null);
|
||||||
|
if(p && !p.specs){ try { const r=await api('/api/product?key='+encodeURIComponent(p.name)); p=r.product||p; } catch(e){} }
|
||||||
const pad=36, availW=c.width-pad*2, availH=c.height-pad*2;
|
const pad=36, availW=c.width-pad*2, availH=c.height-pad*2;
|
||||||
const scale=Math.min(availW/W, availH/D); const rw=W*scale, rh=D*scale, x0=(c.width-rw)/2, y0=(c.height-rh)/2;
|
const scale=Math.min(availW/W, availH/D); const rw=W*scale, rh=D*scale, x0=(c.width-rw)/2, y0=(c.height-rh)/2;
|
||||||
ctx.clearRect(0,0,c.width,c.height); ctx.fillStyle='#0d1117'; ctx.fillRect(0,0,c.width,c.height);
|
ctx.clearRect(0,0,c.width,c.height); ctx.fillStyle='#0d1117'; ctx.fillRect(0,0,c.width,c.height);
|
||||||
|
|||||||
Reference in new issue
Block a user