tokenskyline 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -1
  2. package/package.json +3 -2
  3. package/template.html +84 -31
package/README.md CHANGED
@@ -20,7 +20,7 @@ Reads local logs from Claude Code, Codex, Gemini CLI / Antigravity, Hermes Agent
20
20
 
21
21
  - **All tools stacked in one grid**: each day's cell is split by how much each tool used that day.
22
22
  - **Each tool on its own row**, on the same timeline, so you can see when you switched tools.
23
- - **3D skyline or flat grid**: isometric bars on a plinth, height = real usage. Opens in 3D; add `#flat` to the URL for the grid.
23
+ - **3D skyline or flat grid**: bars on a plinth, height = real usage. The view angle is picked to make the chart as large as your screen allows; drag to rotate and look behind tall bars, double-click to reset. Add `#flat` to the URL for the grid, where nothing hides anything.
24
24
  - **Three measures**: total tokens, tokens without cache reads (cache reads are often 90%+ of the total), estimated cost in USD.
25
25
  - **A local ledger** at `~/.tokenskyline/ledger.json`: every run saves each day's totals, so days stay counted after the tools delete their logs.
26
26
  - **One file, about 50 KB**. Send it to anyone, open it on a phone.
@@ -84,8 +84,11 @@ npx tokenskyline
84
84
  ```bash
85
85
  npm test # smoke test; CI runs it on Linux, macOS and Windows with Node 18 and 22
86
86
  npm run demo # writes and opens tokenskyline-<year>-demo.html
87
+ npm run variants # builds 8 data shapes into test/out/
87
88
  ```
88
89
 
90
+ Then serve the repo folder (`python3 -m http.server`) and open `test/fit.html`: it loads every data shape at 10 desktop screen sizes, in Chinese and English, 3D and flat, and checks that the chart and its caption fit on the first screen, the page never scrolls sideways, and the 3D chart takes at least 28% of the screen height. All 240 combinations pass.
91
+
89
92
  `template.html` is the whole page. The CLI inlines the data into it in place of `<script src="data/data.js"></script>`.
90
93
 
91
94
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenskyline",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Your year of AI coding as a 3D token skyline. One command reads local logs of Claude Code, Codex, Gemini/Antigravity, Hermes, Cursor, OpenCode and 60+ tools and writes a single HTML file: GitHub-style contribution graph, flat or 3D.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -40,7 +40,8 @@
40
40
  "license": "MIT",
41
41
  "scripts": {
42
42
  "test": "node test/check.mjs",
43
- "demo": "node bin/tokenskyline.mjs --demo"
43
+ "demo": "node bin/tokenskyline.mjs --demo",
44
+ "variants": "node test/variants.mjs"
44
45
  },
45
46
  "repository": {
46
47
  "type": "git",
package/template.html CHANGED
@@ -21,7 +21,7 @@
21
21
  *{box-sizing:border-box}
22
22
  [hidden]{display:none!important}
23
23
  body{background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:14px;line-height:1.5}
24
- .wrap{max-width:1120px;margin:0 auto;padding-block:40px 64px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));display:grid;gap:40px}
24
+ .wrap{max-width:max(1120px,min(82vw,1800px));margin:0 auto;padding-block:clamp(18px,4vh,40px) 64px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));display:grid;gap:clamp(22px,4.5vh,40px)}
25
25
  .num{font-family:var(--f-mono);font-variant-numeric:tabular-nums}
26
26
  .eyebrow{font-family:var(--f-mono);font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);display:flex;flex-wrap:wrap;gap:4px 8px;align-items:baseline}
27
27
  .cmd{margin-left:auto;font-family:var(--f-mono);font-size:12px;letter-spacing:0;text-transform:none;color:var(--ink);border:1px solid var(--ink);padding:1px 7px}
