(function(){ /* ---------- mobile nav ---------- */ var btn=document.getElementById('nav-toggle'), nav=document.getElementById('nav-mobile'); if(btn&&nav){btn.addEventListener('click',function(){var open=!nav.classList.toggle('hidden');btn.setAttribute('aria-expanded',open?'true':'false');});} /* ---------- editor's line date ---------- */ var eld=document.getElementById('editor-line-date'); if(eld){try{eld.textContent=new Date().toLocaleDateString('en-US',{month:'short',day:'numeric'});}catch(e){}} /* ---------- dynamic rendering ---------- */ var API='/wp-json/wp/v2'; if(location.hostname!=='robotbelt.com'&&location.hostname!=='www.robotbelt.com'){API='https://robotbelt.com/wp-json/wp/v2';} var EMBED='&_embed=wp:featuredmedia,wp:term'; var CAT2ACCENT={ 'humanoid-robots':'robotics','robotics':'robotics','shenzhen-robotics':'robotics','industrial-automation':'robotics','shenzhen':'robotics','factory-tours':'robotics', 'artificial-intelligence':'ai','china-tech':'ai','pro-vision':'ai', 'ev-mobility':'ev','ev':'ev','electric-vehicles':'ev', 'semiconductors':'semis','component-index':'semis','supply-chain':'semis', 'market-trends':'capital','business':'capital', 'insights':'insights','opinion':'insights','policy-watch':'insights','notebook':'insights' }; function fmtDate(iso){try{return new Date(iso).toLocaleDateString('en-US',{month:'short',day:'numeric',year:'numeric'});}catch(e){return '';}} function decode(html){var d=document.createElement('textarea');d.innerHTML=html||'';return d.value;} function stripHTML(html){var d=document.createElement('div');d.innerHTML=html||'';var t=d.textContent||'';return t.replace(/\[\u2026\]|\u2026\s*$/g,'').trim();} function primaryCat(post){ var groups=(post._embedded&&post._embedded['wp:term'])||[]; var skip={'news':1,'notebook':1,'sectors':1,'the-belt':1}; var fallback=null; for(var g=0;g