Skip to content

Commit c759026

Browse files
Ben05-sysclaude
andcommitted
Show viewer counts compactly rather than by system locale
Driving the TV view against a live server turned up 74,71,034 watching Yahoo Finance. That is 7,471,034 grouped in lakhs, which is what toLocaleString does on an Indian machine and is correct there — but it sits in a column beside US market data, where a reader parses digit groups without thinking about it and gets the wrong magnitude for a moment. Compact form fixes both halves at once. "7.5M" carries the whole meaning in a third of the width, which is what a rail that gets scanned rather than read actually wants, and it has no digit grouping to get locale-dependent. Scoped to the new view deliberately. The rest of the terminal calls bare toLocaleString in a dozen places and has the same property; changing that is a decision about the whole UI, not a detail of this one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent ed0d097 commit c759026

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎app/web/index.html‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,11 @@ <h2>KEYS</h2>
20222022
/* ---------- live tv ---------- */
20232023
S.tv = {channels:[], mentions:[], current:null, loaded:false};
20242024

2025+
const fwatch = n =>
2026+
n >= 1e6 ? (n/1e6).toFixed(1).replace(/\.0$/,"") + "M"
2027+
: n >= 1e3 ? Math.round(n/1e3) + "K"
2028+
: String(n);
2029+
20252030
async function loadLiveTv(force){
20262031
const note = document.getElementById("tvNote");
20272032
note.textContent = "checking who is on air…";
@@ -2045,8 +2050,13 @@ <h2>KEYS</h2>
20452050
const bar = document.getElementById("tvChannels");
20462051
bar.innerHTML = S.tv.channels.map(c=>{
20472052
const on = c.id===S.tv.current;
2053+
// Compact rather than exact: the rail is scanned, and "7.5M" carries
2054+
// the whole meaning of 7,471,034 in a third of the width. It also
2055+
// sidesteps digit grouping, which toLocaleString renders by system
2056+
// locale — 74,71,034 on an Indian machine, which is correct there and
2057+
// wrong beside a column of US market data.
20482058
const who = c.live && c.viewers
2049-
? `<span class="who">${Intl.NumberFormat().format(c.viewers)}</span>` : "";
2059+
? `<span class="who">${fwatch(c.viewers)}</span>` : "";
20502060
return `<div class="tvch${c.live?" islive":" off"}${on?" on":""}"`
20512061
+ ` data-ch="${esc(c.id)}" title="${esc(c.note||"")}">`
20522062
+ `<span class="dot"></span>${esc(c.name)}${who}</div>`;

0 commit comments

Comments
 (0)