@@ -30,9 +30,18 @@ body{background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:1
30
30
  h1,h2{font-family:var(--f-display);font-weight:700;margin:0;text-wrap:balance}
31
31
 
32
32
  /* 顶部 */
33
- .head{display:grid;gap:18px}
33
+ .head{display:grid;gap:clamp(10px,1.8vh,18px)}
34
34
  .hero{display:flex;flex-wrap:wrap;align-items:flex-end;gap:12px 40px;justify-content:space-between}
35
- .big{font-family:var(--f-display);font-weight:700;font-size:clamp(52px,10vw,104px);line-height:.9;letter-spacing:-.03em}
35
+ .heroL{min-width:0;max-width:min(100%,560px)}
36
+ .heroR{flex:1 1 420px;min-width:0;display:grid;gap:10px;align-content:end}
37
+ .heroR .legend{margin-inline:-9px}
38
+ .chartbox{display:grid;grid-template-columns:minmax(0,1fr)}
39
+ .chartbox.side{grid-template-columns:minmax(240px,270px) minmax(0,1fr);gap:8px;align-items:center}
40
+ .kpiOver .kpis{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 18px}
41
+ .kpiOver .kpi b{font-size:18px}
42
+ .kpiOver .kpi .sub{font-size:10.5px}
43
+ #bigSub{overflow-wrap:anywhere}
44
+ .big{font-family:var(--f-display);font-weight:700;font-size:clamp(44px,min(10vw,11vh),104px);line-height:.9;letter-spacing:-.03em}
36
45
  .big small{font-size:.32em;letter-spacing:0;font-weight:500;margin-left:.25em;color:var(--muted)}
37
46
  .kpis{display:grid;grid-template-columns:repeat(4,auto);gap:4px 28px}
38
47
  .kpi{display:grid;gap:2px}
@@ -41,7 +50,11 @@ h1,h2{font-family:var(--f-display);font-weight:700;margin:0;text-wrap:balance}
41
50
  .kpi .sub{font-family:var(--f-mono);font-size:11px;font-variant-numeric:tabular-nums;border-top:1px solid var(--rule);padding-top:3px;margin-top:2px}
42
51
  .share{display:flex;height:10px;width:100%;background:var(--empty)}
43
52
  .share i{display:block;height:100%}
44
- .legend{display:flex;flex-wrap:wrap;gap:6px 22px;font-size:12px;color:var(--muted)}
53
+ .legend{display:flex;flex-wrap:wrap;gap:2px 6px;font-size:12px;color:var(--muted);margin-inline:-9px}
54
+ .legend .tool{font-size:12px;padding:3px 9px}
55
+ .legend .tool b{color:var(--ink);font-weight:500}
56
+ .legend .more{color:var(--ink);text-decoration:underline;text-underline-offset:3px}
57
+ .legend .tool[aria-pressed="false"]{text-decoration:line-through;text-decoration-color:var(--rule)}
45
58
  .legend span{display:inline-flex;align-items:center;gap:6px}
46
59
  .legend i{width:9px;height:9px;display:inline-block}
47
60
 
@@ -63,7 +76,8 @@ button:focus-visible{outline:2px solid var(--hl);outline-offset:1px}
63
76
  /* 主图 */
64
77
  .main{display:grid;gap:10px}
65
78
  .scroll{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}
66
- #cv3{display:block}
79
+ #cv3{display:block;cursor:grab;touch-action:pan-y}
80
+ #cv3:active{cursor:grabbing}
67
81
  .scale{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);justify-content:flex-end}
68
82
  .scale i{width:11px;height:11px;display:inline-block}
69
83
  .note{font-size:12px;color:var(--muted)}
@@ -99,14 +113,14 @@ svg text{fill:var(--muted);font-family:var(--f-mono);font-size:10px}
99
113
  </style>
100
114
 
101
115
  <div class="wrap">
102
- <header class="head">
116
+ <header class="head" id="head">
103
117
  <div class="eyebrow"><span id="yr"></span> · <span id="brand"></span> · <span id="upd"></span><span class="cmd">npx tokenskyline</span></div>
104
118
  <div class="hero">
105
- <div>
119
+ <div class="heroL">
106
120
  <div class="big" id="bigNum">—</div>
107
121
  <div class="note" id="bigSub"></div>
108
122
  </div>
109
- <div class="kpis" id="kpis"></div>
123
+ <div class="heroR" id="heroR"><div class="kpis" id="kpis"></div></div>
110
124
  </div>
111
125
  <div class="share" id="share"></div>
112
126
  <div class="legend" id="shareLegend"></div>
@@ -124,10 +138,8 @@ svg text{fill:var(--muted);font-family:var(--f-mono);font-size:10px}
124
138
  <div class="seg" role="group" id="gRange">
