From 09ce590abd7abe590c2a09003ffdea0ddf8ef9f7 Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 25 Apr 2026 18:53:56 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20mobile=20search=20bar=20in=20header=20?= =?UTF-8?q?=E2=80=94=20tap=20icon=20to=20search=20Navidrome=20library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Search icon added to mobile header. Tapping opens an inline search bar below the header. Typing searches artists/albums/songs via Navidrome search3 API with 300ms debounce. X button closes and returns to Home. Co-Authored-By: Claude Sonnet 4.6 --- app.js | 26 ++++++++++++++++++++++++++ index.html | 28 +++++++++++++++++++++------- sw.js | 2 +- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 5865773..aa3f15d 100644 --- a/app.js +++ b/app.js @@ -508,6 +508,32 @@ async function doLocalSearch(q){ } function mkSection(title){const d=document.createElement('div');d.className='search-section';d.innerHTML=`
${title}
`;return d} +function toggleMobileSearch(){ + const bar=document.getElementById('mobile-search-bar'); + const btn=document.getElementById('mobile-search-btn'); + const open=bar.style.display==='none'||bar.style.display===''; + bar.style.display=open?'block':'none'; + btn.style.color=open?'var(--accent)':'var(--text2)'; + if(open){setTimeout(()=>document.getElementById('mobile-search-input').focus(),50);} + else{closeMobileSearch();} +} +function closeMobileSearch(){ + const bar=document.getElementById('mobile-search-bar'); + const inp=document.getElementById('mobile-search-input'); + const btn=document.getElementById('mobile-search-btn'); + bar.style.display='none'; + btn.style.color='var(--text2)'; + inp.value=''; + navigate('home'); +} +let _mobileSearchTimer=null; +function onMobileSearch(val){ + clearTimeout(_mobileSearchTimer); + if(!val.trim()){navigate('home');return;} + navigate('search'); + _mobileSearchTimer=setTimeout(()=>doLocalSearch(val),300); +} + // ─── ITUNES API ─── const ITUNES='https://itunes.apple.com'; async function itunesSearch(query,entity='musicTrack',limit=25){ diff --git a/index.html b/index.html index 1e32cbc..7cf0d65 100644 --- a/index.html +++ b/index.html @@ -127,14 +127,28 @@
-
-