1(async function () { 2 3 const apiUrl = "https://mmc.metro.hk/wp-json/gba/v1/gbax7pixel_chart?top=3"; 4 const listEl = document.getElementById("gba-list"); 5 const weekEl = document.getElementById("gba-week"); 6 7 if (!listEl || !weekEl) return; 8 9 function formatCNDate(dateStr) { 10 if (!dateStr) return ''; 11 const [y, m, d] = dateStr.split('-'); 12 return `${y}å¹´${parseInt(m, 10)}æ${parseInt(d, 10)}æ¥`; 13 } 14 15 try { 16 const res = await fetch(apiUrl); 17 if (!res.ok) throw new Error("API error"); 18 19 const data = await res.json(); 20 21 // No data fallback 22 if (!data.rows || data.rows.length === 0) { 23 listEl.innerHTML = '<div class="text-center text-muted p-3" style="border-bottom:1px solid #efefef;">æ«æé³æ¨æ¦æªä¸,æ¬è«æå¾ </div>'; 24 weekEl.innerText = ''; 25 return; 26 } 27 28 // â Date range instead of week number 29 weekEl.innerText = 30 `${formatCNDate(data.date.from)} - ${formatCNDate(data.date.to)}`; 31 32 33function smartTruncate(text, maxWidth = 30) { 34 if (!text) return ''; 35 36 let width = 0; 37 let result = ''; 38 39 for (let char of text) { 40 41 // Chinese characters count as 2 42 const charWidth = /[\u4e00-\u9fa5]/.test(char) ? 2.5 : 1; 43 44 if (width + charWidth > maxWidth) { 45 return result + '...'; 46 } 47 48 width += charWidth; 49 result += char; 50 } 51 52 return result; 53} 54 55function truncate(text, maxLength = 14) { 56 if (!text) return ''; 57 return text.length > maxLength ? text.slice(0, maxLength) + '...' : text; 58} 59 60function truncate2(text, maxLength = 20) { 61 if (!text) return ''; 62 return text.length > maxLength ? text.slice(0, maxLength) + '...' : text; 63} 64 65listEl.innerHTML = data.rows.map(row => ` 66 <a href="https://mmc.metro.hk/gba" 67 target="_blank" 68 class="number-list__item number-list__music" style="padding-bottom:22px"> 69 70 <span class="number-list__item__num">${row.RankThisWeek}</span> 71 <span class="number-list__item__content">${smartTruncate(row.SongName)}</span> 72 <span class="number-list__item__time"> ${smartTruncate(row.Singer)}</span> 73 74 </a> 75`).join("") + 76 `<div class="music__chart__more"> 77 <a href="https://mmc.metro.hk/gba" target="_blank" class="music__chart__more__btn"> 78 æ´å¤å¤§ç£å鳿¨æ¦ 79 </a> 80 </div>`; 81 82 } catch (err) { 83 listEl.innerHTML = '<div class="text-center text-muted p-3" style="border-bottom:1px solid #efefef;">æ«æé³æ¨æ¦æªä¸,æ¬è«æå¾ </div>'; 84 weekEl.innerText = ''; 85 } 86 87})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.