125
139
  <button id="rData" aria-pressed="true"></button><button id="rYear" aria-pressed="false"></button>
126
140
  </div>
127
- <div class="grow"></div>
128
- <div class="tools" id="tools"></div>
129
141
  </div>
130
- <div class="scroll" id="mainScroll"><div id="w2d" hidden><svg id="grid2d"></svg></div><canvas id="cv3"></canvas></div>
142
+ <div class="chartbox"><div class="kpiOver" id="kpiOver" hidden></div><div class="scroll" id="mainScroll"><div id="w2d" hidden><svg id="grid2d"></svg></div><canvas id="cv3"></canvas></div></div>
131
143
  <div class="scale" id="scale"></div>
132
144
  </section>
133
145
 
@@ -158,8 +170,8 @@ const L=ZH?{
158
170
  gView:"视图", gMetric:"口径", gRange:"时间范围",
159
171
  usd:"估算美元", none:"未选", estCost:"按官方价估算", perDay:"日均", cacheShare:"缓存读占", allTok:"全部 token",
160
172
  days:n=>n+" 天", activeDays:"有用量的日子", since:d=>d+" 起有记录", streak:"最长连续", peak:"最猛一天", led:n=>n+"主导",
161
- scale2d:"格内分段 = 各家当天占比 · 深浅按分位五档", cuts:"分界", scale3d:"柱高 = 当天真实用量 · 柱内分段 = 各家当天占比",
162
- rowTip:n=>"点击:在图 1 里加上或去掉 "+n, from:d=>d+" 起", main:"主力", total:"合计", noRec:"没有记录",
173
+ scale2d:"格内分段 = 各家当天占比 · 深浅按分位五档", cuts:"分界", scale3d:"拖动旋转 · 双击复位 · 柱高 = 当天真实用量 · 柱内分段 = 各家当天占比",
174
+ rowTip:n=>"点击:在图 1 里加上或去掉 "+n, more:n=>"+"+n+" 家", from:d=>d+" 起", main:"主力", total:"合计", noRec:"没有记录",
163
175
  wd:["一","","三","","五","","日"], weekStart:1,
164
176
  foot:(cover,gap)=>`
165
177
  <div><b>数据从哪来</b> 本机各家 AI 工具的日志,由开源工具 tokscale 读取,数据只在本机,不上传。每次运行都会把每天的数存进一份本地底账,日志被清理后,统计过的日子不会丢。</div>
@@ -173,8 +185,8 @@ const L=ZH?{
173
185
  gView:"View", gMetric:"Measure", gRange:"Range",
174
186
  usd:"est. USD", none:"none", estCost:"at list prices", perDay:"per day", cacheShare:"cache reads", allTok:"all tokens",
175
187
  days:n=>n+(n===1?" day":" days"), activeDays:"active days", since:d=>"since "+d, streak:"longest streak", peak:"busiest day", led:n=>"mostly "+n,
176
- scale2d:"cell split = each tool's share that day · shade = quintile", cuts:"cuts", scale3d:"bar height = real usage that day · segments = each tool's share",
177
- rowTip:n=>"Click to add or remove "+n+" in fig. 1", from:d=>"since "+d, main:"top model", total:"Total", noRec:"no usage",
188
+ scale2d:"cell split = each tool's share that day · shade = quintile", cuts:"cuts", scale3d:"drag to rotate · double-click to reset · bar height = real usage that day · segments = each tool's share",
189
+ rowTip:n=>"Click to add or remove "+n+" in fig. 1", more:n=>"+"+n+" more", from:d=>"since "+d, main:"top model", total:"Total", noRec:"no usage",
178
190
  wd:["","Mon","","Wed","","Fri",""], weekStart:0,
179
191
  foot:(cover,gap)=>`
180
192
  <div><b>Where the data comes from</b> Local logs of your AI coding tools, read by the open-source tokscale. Nothing leaves your machine. Every run saves each day's totals to a local ledger, so days stay counted after the tools delete their logs.</div>
@@ -288,8 +300,11 @@ function renderHead(){
288
300
  ].map(([b,s,t])=>`<div class="kpi"><b>${b}</b><span>${s}</span><span class="sub">${t}</span></div>`).join("");
289
301
  const sum=Object.values(perTool).reduce((a,b)=>a+b,0)||1;
290
302
  $("share").innerHTML=TOOLS.filter(t=>on.has(t.k)).map(t=>`<i style="width:${perTool[t.k]/sum*100}%;background:var(--c-${t.k})" title="${t.n}"></i>`).join("");
291
- $("shareLegend").innerHTML=TOOLS.filter(t=>on.has(t.k)&&perTool[t.k]>0).sort((a,b)=>perTool[b.k]-perTool[a.k])
292
- .map(t=>`<span><i style="background:var(--c-${t.k})"></i>${t.n} <b class="num" style="color:var(--ink);font-weight:500">${(perTool[t.k]/sum*100).toFixed(1)}%</b> <span class="num">${fmt(perTool[t.k])}</span></span>`).join("");
303
+ const LMAX=8, all=S.legendAll||TOOLS.length<=LMAX, shown=all?TOOLS:TOOLS.slice(0,LMAX-1); // 工具太多时图例只列前 7 家,免得把顶部撑高
304
+ $("shareLegend").innerHTML=shown.map(t=>{const o=on.has(t.k);
305
+ return `<button class="tool" data-k="${t.k}" aria-pressed="${o}" title="${L.rowTip(t.n)}"><i style="background:var(--c-${t.k})"></i>${t.n}`+
306
+ (o?` <b class="num">${(perTool[t.k]/sum*100).toFixed(1)}%</b> <span class="num">${fmt(perTool[t.k])}</span>`:"")+`</button>`}).join("")+
307
+ (all?"":`<button class="tool more" id="legMore">${L.more(TOOLS.length-shown.length)}</button>`);
293
308
  }
