File size: 9,376 Bytes
7cca660
0784b1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7cca660
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>B-Real 具身智能榜单</title>
<style>
  :root {
    color-scheme: light;
    --bg: #ffffff; --panel: #f7f8fa; --panel-2: #eef0f4; --border: #dfe3e9;
    --text: #1a1d21; --muted: #667085; --accent: #2f6feb; --accent-soft: #e8efff;
    --gold: #c99a1e; --silver: #8d9299; --bronze: #a9714b; --row-hover: #f2f6ff;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: #14161a; --panel: #1b1e24; --panel-2: #22262e; --border: #2e333c;
      --text: #e7eaee; --muted: #98a1ad; --accent: #6c9bff; --accent-soft: #1e2a44;
      --gold: #e0b84a; --silver: #a8aeb6; --bronze: #c88d64; --row-hover: #1f2530;
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #14161a; --panel: #1b1e24; --panel-2: #22262e; --border: #2e333c;
    --text: #e7eaee; --muted: #98a1ad; --accent: #6c9bff; --accent-soft: #1e2a44;
    --gold: #e0b84a; --silver: #a8aeb6; --bronze: #c88d64; --row-hover: #1f2530;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    padding: 24px clamp(16px, 4vw, 40px) 48px;
  }
  .wrap { max-width: 1200px; margin: 0 auto; }
  h1 { font-size: clamp(20px, 2.4vw, 28px); margin: 0 0 6px; letter-spacing: -0.01em; }
  .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
  .sub a { color: var(--accent); text-decoration: none; }

  .tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
  .tab {
    appearance: none; border: 1px solid transparent; border-bottom: none;
    background: transparent; color: var(--muted); font: inherit; font-weight: 600;
    cursor: pointer; padding: 9px 16px; border-radius: 8px 8px 0 0; margin-bottom: -1px;
  }
  .tab:hover { color: var(--text); background: var(--panel); }
  .tab[aria-selected="true"] { color: var(--accent); background: var(--bg);
    border-color: var(--border); border-bottom: 1px solid var(--bg); }

  .toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
  .search { flex: 1 1 220px; min-width: 160px; max-width: 340px; padding: 8px 12px;
    border-radius: 8px; border: 1px solid var(--border); background: var(--panel);
    color: var(--text); font: inherit; }
  .search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
  .count { color: var(--muted); font-size: 13px; margin-left: auto; }

  .card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
  .scroll { overflow-x: auto; }
  table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
  thead th { position: sticky; top: 0; z-index: 1; background: var(--panel-2);
    color: var(--muted); font-size: 12px; font-weight: 600; text-align: left;
    padding: 10px 14px; white-space: nowrap; border-bottom: 1px solid var(--border); }
  thead th.num, tbody td.num { text-align: right; }
  tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: var(--row-hover); }
  td.model { font-weight: 600; white-space: normal; min-width: 150px; }
  td.rank { font-weight: 700; color: var(--muted); width: 1%; }
  td.rank.r1 { color: var(--gold); }
  td.rank.r2 { color: var(--silver); }
  td.rank.r3 { color: var(--bronze); }
  td.score { font-weight: 700; color: var(--accent); }
  .empty { padding: 28px 14px; text-align: center; color: var(--muted); }

  .note { margin-top: 16px; padding: 12px 14px; background: var(--panel);
    border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
    font-size: 12.5px; white-space: pre-wrap; }
  footer { margin-top: 24px; color: var(--muted); font-size: 12px; }
  footer a { color: var(--accent); text-decoration: none; }
</style>
</head>
<body>
<div class="wrap">
  <h1>B-Real 具身智能榜单</h1>
  <p class="sub" id="subtitle">Embodied AI Leaderboard</p>

  <nav class="tabs" id="tabs" role="tablist"></nav>

  <div class="toolbar">
    <input id="search" class="search" type="search" placeholder="搜索模型或机构…" autocomplete="off">
    <span class="count" id="count"></span>
  </div>

  <div class="card" id="card"></div>
  <div class="note" id="note" hidden></div>

  <footer id="footer"></footer>
</div>

<script>
const state = { summary: null, bench: null, board: {}, filter: "" };

async function getJSON(url) {
  const res = await fetch(url, { cache: "no-cache" });
  if (!res.ok) throw new Error(`${url} -> HTTP ${res.status}`);
  return res.json();
}

const el = (tag, cls, text) => {
  const n = document.createElement(tag);
  if (cls) n.className = cls;
  if (text != null) n.textContent = text;
  return n;
};

