Update index.html
Browse files- index.html +14 -4
index.html
CHANGED
|
@@ -51,6 +51,7 @@ button:focus-visible,input:focus-visible{outline:2px solid var(--acc);outline-of
|
|
| 51 |
.box{background:var(--panel);border:1px solid var(--line);border-radius:22px;padding:16px}
|
| 52 |
select{font:inherit;background:var(--bg);color:var(--txt);border:1px solid var(--line);border-radius:10px;padding:5px 8px;max-width:190px}
|
| 53 |
#bg{position:fixed;inset:0;width:100%;height:100%;z-index:0;background:#000}
|
|
|
|
| 54 |
.wrap{z-index:2}
|
| 55 |
.ss .wrap{position:fixed;width:min(var(--ww,380px),calc(100vw - 24px));max-width:none}
|
| 56 |
.ss .bell{display:none}
|
|
@@ -178,6 +179,8 @@ input[type=text]{flex:1;min-width:120px}
|
|
| 178 |
<div class="grp">
|
| 179 |
<h3>πΌοΈ Slideshow</h3>
|
| 180 |
<div class="f"><span id="cnt">No pictures yet</span><span><button class="btn" id="bfd">π Folder</button> <button class="btn alt" id="bfi">β Pictures</button></span></div>
|
|
|
|
|
|
|
| 181 |
<div class="f"><span>Slideshow</span><div class="sg" data-k="ss"><button data-v="true">On</button><button data-v="false">Off</button></div></div>
|
| 182 |
<div class="f"><span>Change every</span><div class="sg" data-k="interval"><button data-v="5">5s</button><button data-v="10">10s</button><button data-v="30">30s</button><button data-v="60">1m</button><button data-v="300">5m</button></div></div>
|
| 183 |
<div class="f"><span>Order</span><div class="sg" data-k="shuffle"><button data-v="true">Shuffle</button><button data-v="false">In order</button></div></div>
|
|
@@ -221,7 +224,7 @@ input[type=text]{flex:1;min-width:120px}
|
|
| 221 |
|
| 222 |
<script>
|
| 223 |
const $=id=>document.getElementById(id);
|
| 224 |
-
const DEF={h24:false,secs:true,smooth:true,theme:'auto',dot:'red',sound:'bell',vol:.6,snooze:5,awake:false,ss:true,interval:10,shuffle:true,fit:'cover',trans:'random',tdur:2,dim:.2,corner:'br',ws:380,night:false,nc:'red',nb:.6,show:{a:true,b:true,d:true},alarms:[{id:1,t:'07:00',label:'Wake up',on:false,days:[1,2,3,4,5]}]};
|
| 225 |
let S=JSON.parse(JSON.stringify(DEF));
|
| 226 |
try{const o=JSON.parse(localStorage.getItem('clock4')||'{}');Object.assign(S,o);S.show=Object.assign({},DEF.show,o.show)}catch(e){}
|
| 227 |
const save=()=>{try{localStorage.setItem('clock4',JSON.stringify(S))}catch(e){}};
|
|
@@ -383,7 +386,8 @@ $('tsel').onchange=e=>{S.trans=e.target.value;save()};
|
|
| 383 |
function draw(p){c.fillStyle='#000';c.fillRect(0,0,W,H);if(nxt&&tn){const e=sm(p);if(CL[tn]){A();K(()=>CL[tn](e))}else F[tn](p)}else A();if(S.dim){c.fillStyle=`rgba(0,0,0,${S.dim})`;c.fillRect(0,0,W,H)}}
|
| 384 |
function size(){const d=Math.min(devicePixelRatio||1,2);W=bg.width=tmp.width=Math.round(innerWidth*d);H=bg.height=tmp.height=Math.round(innerHeight*d)}
|
| 385 |
function pick(){if(idx<0||idx>=order.length-1){order=[...files.keys()];if(S.shuffle)for(let i=order.length-1;i>0;i--){const j=Math.random()*(i+1)|0;[order[i],order[j]]=[order[j],order[i]]}idx=0}else idx++;return order[idx]}
|
| 386 |
-
|
|
|
|
| 387 |
if(!cur){cur=bm;draw(1);timer=setTimeout(advance,S.interval*1000);return}
|
| 388 |
tn=S.trans==='random'?ALL[Math.random()*ALL.length|0]:S.trans;nxt=bm;R=Array.from({length:1600},Math.random);
|
| 389 |
const d=S.tdur*1000,t0=performance.now(),f=now=>{const p=cl((now-t0)/d);draw(p);if(p<1)anim=requestAnimationFrame(f);else{cur.close&&cur.close();cur=nxt;nxt=null;draw(1);timer=setTimeout(advance,S.interval*1000)}};f(t0)}
|
|
@@ -392,13 +396,19 @@ b.classList.toggle('ss',on);['tl','tr','bl','br'].forEach(k=>b.classList.toggle(
|
|
| 392 |
r.toggleAttribute('data-night',S.night);r.style.setProperty('--tone',P[0]);r.style.setProperty('--dim',P[1]);r.style.setProperty('--nb',S.nb);
|
| 393 |
if(on&&!running){running=true;size();advance()}else if(!on&&running){running=false;clearTimeout(timer);cancelAnimationFrame(anim)}}
|
| 394 |
const load=e=>{const fl=[...e.target.files].filter(f=>f.type.startsWith('image/')||/\.(jpe?g|png|webp|gif|avif|bmp)$/i.test(f.name));if(!fl.length)return;
|
| 395 |
-
files=e.target.id==='ffil'?files.concat(fl):fl;idx=-1;order=[];cur&&cur.close&&cur.close();cur=nxt=null;running=false;clearTimeout(timer);cancelAnimationFrame(anim);
|
| 396 |
-
|
| 397 |
$('fdir').onchange=$('ffil').onchange=load;$('bfd').onclick=()=>$('fdir').click();$('bfi').onclick=()=>$('ffil').click();
|
| 398 |
$('bnext').onclick=()=>{if(!running)return;cancelAnimationFrame(anim);if(nxt){cur=nxt;nxt=null}advance()};
|
| 399 |
$('dim').oninput=e=>{S.dim=+e.target.value;save();cur&&!nxt&&draw(1)};
|
| 400 |
$('nb').oninput=e=>{S.nb=+e.target.value;save();document.documentElement.style.setProperty('--nb',S.nb)};
|
| 401 |
addEventListener('resize',()=>{size();cur&&!nxt&&draw(1)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
size();sync();renderAlarms();logic();frame();setInterval(logic,250);awake();
|
| 403 |
</script>
|
| 404 |
</body>
|
|
|
|
| 51 |
.box{background:var(--panel);border:1px solid var(--line);border-radius:22px;padding:16px}
|
| 52 |
select{font:inherit;background:var(--bg);color:var(--txt);border:1px solid var(--line);border-radius:10px;padding:5px 8px;max-width:190px}
|
| 53 |
#bg{position:fixed;inset:0;width:100%;height:100%;z-index:0;background:#000}
|
| 54 |
+
textarea{font:inherit;width:100%;background:var(--bg);color:var(--txt);border:1px solid var(--line);border-radius:10px;padding:6px 8px;resize:vertical}
|
| 55 |
.wrap{z-index:2}
|
| 56 |
.ss .wrap{position:fixed;width:min(var(--ww,380px),calc(100vw - 24px));max-width:none}
|
| 57 |
.ss .bell{display:none}
|
|
|
|
| 179 |
<div class="grp">
|
| 180 |
<h3>πΌοΈ Slideshow</h3>
|
| 181 |
<div class="f"><span id="cnt">No pictures yet</span><span><button class="btn" id="bfd">π Folder</button> <button class="btn alt" id="bfi">β Pictures</button></span></div>
|
| 182 |
+
<textarea id="urls" rows="3" placeholder="Image URLs, one per line (https://β¦ or photos/1.jpg)" aria-label="Image URLs"></textarea>
|
| 183 |
+
<div class="f"><span><button class="btn" id="burl">π Use URLs</button> <button class="btn alt" id="brnd">π² Random photos</button></span><button class="btn alt" id="bclr">ποΈ Clear online</button></div>
|
| 184 |
<div class="f"><span>Slideshow</span><div class="sg" data-k="ss"><button data-v="true">On</button><button data-v="false">Off</button></div></div>
|
| 185 |
<div class="f"><span>Change every</span><div class="sg" data-k="interval"><button data-v="5">5s</button><button data-v="10">10s</button><button data-v="30">30s</button><button data-v="60">1m</button><button data-v="300">5m</button></div></div>
|
| 186 |
<div class="f"><span>Order</span><div class="sg" data-k="shuffle"><button data-v="true">Shuffle</button><button data-v="false">In order</button></div></div>
|
|
|
|
| 224 |
|
| 225 |
<script>
|
| 226 |
const $=id=>document.getElementById(id);
|
| 227 |
+
const DEF={h24:false,secs:true,smooth:true,theme:'auto',dot:'red',sound:'bell',vol:.6,snooze:5,awake:false,urls:[],ss:true,interval:10,shuffle:true,fit:'cover',trans:'random',tdur:2,dim:.2,corner:'br',ws:380,night:false,nc:'red',nb:.6,show:{a:true,b:true,d:true},alarms:[{id:1,t:'07:00',label:'Wake up',on:false,days:[1,2,3,4,5]}]};
|
| 228 |
let S=JSON.parse(JSON.stringify(DEF));
|
| 229 |
try{const o=JSON.parse(localStorage.getItem('clock4')||'{}');Object.assign(S,o);S.show=Object.assign({},DEF.show,o.show)}catch(e){}
|
| 230 |
const save=()=>{try{localStorage.setItem('clock4',JSON.stringify(S))}catch(e){}};
|
|
|
|
| 386 |
function draw(p){c.fillStyle='#000';c.fillRect(0,0,W,H);if(nxt&&tn){const e=sm(p);if(CL[tn]){A();K(()=>CL[tn](e))}else F[tn](p)}else A();if(S.dim){c.fillStyle=`rgba(0,0,0,${S.dim})`;c.fillRect(0,0,W,H)}}
|
| 387 |
function size(){const d=Math.min(devicePixelRatio||1,2);W=bg.width=tmp.width=Math.round(innerWidth*d);H=bg.height=tmp.height=Math.round(innerHeight*d)}
|
| 388 |
function pick(){if(idx<0||idx>=order.length-1){order=[...files.keys()];if(S.shuffle)for(let i=order.length-1;i>0;i--){const j=Math.random()*(i+1)|0;[order[i],order[j]]=[order[j],order[i]]}idx=0}else idx++;return order[idx]}
|
| 389 |
+
const grab=it=>typeof it!=='string'?createImageBitmap(it):new Promise((ok,no)=>{const im=new Image();im.referrerPolicy='no-referrer';im.onload=()=>ok(im);im.onerror=no;im.src=it==='picsum'?`https://picsum.photos/1920/1080?random=${Date.now()}`:it});
|
| 390 |
+
async function advance(){if(!running||!files.length)return;clearTimeout(timer);const bm=await grab(files[pick()]).catch(()=>null);if(!running)return;if(!bm){timer=setTimeout(advance,2000);return}
|
| 391 |
if(!cur){cur=bm;draw(1);timer=setTimeout(advance,S.interval*1000);return}
|
| 392 |
tn=S.trans==='random'?ALL[Math.random()*ALL.length|0]:S.trans;nxt=bm;R=Array.from({length:1600},Math.random);
|
| 393 |
const d=S.tdur*1000,t0=performance.now(),f=now=>{const p=cl((now-t0)/d);draw(p);if(p<1)anim=requestAnimationFrame(f);else{cur.close&&cur.close();cur=nxt;nxt=null;draw(1);timer=setTimeout(advance,S.interval*1000)}};f(t0)}
|
|
|
|
| 396 |
r.toggleAttribute('data-night',S.night);r.style.setProperty('--tone',P[0]);r.style.setProperty('--dim',P[1]);r.style.setProperty('--nb',S.nb);
|
| 397 |
if(on&&!running){running=true;size();advance()}else if(!on&&running){running=false;clearTimeout(timer);cancelAnimationFrame(anim)}}
|
| 398 |
const load=e=>{const fl=[...e.target.files].filter(f=>f.type.startsWith('image/')||/\.(jpe?g|png|webp|gif|avif|bmp)$/i.test(f.name));if(!fl.length)return;
|
| 399 |
+
files=e.target.id==='ffil'?files.concat(fl):[...S.urls,...fl];idx=-1;order=[];cur&&cur.close&&cur.close();cur=nxt=null;running=false;clearTimeout(timer);cancelAnimationFrame(anim);
|
| 400 |
+
cnt();S.ss=true;e.target.value='';apply()};
|
| 401 |
$('fdir').onchange=$('ffil').onchange=load;$('bfd').onclick=()=>$('fdir').click();$('bfi').onclick=()=>$('ffil').click();
|
| 402 |
$('bnext').onclick=()=>{if(!running)return;cancelAnimationFrame(anim);if(nxt){cur=nxt;nxt=null}advance()};
|
| 403 |
$('dim').oninput=e=>{S.dim=+e.target.value;save();cur&&!nxt&&draw(1)};
|
| 404 |
$('nb').oninput=e=>{S.nb=+e.target.value;save();document.documentElement.style.setProperty('--nb',S.nb)};
|
| 405 |
addEventListener('resize',()=>{size();cur&&!nxt&&draw(1)});
|
| 406 |
+
const cnt=()=>{const u=S.urls.length,l=files.length-u;$('cnt').textContent=!files.length?'No pictures yet':(l?l+' local':'')+(l&&u?' + ':'')+(u?(S.urls[0]==='picsum'?'random online':u+' online'):'')};
|
| 407 |
+
const setU=u=>{S.urls=u;files=[...u,...files.filter(f=>typeof f!=='string')];idx=-1;order=[];cur&&cur.close&&cur.close();cur=nxt=null;running=false;clearTimeout(timer);cancelAnimationFrame(anim);S.ss=true;cnt();apply()};
|
| 408 |
+
$('burl').onclick=()=>setU($('urls').value.split(/\n+/).map(s=>s.trim()).filter(Boolean).slice(0,500));
|
| 409 |
+
$('brnd').onclick=()=>setU(['picsum']);
|
| 410 |
+
$('bclr').onclick=()=>{$('urls').value='';setU([])};
|
| 411 |
+
files=[...S.urls];$('urls').value=S.urls[0]==='picsum'?'':S.urls.join('\n');cnt();
|
| 412 |
size();sync();renderAlarms();logic();frame();setInterval(logic,250);awake();
|
| 413 |
</script>
|
| 414 |
</body>
|