294
309
 
295
310
  // ---------- 平面网格(SVG) ----------
@@ -330,26 +345,45 @@ function gridSVG(svg,dates,set,opt){
330
345
  }
331
346
 
332
347
  // ---------- 立体(canvas 平行轴测) ----------
333
- let hexes=[];
348
+ let hexes=[], lastAng={a:20,e:32};
334
349
  function draw3D(dates){
335
350
  const cv=$("cv3"), box=$("mainScroll");
336
351
  const weeks=Math.ceil(dates.length/7);
337
- const az=(weeks>30?21:30)*Math.PI/180, el=36*Math.PI/180; // 周数少时转大一点角度,免得太扁
352
+ const W=Math.max(480,box.clientWidth), padL=40, padR=72, plDepth=6;
353
+ // 一屏放下:图顶到窗口底剩多高,整张图就只能多高
354
+ const top=box.getBoundingClientRect().top+scrollY;
355
+ const budget=Math.max(220,innerHeight-top-62);
356
+ const mhCap=Math.max(200,budget*.5);
357
+ // 视角不写死:在一组好看的角度里挑格子最大的那个——周数少就转平、横着铺满宽度
358
+ // 拖动旋转时用拖到的角度;否则自动挑。俯视角下限抬到 28°,前排高柱少挡后排
359
+ const As=S.rot?[S.rot.a]:[12,14,16,18,20,22,24,26,28,30], Es=S.rot?[S.rot.e]:[28,30,32,34,36,38,40];
360
+ let best=null;
361
+ for(const k of [5.5,4.75,4])for(const a of As)for(const e of Es){
362
+ const mh=s=>Math.min(mhCap,Math.max(70,s*k));
363
+ const az_=a*Math.PI/180, el_=e*Math.PI/180;
364
+ const wSpan=weeks*Math.cos(az_)+7*Math.sin(az_), depth=weeks*Math.sin(az_)*Math.sin(el_)+7*Math.cos(az_)*Math.sin(el_);
365
+ let s=(W-padL-padR)/wSpan;
366
+ while(s>6&&depth*s+mh(s)+plDepth+60>budget)s*=.97;
367
+ const score=s*(1-Math.abs(e-32)*.004)*(1-(5.5-k)*.05); // 同样大小时偏向 32° 俯视、柱子更高
368
+ if(!best||score>best.score)best={score,s,az_,el_,k};
369
+ }
370
+ const az=best.az_, el=best.el_; lastAng={a:az*180/Math.PI,e:el*180/Math.PI};
338
371
  const uxW=Math.cos(az), uyW=Math.sin(az)*Math.sin(el), uxD=-Math.sin(az), uyD=Math.cos(az)*Math.sin(el);
339
- const W=Math.max(640,box.clientWidth), padL=40, padR=72;
340
- const step=Math.min(34,(W-padL-padR)/(weeks*uxW+7*Math.abs(uxD)));
372
+ let step=best.s;
373
+ const mhOf=s=>Math.min(mhCap,Math.max(70,s*best.k));
341
374
  const span=step*(weeks*uxW+7*Math.abs(uxD));
342
- const cR=.8, plD=6, pad=.35;
375
+ const cR=.72, plD=plDepth, pad=.35; // 柱子占格子 72%,留缝能看到后排
343
376
  const vals=dates.map(d=>dayParts(ymd(d),S.on).reduce((s,p)=>s+p[1],0));
344
377
  const maxV=Math.max(...vals,0);
345
- const maxH=Math.min(200,Math.max(130,step*7));
378
+ const maxH=mhOf(step);
346
379
  const hOf=v=>v>0&&maxV>0?Math.max(3.5,v/maxV*maxH):0; // 柱高 = 真实比例
347
380
  const ox=(W-span)/2+7*Math.abs(uxD)*step+ (padL-padR)/2;
348
381
  const rawY=(w,d,z)=>w*uyW*step+d*uyD*step-z;
349
382
  let minY=Math.min(rawY(-pad,-pad,0),rawY(weeks,-pad,maxH));
350
383
  dates.forEach((d,i)=>{const y=rawY(Math.floor(i/7),i%7,hOf(vals[i]));if(y<minY)minY=y});
351
384
  const maxY=rawY(weeks-.2+pad,7-.2+pad,0)+plD+24;
352
- const oy=18-minY, H=Math.ceil(oy+maxY+10);
385
+ const sideH=$("kpiOver").hidden?0:$("kpiOver").offsetHeight;
386
+ const H0=Math.ceil(18-minY+maxY+10), H=Math.max(H0,sideH), oy=18-minY+(H-H0)/2; // 不矮于左侧指标栏,图在其中垂直居中
353
387
  const dpr=Math.min(devicePixelRatio||1,3);
354
388
  cv.width=W*dpr;cv.height=H*dpr;cv.style.width=W+"px";cv.style.height=H+"px";
355
389
  const g=cv.getContext("2d");g.setTransform(dpr,0,0,dpr,0,0);g.clearRect(0,0,W,H);
@@ -410,14 +444,23 @@ function renderRows(dates){
410
444
  }
411
445
 
412
446
  // ---------- 渲染 ----------
447
+ function placeLayout(){
448
+ const wide=S.view==="3d"&&innerWidth>=980;
449
+ // 立体 + 宽屏:指标竖排在图左侧一栏(永不和图重叠),份额条和图例上到大数字右边
450
+ if(wide){ $("heroR").append($("share"),$("shareLegend")); $("kpiOver").append($("kpis")); $("kpiOver").hidden=false }
451
+ else { $("heroR").append($("kpis")); $("head").append($("share"),$("shareLegend")); $("kpiOver").hidden=true }
452
+ document.querySelector(".chartbox").classList.toggle("side",wide);
453
+ }
413
454
  function render(){
455
+ placeLayout();
414
456
  readColors();
415
457
  const dates=rangeDates();
416
458
  renderHead();
417
459
  const box=$("mainScroll");
418
460
  if(S.view==="2d"){
419
461
  $("w2d").hidden=false;$("cv3").hidden=true;
420
- const r=gridSVG($("grid2d"),dates,S.on,{width:box.clientWidth,min:11,max:S.range==="year"?20:46,labels:true});
462
+ const room=Math.max(160,innerHeight-(box.getBoundingClientRect().top+scrollY)-62);
463
+ const r=gridSVG($("grid2d"),dates,S.on,{width:box.clientWidth,min:9,max:Math.min(S.range==="year"?20:46,Math.floor((room-16)/7)),labels:true});
421
464
  const cut=r.lv.cut||[];
422
465
  $("scale").innerHTML=`${L.scale2d} ${[1,2,3,4,5].map(l=>`<i style="background:${mix(C.ink,C.empty,LV[l]*.85)}"></i>`).join("")} <span class="num">${L.cuts} ${cut.map(fmt).join(" / ")}</span>`;
423
466
  }else{
@@ -449,9 +492,22 @@ document.addEventListener("pointermove",e=>{
449
492
  if(el&&el.closest("svg"))ds=el.getAttribute("data-d");
450
493
  else if(e.target.id==="cv3"){const r=e.target.getBoundingClientRect(),x=e.clientX-r.left,y=e.clientY-r.top;
451
494
  for(let i=hexes.length-1;i>=0;i--){if(inPoly(x,y,hexes[i].pts)){ds=hexes[i].ds;break}}}
495
+ if(drag&&drag.moved)return;
452
496
  if(ds)showTip(ds,e);else tip.style.display="none";
453
497
  });
454
498
 
499
+ // ---------- 拖动旋转(双击复位) ----------
500
+ let drag=null, raf=0;
501
+ const cv3=$("cv3");
502
+ cv3.addEventListener("pointerdown",e=>{drag={x:e.clientX,y:e.clientY,a:lastAng.a,e:lastAng.e,moved:false};cv3.setPointerCapture(e.pointerId)});
503
+ cv3.addEventListener("pointermove",e=>{if(!drag)return;const dx=e.clientX-drag.x,dy=e.clientY-drag.y;
504
+ if(Math.abs(dx)+Math.abs(dy)>3)drag.moved=true; if(!drag.moved)return;
505
+ S.rot={a:Math.min(70,Math.max(6,drag.a-dx*.25)),e:Math.min(70,Math.max(15,drag.e+dy*.25))};
506
+ tip.style.display="none"; cancelAnimationFrame(raf); raf=requestAnimationFrame(()=>draw3D(rangeDates()))});
507
+ const endDrag=()=>{drag=null};
508
+ cv3.addEventListener("pointerup",endDrag);cv3.addEventListener("pointercancel",endDrag);
509
+ cv3.addEventListener("dblclick",()=>{S.rot=null;render()});
510
+
455
511
  // ---------- 文案 + 控件 ----------
456
512
  ["h1","fig1","h2","h2note","v3d","v2d","mTotal","mNoCache","mCost","rData","rYear"].forEach(id=>$(id).textContent=L[id]);
457
513
  ["gView","gMetric","gRange"].forEach(id=>$(id).setAttribute("aria-label",L[id]));
@@ -461,14 +517,11 @@ seg(["v3d","v2d"],"view",["3d","2d"]);
461
517
  seg(["mTotal","mNoCache","mCost"],"metric",["total","nocache","cost"]);
462
518
  seg(["rData","rYear"],"range",["data","year"]);
463
519
  $("v3d").setAttribute("aria-pressed",S.view==="3d");$("v2d").setAttribute("aria-pressed",S.view==="2d");
464
- $("tools").innerHTML=TOOLS.map(t=>`<button class="tool" data-k="${t.k}" aria-pressed="true"><i style="background:var(--c-${t.k})"></i>${t.n}</button>`).join("");
465
- function toggle(k){if(S.on.has(k)){if(S.on.size===1)return;S.on.delete(k)}else S.on.add(k);
466
- document.querySelectorAll(".tool").forEach(x=>x.setAttribute("aria-pressed",S.on.has(x.dataset.k)));render()}
467
- $("tools").addEventListener("click",e=>{const b=e.target.closest(".tool");if(b)toggle(b.dataset.k)});
520
+ function toggle(k){if(S.on.has(k)){if(S.on.size===1)return;S.on.delete(k)}else S.on.add(k);render()}
521
+ $("shareLegend").addEventListener("click",e=>{if(e.target.closest(".more")){S.legendAll=true;render();return}const b=e.target.closest(".tool");if(b)toggle(b.dataset.k)});
468
522
  $("rows").addEventListener("click",e=>{const r=e.target.closest(".row");if(r)toggle(r.dataset.k)});
469
523
  // 双击某家 = 只看它
470
- $("tools").addEventListener("dblclick",e=>{const b=e.target.closest(".tool");if(!b)return;S.on=new Set([b.dataset.k]);
471
- document.querySelectorAll(".tool").forEach(x=>x.setAttribute("aria-pressed",S.on.has(x.dataset.k)));render()});
524
+ $("shareLegend").addEventListener("dblclick",e=>{const b=e.target.closest(".tool");if(!b)return;S.on=new Set([b.dataset.k]);render()});
472
525
 
473
526
  const g=new Date(D.generatedAt);
474
527
  $("brand").textContent=L.brand;