function rankClass(rank) { return rank === 1 ? "r1" : rank === 2 ? "r2" : rank === 3 ? "r3" : ""; }
const fmt = (v) => (v == null || v === "") ? "" : (typeof v === "number" ? (Math.round(v * 100) / 100).toString() : v);

const COLS = [
  { key: "rank",         label: "#",        num: true },
  { key: "name",         label: "模型"                },
  { key: "organization", label: "机构"                },
  { key: "parameters",   label: "参数量"              },
  { key: "score",        label: "综合得分",  num: true },
  { key: "published",    label: "发布日期"             },
];

function renderBoard() {
  const rows = state.board[state.bench.slug] || [];
  const q = state.filter.trim().toLowerCase();
  const shown = q ? rows.filter(r =>
    (r.name + r.organization + r.parameters).toLowerCase().includes(q)) : rows;

  const card = document.getElementById("card");
  card.replaceChildren();
  const scroll = el("div", "scroll");
  const table = el("table");
  const thead = el("thead");
  const trh = el("tr");
  for (const c of COLS) trh.append(el("th", c.num ? "num" : "", c.label));
  thead.append(trh); table.append(thead);

  const tbody = el("tbody");
  for (const r of shown) {
    const tr = el("tr");
    for (const c of COLS) {
      let cls = c.num ? "num" : "";
      if (c.key === "name") cls = "model";
      if (c.key === "rank") cls += " rank " + rankClass(r.rank);
      if (c.key === "score") cls += " score";
      const val = r[c.key];
      tr.append(el("td", cls, (val != null && val !== "") ? fmt(val) : "—"));
    }
    tbody.append(tr);
  }
  if (!shown.length) {
    const tr = el("tr"), td = el("td", "empty", q ? `没有匹配 "${state.filter}" 的条目` : "暂无数据");
    td.colSpan = COLS.length; tr.append(td); tbody.append(tr);
  }
  table.append(tbody); scroll.append(table); card.append(scroll);

  document.getElementById("count").textContent =
    q ? `${shown.length} / ${rows.length} 个模型` : `${rows.length} 个模型`;

  const note = document.getElementById("note");
  const text = state.bench && state.bench.scoring_note;
  if (text) { note.hidden = false; note.textContent = "计分说明:\n" + text; }
  else { note.hidden = true; note.textContent = ""; }
}

function selectBench(slug) {
  state.bench = state.summary.benches.find(b => b.slug === slug) || state.summary.benches[0];
  state.filter = "";
  document.getElementById("search").value = "";
  for (const b of document.querySelectorAll(".tab"))
    b.setAttribute("aria-selected", String(b.dataset.slug === state.bench.slug));
  if (location.hash !== "#" + slug) history.replaceState(null, "", "#" + slug);
  renderBoard();
}

async function main() {
  try {
    state.summary = await getJSON("data/summary.json");
  } catch (err) {
    document.getElementById("card").append(
      el("div", "empty", `无法加载 data/summary.json:${err.message}`));
    return;
  }
  const period = state.summary.period;
  document.getElementById("subtitle").innerHTML = period
    ? `Embodied AI Leaderboard · 评测周期 <b>${period}</b>`
    : "Embodied AI Leaderboard";

  const nav = document.getElementById("tabs");
  for (const b of state.summary.benches) {
    const btn = el("button", "tab", `${b.title} (${b.rows})`);
    btn.type = "button"; btn.role = "tab"; btn.dataset.slug = b.slug;
    btn.setAttribute("aria-selected", "false");
    btn.addEventListener("click", () => selectBench(b.slug));
    nav.append(btn);
  }

  await Promise.all(state.summary.benches.map(async b => {
    state.board[b.slug] = await getJSON(`data/${b.slug}/leaderboard.json`).catch(() => []);
  }));

  document.getElementById("search").addEventListener("input", (e) => {
    state.filter = e.target.value; renderBoard();
  });
  window.addEventListener("hashchange", () => {
    const slug = location.hash.slice(1);
    if (state.summary.benches.some(b => b.slug === slug)) selectBench(slug);
  });

  const slug = location.hash.slice(1);
  selectBench(state.summary.benches.some(b => b.slug === slug)
    ? slug : state.summary.benches[0].slug);

  document.getElementById("footer").innerHTML = "数据来源:" +
    state.summary.benches.map(b =>
      `<a href="${b.source}" target="_blank" rel="noopener">${b.title}</a>`
    ).join(" · ");
}

main();
</script>
</body>
</html>