${g}
${arr.map(p=>`
`).join('')}
`;
}).join('');
return html;
}
function renderNorth(mode){
const sorted = list.slice().sort((a,b)=> (jisIndex[a.id]??999) - (jisIndex[b.id]??999));
return `
${sorted.map(p=>`
`).join('')}
`;
}
setTimeout(()=>{
const container = document.getElementById('grid');
const br = document.getElementById('btn-region');
const bn = document.getElementById('btn-north');
if (!container || !br || !bn) return;
const setMode = (mode)=>{
localStorage.setItem('jpmap:mode', mode);
br.classList.toggle('active', mode==='region');
bn.classList.toggle('active', mode==='north');
container.innerHTML = (mode==='north') ? renderNorth(mode) : renderRegion(mode);
};
setMode(initialMode);
br.addEventListener('click', ()=> setMode('region'));
bn.addEventListener('click', ()=> setMode('north'));
},0);
const searchBox = `
該当する県が見つかりません(${prefId})。
`; } else { document.title = '都道府県一覧|紹介'; app.innerHTML = indexView(PREFS); // 検索(現在モードをURLに付与) const kw = document.getElementById('kw'); const grid = document.getElementById('grid'); kw?.addEventListener('input', () => { const k = kw.value.trim(); const f = PREFS.filter(p => { const hay = [p.name, p.capital, ...(p.famous||[]), ...(p.spots||[])].join(' '); return hay.includes(k); }); const mode = localStorage.getItem('jpmap:mode') || 'region'; const show = (k ? f : PREFS); grid.innerHTML = show.map(p=>` `).join(''); }); } })();