papersearch 0.7.1 → 0.7.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 (94) hide show
  1. package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
  2. package/dist/capabilities/download/batch/batch.js +12 -1
  3. package/dist/capabilities/download/batch/batch.js.map +1 -1
  4. package/dist/capabilities/download/batch/batchSummary.d.ts.map +1 -1
  5. package/dist/capabilities/download/batch/batchSummary.js +16 -7
  6. package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
  7. package/dist/capabilities/download/batch/journalKey.d.ts +12 -0
  8. package/dist/capabilities/download/batch/journalKey.d.ts.map +1 -0
  9. package/dist/capabilities/download/batch/journalKey.js +30 -0
  10. package/dist/capabilities/download/batch/journalKey.js.map +1 -0
  11. package/dist/capabilities/download/content/pdf/DownloadTier.d.ts +4 -0
  12. package/dist/capabilities/download/content/pdf/DownloadTier.d.ts.map +1 -1
  13. package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.d.ts.map +1 -1
  14. package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js +2 -0
  15. package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js.map +1 -1
  16. package/dist/capabilities/download/content/pdf/school.js +2 -0
  17. package/dist/capabilities/download/content/pdf/school.js.map +1 -1
  18. package/dist/capabilities/download/types.d.ts +4 -0
  19. package/dist/capabilities/download/types.d.ts.map +1 -1
  20. package/dist/cli.js +32 -9
  21. package/dist/cli.js.map +1 -1
  22. package/dist/infrastructure/school/SchoolMcpClient.d.ts +4 -0
  23. package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
  24. package/dist/infrastructure/school/SchoolMcpClient.js +20 -1
  25. package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
  26. package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
  27. package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
  28. package/dist/infrastructure/school/SchoolReadiness.js +3 -0
  29. package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
  30. package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
  31. package/dist/infrastructure/school/SchoolResultNormalizer.js +5 -0
  32. package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
  33. package/dist/infrastructure/school/types.d.ts +12 -0
  34. package/dist/infrastructure/school/types.d.ts.map +1 -1
  35. package/dist/management/pro/activate.d.ts +36 -0
  36. package/dist/management/pro/activate.d.ts.map +1 -0
  37. package/dist/management/pro/activate.js +122 -0
  38. package/dist/management/pro/activate.js.map +1 -0
  39. package/dist/management/pro/install.d.ts +15 -0
  40. package/dist/management/pro/install.d.ts.map +1 -1
  41. package/dist/management/pro/install.js +39 -12
  42. package/dist/management/pro/install.js.map +1 -1
  43. package/dist/management/reports/index.d.ts +6 -0
  44. package/dist/management/reports/index.d.ts.map +1 -1
  45. package/dist/management/reports/index.js +6 -0
  46. package/dist/management/reports/index.js.map +1 -1
  47. package/dist/management/school/autoUpdate.d.ts.map +1 -1
  48. package/dist/management/school/autoUpdate.js +1 -0
  49. package/dist/management/school/autoUpdate.js.map +1 -1
  50. package/dist/management/school/cliProgress.d.ts.map +1 -1
  51. package/dist/management/school/cliProgress.js +1 -0
  52. package/dist/management/school/cliProgress.js.map +1 -1
  53. package/dist/management/school/settingsWindow.d.ts +1 -0
  54. package/dist/management/school/settingsWindow.d.ts.map +1 -1
  55. package/dist/management/school/settingsWindow.js +2 -0
  56. package/dist/management/school/settingsWindow.js.map +1 -1
  57. package/dist/management/updates/selfUpdate.d.ts +86 -0
  58. package/dist/management/updates/selfUpdate.d.ts.map +1 -0
  59. package/dist/management/updates/selfUpdate.js +194 -0
  60. package/dist/management/updates/selfUpdate.js.map +1 -0
  61. package/package.json +1 -1
  62. package/school/paper_search_school/adapters/annual_reviews/__init__.py +1 -0
  63. package/school/paper_search_school/adapters/ieee/__init__.py +1 -0
  64. package/school/paper_search_school/assets/capsule.html +927 -202
  65. package/school/paper_search_school/assets/capsule_en.json +290 -22
  66. package/school/paper_search_school/assets/capsule_fr.json +1331 -0
  67. package/school/paper_search_school/assets/capsule_ja.json +1331 -0
  68. package/school/paper_search_school/assets/capsule_ko.json +1331 -0
  69. package/school/paper_search_school/assets/capsule_zh-Hant.json +2462 -0
  70. package/school/paper_search_school/cli.py +15 -1
  71. package/school/paper_search_school/cold_start.py +70 -8
  72. package/school/paper_search_school/config.py +2 -0
  73. package/school/paper_search_school/download_diagnostics.py +4 -4
  74. package/school/paper_search_school/engine/batch_capture.py +35 -1
  75. package/school/paper_search_school/engine/batch_diagnostics.py +1 -1
  76. package/school/paper_search_school/engine/batch_institution.py +41 -0
  77. package/school/paper_search_school/engine/batch_login.py +65 -1
  78. package/school/paper_search_school/engine/batch_waits.py +22 -8
  79. package/school/paper_search_school/engine/bridge.py +11 -0
  80. package/school/paper_search_school/i18n.py +46 -22
  81. package/school/paper_search_school/orchestrator.py +60 -8
  82. package/school/paper_search_school/pro_status.py +54 -63
  83. package/school/paper_search_school/progress_capsule.py +180 -24
  84. package/school/paper_search_school/progress_reporter.py +51 -5
  85. package/school/paper_search_school/progress_view.py +3 -2
  86. package/school/paper_search_school/school_login.py +18 -4
  87. package/school/paper_search_school/school_switch.py +102 -0
  88. package/school/paper_search_school/school_test.py +335 -0
  89. package/school/paper_search_school/server.py +16 -0
  90. package/school/paper_search_school/updates.py +222 -0
  91. package/school/paper_search_school/user_settings.py +8 -3
  92. package/skills/paper-search/SKILL.md +1 -1
  93. package/skills/paper-search/references/cli-contract.md +1 -1
  94. package/skills/paper-search/references/school-setup.md +1 -1
@@ -95,16 +95,28 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
95
95
  .head .title { font-weight: 600; font-size: 14px; }
96
96
  .head .sub { font-size: 12px; color: var(--dim); }
97
97
  /* The head's buttons close together (user, 2026-11-17): the pin's room comes from their gaps, not the text's. */
98
- .tools { display: flex; align-items: center; gap: 2px; margin-right: -3px; flex: none; }
99
- .tools .iconbtn { margin: 0; padding: 3px; }
98
+ .tools { display: flex; align-items: center; gap: 0; margin-right: -3px; flex: none; }
99
+ /* Each a 32 px target, drawn where it was (user, 2026-11-21: 最小化 was hard to hit): the margins take back what the
100
+ padding adds, the icons 24 px apart as before. */
101
+ .tools .iconbtn { margin: -4px; padding: 8px; }
100
102
  .iconbtn { background: none; border: none; padding: 4px; margin: -4px; border-radius: 6px; color: var(--dim); display: inline-flex; cursor: pointer; }
101
103
  .iconbtn:hover { background: var(--hover); color: var(--fg); }
102
104
  .paper { margin: 14px 0 12px; }
103
105
  .paper .name { line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
104
106
  .paper .where { color: var(--faint); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
105
- .paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; }
107
+ .paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
106
108
  .paper-link { display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 6px; }
107
- .paper-link .name, .paper-link .where, .paper-link .notice { display: block; }
109
+ .paper-link .where, .paper-link .notice { display: block; }
110
+ /* The paper's block is one height whatever the paper (user, 2026-11-21: the card shook up and down as papers went by,
111
+ each change of height resizing the window, whose edge moves): the title two lines high even when one, the journal or
112
+ a notice one line, the step or the lane's line one row, each a fixed height. A title's symbols or another script, drawn
113
+ in a fallback font, made a line a pixel or two taller (Windows); the step's bar and the lane's line were not as tall
114
+ as each other. test_the_running_card_keeps_its_height_whatever_the_paper. */
115
+ .paper .name { height: 2.9em; }
116
+ .paper .where, .paper .notice { height: 1.45em; line-height: 1.45; }
117
+ .paper-status { display: flex; align-items: center; height: 18px; margin-top: 8px; overflow: hidden; }
118
+ .paper-status .steps { flex: 1; min-width: 0; margin-top: 0; }
119
+ .paper-status .line { flex: 1; min-width: 0; margin-top: 0; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
108
120
  .paper-link:hover .name { text-decoration: underline; }
109
121
  .paper-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
110
122
  .steps { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
@@ -219,17 +231,64 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
219
231
  .nav-sub { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
220
232
  .settings-note { font-size: 11px; color: var(--ok); margin-top: 8px; }
221
233
  .key-group { font-size: 11px; color: var(--faint); margin: 12px 0 2px; }
222
- .key-group.pro-group { margin-top: 16px; }
223
- /* The Markdown page (PaperSearch Pro): its tile and state, what it does, 安装 or its progress, where to report. */
224
- .pro-head { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
225
- .pro-tile { width: 34px; height: 34px; border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center;
226
- background: var(--accent); color: #fff; }
227
- .pro-tile svg.i { width: 18px; height: 18px; }
228
- .pro-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
234
+ /* The home page's last line (user, 2026-11-21): PaperSearch Pro, a blue link at its left; the language at its
235
+ right, one menu of the languages each in its own name. Installed, Pro's features are rows above, marked Pro. */
236
+ .settings .home-foot { gap: 12px; padding: 10px 0 0; }
237
+ /* 关于 PaperSearch (user, 2026-11-21): its icon and name centered, Pro's pill beside the name with the line a little to
238
+ the right (not the name alone centered: too far right), a wider space before Pro's part. */
239
+ .app-icon { display: block; flex: none; }
240
+ .about-hero { display: flex; flex-direction: column; align-items: center; margin-top: 12px; text-align: center; }
241
+ .about-name { font-size: 16px; font-weight: 600; margin-top: 8px; white-space: nowrap; }
242
+ .about-name.with-pill { transform: translateX(8px); }
243
+ .about-name .pro-pill { margin-left: 6px; vertical-align: 2px; }
244
+ .about-version { font-size: 12px; color: var(--dim); margin-top: 3px; }
245
+ .about-version.new, .about-version.bad { color: var(--bad); }
246
+ .about-action { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
247
+ .about-action .btn.primary { width: 100%; justify-content: center; padding: 6px 10px; font-size: 13px; }
248
+ .about-action .btn.link { padding: 0; font-size: 12px; }
249
+ .about-action .pro-bar { width: 100%; }
250
+ .update-steps { align-self: stretch; }
251
+ .about-caption { text-align: center; font-size: 11px; color: var(--dim); margin-top: 6px; }
252
+ .about-gap { height: 18px; }
253
+ .about-sec { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; margin-top: 22px; padding-bottom: 8px;
254
+ border-bottom: 0.5px solid var(--line); }
255
+ .about-feat { padding: 6px 0; }
256
+ .about-feat b { font-weight: 600; font-size: 12px; }
257
+ .about-feat .pro-tag { display: inline-block; margin-left: 6px; vertical-align: 1px; }
258
+ .about-feat .pl-sub { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 1px; }
259
+ .about-sub { font-size: 11px; color: var(--faint); margin: 12px 0 2px; }
260
+ .settings .pro-activate { margin-top: 14px; }
261
+ .version-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; border: none; background: none;
262
+ font: inherit; font-size: 12px; color: var(--dim); cursor: pointer; }
263
+ .version-link.new { color: var(--bad); font-weight: 600; }
264
+ .version-link .pl-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
265
+ .version-link:hover .pl-text { text-decoration: underline; }
266
+ .version-link svg.i { width: 14px; height: 14px; flex: none; }
267
+ .reopen-line { display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 7px 10px; border: none; border-radius: 8px;
268
+ background: rgba(22, 163, 74, 0.10); color: var(--ok); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
269
+ .reopen-line svg.i { width: 14px; height: 14px; flex: none; }
270
+ .reopen-line .k { margin-left: auto; font-weight: 600; white-space: nowrap; }
271
+ .iconbtn.has-dot { position: relative; }
272
+ .iconbtn.has-dot::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
273
+ .tools .iconbtn.has-dot::after { top: 6px; right: 6px; }
274
+ .nav-row .app-icon { margin: 0 1px; }
275
+ .lang-btn { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; border: none;
276
+ background: none; font: inherit; font-size: 12px; cursor: pointer; }
277
+ .lang-btn svg.i { width: 14px; height: 14px; flex: none; }
278
+ .lang-wrap { position: relative; flex: none; }
279
+ .lang-btn { color: var(--dim); }
280
+ .lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--fg); }
281
+ .lang-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; min-width: 150px; box-sizing: border-box; padding: 4px;
282
+ background: var(--bg); border-radius: 10px; box-shadow: 0 0 0 0.5px var(--line), 0 6px 20px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.08); }
283
+ .lang-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 5px 8px;
284
+ border: none; border-radius: 6px; background: none; font: inherit; font-size: 12px; color: var(--fg); text-align: left; cursor: pointer; }
285
+ .lang-menu button:hover { background: var(--hover); }
286
+ .lang-menu button[aria-checked="true"] { color: var(--accent); }
287
+ .lang-menu button svg.i { width: 14px; height: 14px; }
288
+ .lang-more { margin: 4px 4px 0; padding: 5px 4px 2px; border-top: 0.5px solid var(--line); font-size: 11px; color: var(--faint); }
289
+ .nav-title .pro-pill.feature { margin-left: 6px; }
290
+ /* Pro's pill (蓝标) and its texts, on the home page, 关于 PaperSearch and Pro's feature pages. */
229
291
  .pro-pill { font-size: 10.5px; font-weight: 500; line-height: 1.5; color: var(--accent); background: var(--hover); border-radius: 999px; padding: 0 7px; }
230
- .pro-state { font-size: 12px; color: var(--dim); }
231
- .pro-state.ok { color: var(--ok); }
232
- .pro-state.bad { color: var(--bad); }
233
292
  .pro-desc { font-size: 12px; line-height: 1.55; color: var(--dim); margin-top: 10px; }
234
293
  .pro-action { margin-top: 12px; }
235
294
  .pro-action:empty { display: none; }
@@ -244,13 +303,33 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
244
303
  /* What Pro keeps, its counts, its sites and whether it is free (user, 2026-11-19). */
245
304
  /* What a Markdown keeps, the counts, the sites and the usage, as drawn on 2026-11-19: taller than the
246
305
  other settings pages, which the user prefers to a crowded page (the window grows, as for API key). */
247
- .pro-check { margin-left: auto; padding-right: 0; font-size: 12px; }
248
306
  .pro-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
249
307
  .pro-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px 2px 7px; border-radius: 999px;
250
308
  border: 0.5px solid var(--line); color: var(--dim); }
251
309
  .pro-chip svg.i { width: 13px; height: 13px; }
310
+ /* What sets Pro's Markdown apart, a row that opens like the platforms' (user, 2026-11-21). */
311
+ .pro-merits { padding: 0 0 8px 26px; }
312
+ .pro-merit { display: flex; gap: 8px; padding: 6px 0; }
313
+ .pro-merit svg.i { width: 15px; height: 15px; margin-top: 1px; color: var(--dim); }
314
+ .pro-merit b { display: block; font-weight: 600; font-size: 12px; }
315
+ .pro-merit span { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 1px; }
252
316
  .pro-stats { margin-top: 12px; }
253
- .pro-row.static { cursor: default; }
317
+ /* Pro's page (user, 2026-11-21): what it does now and what is coming, each a line; the activation code. */
318
+ .pro-tag { flex: none; align-self: flex-start; font-size: 10.5px; line-height: 1.6; color: var(--dim); background: var(--hover);
319
+ border-radius: 4px; padding: 0 5px; }
320
+ .pro-activate { margin-top: 14px; padding-top: 12px; border-top: 0.5px solid var(--line); }
321
+ .pro-code-label { font-size: 11px; color: var(--dim); margin-bottom: 5px; }
322
+ .pro-code { display: flex; gap: 6px; }
323
+ .settings .pro-code input { flex: 1; min-width: 0; width: auto; height: 30px; text-align: left; background: var(--bg); padding: 0 8px;
324
+ font-size: 13px; letter-spacing: 0.04em; }
325
+ .pro-action .pro-code .btn.primary { width: auto; flex: none; padding: 5px 12px; }
326
+ .settings .pro-action .err { text-align: left; margin: 6px 0 0; }
327
+ .pro-needed { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px;
328
+ border-top: 0.5px solid var(--line); font-size: 12px; color: var(--dim); }
329
+ .pro-needed .btn.link { padding-right: 0; gap: 2px; white-space: nowrap; flex: none; }
330
+ .pro-needed .btn.link svg.i { width: 13px; height: 13px; }
331
+ .pro-use .ok { color: var(--ok); }
332
+ .pro-use .bad { color: var(--bad); }
254
333
  .pro-sites { padding: 0 0 8px 26px; }
255
334
  /* The platforms by kind, each site once (user, 2026-11-20: a list in groups, the multidisciplinary ones first). */
256
335
  .site-group { font-size: 11px; color: var(--faint); margin: 6px 0 3px; }
@@ -269,6 +348,9 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
269
348
  .login-row:hover .ls-name { color: var(--accent); }
270
349
  .login-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
271
350
  .login-row .ls-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
351
+ .login-row .ls-n { flex: none; width: 12px; font-size: 11px; color: var(--faint); text-align: left; }
352
+ /* Under the schools, whose rows end in a line already: its own line below, none above (two showed, 2026-11-21). */
353
+ .settings .switch-row { border-top: none; border-bottom: 0.5px solid var(--line); }
272
354
  .login-row .ls-acct { margin-left: auto; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
273
355
  .login-row svg.i { width: 13px; height: 13px; flex: none; color: var(--faint); }
274
356
  .tag.fill { background: rgba(22, 163, 74, 0.12); color: var(--ok); }
@@ -278,9 +360,11 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
278
360
  .tag.none { background: var(--hover); color: var(--dim); }
279
361
  .login-form { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; padding: 0 0 8px; font-size: 12px; color: var(--dim); }
280
362
  .settings .login-form input { width: 100%; box-sizing: border-box; text-align: left; background: var(--bg); padding: 5px 8px; font-size: 13px; }
281
- .login-pw { display: flex; align-items: center; gap: 4px; }
282
- .login-pw input { flex: 1; min-width: 0; }
283
- .login-pw .iconbtn { margin: 0; flex: none; }
363
+ /* The eye inside the password's box, and the test article's line ending where the boxes end: the three rows' right
364
+ edges in line (user, 2026-11-21, 甲). */
365
+ .login-pw { position: relative; display: block; min-width: 0; }
366
+ .settings .login-pw input { padding-right: 30px; }
367
+ .login-pw .iconbtn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); margin: 0; }
284
368
  .login-form .err, .login-form .key-actions { grid-column: 1 / -1; }
285
369
  .login-form .err { text-align: left; margin: 0; }
286
370
  .login-form .err:empty { display: none; }
@@ -293,13 +377,56 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
293
377
  .login-links .link-btn:hover, .login-links .link-btn:focus-visible { color: var(--accent); }
294
378
  .login-links .link-btn.danger:hover, .login-links .link-btn.danger:focus-visible, .login-links .link-btn.confirm { color: var(--bad); }
295
379
  .login-links .sep { color: var(--dim); }
380
+ /* 测试登录 (user, 2026-11-21, as drawn): the article, then how the test went; while it runs, its steps in rows of their
381
+ own height and one line for what the download says, so that the page does not move as it goes. */
382
+ .login-form .test-result { grid-column: 1 / -1; }
383
+ .login-form .test-err { grid-column: 2; }
384
+ .test-article { display: flex; align-items: center; gap: 8px; min-width: 0; }
385
+ .test-article .what { flex: 1; min-width: 0; color: var(--fg); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
386
+ .test-article .what.empty { color: var(--dim); font-size: 11.5px; } /* none filled in: what to do */
387
+ .test-article .test-btn { padding: 3px 10px; flex: none; white-space: nowrap; }
388
+ .test-article .link-btn, .test-edit .link-btn { border: none; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; flex: none; }
389
+ /* The box holds the text and its button side by side: 查找中… is wider than 确定 and went over the text (user,
390
+ 2026-11-21); the text gives way to whatever the button says, in any language. */
391
+ .test-edit { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; height: 26px; box-sizing: border-box;
392
+ background: var(--bg); border: 0.5px solid var(--line); border-radius: 6px; padding: 0 8px; }
393
+ .test-edit:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
394
+ .settings .test-edit input { flex: 1; min-width: 0; width: auto; height: 24px; border: none; background: none; padding: 0;
395
+ text-align: left; font-size: 13px; }
396
+ .settings .test-edit input:focus { outline: none; }
397
+ .test-edit .link-btn { font-size: 12px; white-space: nowrap; }
398
+ .test-edit .link-btn:disabled { color: var(--dim); cursor: default; }
399
+ .test-result { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; }
400
+ .test-result svg.i { width: 15px; height: 15px; flex: none; margin-top: 1px; }
401
+ .test-result.ok { background: rgba(22, 163, 74, 0.10); } .test-result.ok svg.i { color: var(--ok); }
402
+ .test-result.bad { background: rgba(220, 38, 38, 0.08); } .test-result.bad svg.i { color: var(--bad); }
403
+ .test-result .t { color: var(--fg); font-weight: 600; } .test-result .d { margin-top: 2px; }
404
+ .login-test { padding: 2px 0 8px; font-size: 12px; color: var(--dim); }
405
+ .test-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
406
+ .test-steps li { display: flex; align-items: center; gap: 8px; height: 18px; color: var(--faint); }
407
+ .test-steps li svg.i { width: 15px; height: 15px; color: var(--ok); }
408
+ .test-steps li.done { color: var(--dim); }
409
+ .test-steps li.now { color: var(--fg); font-weight: 600; }
410
+ .test-steps .mark { width: 9px; height: 9px; margin: 0 3px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; }
411
+ .test-steps li.now .mark { background: var(--accent); border-color: var(--accent); }
412
+ .test-phase { height: 18px; line-height: 18px; margin: 6px 0 2px 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
413
+ .login-test .key-actions { margin-top: 6px; }
296
414
  .login-add { padding: 0 0 10px; }
297
415
  .login-add-row .ls-name { font-weight: 500; }
298
416
  .login-add-row svg.i:first-child { color: var(--accent); }
299
417
  .login-find { display: flex; gap: 6px; }
300
418
  .settings .login-find input { flex: 1; min-width: 0; text-align: left; background: var(--bg); padding: 5px 8px; font-size: 13px; }
301
- .login-found { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 0; border-bottom: 0.5px solid var(--line); }
302
- .login-found .ls-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
419
+ /* 支持的学校: a search field, its magnifier inside (user, 2026-11-21: the plain box looked out of place). */
420
+ .support-search { display: flex; align-items: center; gap: 6px; height: 32px; margin: 8px 0 6px; padding: 0 10px; box-sizing: border-box;
421
+ border: 0.5px solid var(--line); border-radius: 8px; background: var(--hover); color: var(--dim); }
422
+ .support-search:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
423
+ .settings .support-search input { flex: 1; min-width: 0; width: auto; height: 100%; padding: 0; border: none; background: none;
424
+ text-align: left; font-size: 13px; -webkit-appearance: none; appearance: none; }
425
+ .settings .support-search input:focus { outline: none; }
426
+ .login-found { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; padding: 5px 0; border-bottom: 0.5px solid var(--line); }
427
+ /* A long name wraps, not cut (user, 2026-11-21); what is said of it stays at its top right. */
428
+ .login-found .ls-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
429
+ .login-found .tag, .login-found .btn { flex: none; }
303
430
  .login-found .ls-fed { font-size: 11px; color: var(--faint); }
304
431
  .login-found .btn { margin-left: auto; }
305
432
  .login-add .login-found:last-child { border-bottom: none; }
@@ -325,9 +452,6 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
325
452
  .strip .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
326
453
  .strip svg.i { width: 14px; height: 14px; }
327
454
  .strip.warn-strip { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
328
- .seg { display: inline-flex; border: 0.5px solid var(--line); border-radius: 7px; overflow: hidden; }
329
- .seg button { font: inherit; font-size: 12px; padding: 3px 10px; border: none; background: none; color: var(--dim); cursor: pointer; }
330
- .seg button.on { background: var(--accent); color: #fff; }
331
455
  .prompt { display: flex; align-items: center; gap: 10px; }
332
456
  .prompt svg.i { width: 22px; height: 22px; }
333
457
  .prompt .t { font-weight: 600; font-size: 14px; }
@@ -354,6 +478,17 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
354
478
  font: inherit; color: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
355
479
  .grp .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
356
480
  .grp .row .reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
481
+ /* 支持的学校's head (back, title, the numbers, search) on top while its list scrolls (user, 2026-11-21). */
482
+ .support-top { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-bottom: 2px; }
483
+ #support-list .row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 0; border: none;
484
+ border-bottom: 0.5px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
485
+ #support-list .row:hover .reason { color: var(--accent); }
486
+ #support-list .row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
487
+ #support-list .row .reason { flex: 1; min-width: 0; overflow-wrap: anywhere; }
488
+ #support-list .row .n { font-weight: 600; }
489
+ #support-list .row svg.i { width: 14px; height: 14px; color: var(--faint); }
490
+ .support-region > .row .reason { font-weight: 600; }
491
+ .support-countries { padding-left: 14px; }
357
492
  .grp .row .n { font-weight: 600; }
358
493
  .grp .row svg.i { width: 14px; height: 14px; color: var(--faint); }
359
494
  .grp .m { font-size: 12px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -381,42 +516,62 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
381
516
  <div id="root" class="pill capsule-drag-region"></div>
382
517
  <script>
383
518
  "use strict";
384
- // English: the window's progress_language. The table (assets/capsule_en.json) is put
385
- // in here when the window loads the page; every text shown passes through tr().
519
+ // The window's progress_language: Chinese (zh, simplified) is the page's
520
+ // own; English (assets/capsule_en.json) and Traditional Chinese (assets/capsule_zh-Hant.json, made from it by
521
+ // school/tools/zh_hant_table.py, user 2026-11-21) are put in here when the window loads the page; every text shown
522
+ // passes through tr().
523
+ // Japanese, Korean and French too (user, 2026-11-21: "中文、英文、日语、韩文,还有法语…都需要支持"): a text their table
524
+ // does not know is said in English, not left in Chinese.
386
525
  const EN = /*CAPSULE_EN*/null;
387
- const EN_PATTERNS = EN ? EN.patterns.map(([source, target]) => [new RegExp(source), target]) : [];
526
+ const HANT = /*CAPSULE_ZH_HANT*/null;
527
+ const JA = /*CAPSULE_JA*/null;
528
+ const KO = /*CAPSULE_KO*/null;
529
+ const FR = /*CAPSULE_FR*/null;
530
+ const TABLES = Object.fromEntries([["en", EN], ["zh-Hant", HANT], ["ja", JA], ["ko", KO], ["fr", FR]].filter(([, table]) => table)
531
+ .map(([code, table]) => [code, { ...table, patterns: table.patterns.map(([source, target]) => [new RegExp(source), target]) }]));
388
532
  const HAN = /[\u4e00-\u9fff]/;
389
533
  let lang = "zh";
534
+ // The languages that list with a comma, not 、 (Japanese keeps 、).
535
+ const commaLang = () => ["en", "ko", "fr"].includes(lang);
390
536
  const BRACKETS = /^(.+?)((.+))$/;
391
537
  const LISTED = /^([^:]+):(.+)$/;
392
- function trOne(core) {
538
+ function trOne(core, table = TABLES[lang]) {
393
539
  if (!HAN.test(core)) return core;
394
- let english = Object.hasOwn(EN.exact, core) ? EN.exact[core] : null;
395
- if (english === null) {
396
- const found = EN_PATTERNS.find(([pattern]) => pattern.test(core));
397
- if (found) english = core.replace(found[0], found[1]);
540
+ let said = Object.hasOwn(table.exact, core) ? table.exact[core] : null;
541
+ if (said === null) {
542
+ const found = table.patterns.find(([pattern]) => pattern.test(core));
543
+ // What the text names in it is said too where it is a text of the table ("更新学校订阅下载扩展出错"); a name keeps
544
+ // its words, in Traditional Chinese its characters ("没权限,换红木兰大学").
545
+ if (found) {
546
+ const parts = found[0].exec(core);
547
+ said = core.replace(found[0], found[1].replace(/\$(\d)/g, (_, i) => (HAN.test(parts[i] || "") ? trOne(parts[i], table) : parts[i] || "")));
548
+ }
398
549
  }
399
- const parts = english === null && BRACKETS.exec(core);
550
+ // Traditional Chinese: a text the table does not know, its characters (a name keeps its words).
551
+ if (said === null && table.chars) return core.replace(/[\u4e00-\u9fff]/g, (c) => table.chars[c] || c);
552
+ const parts = said === null && BRACKETS.exec(core);
400
553
  // "开放下载 18(出版社 API 3、预印本 1)": the text and what its brackets list, each on its own.
401
- if (parts) english = trOne(parts[1]) + " (" + parts[2].split("、").map(trOne).join(", ") + ")";
554
+ if (parts) said = trOne(parts[1], table) + " (" + parts[2].split("、").map((p) => trOne(p, table)).join(", ") + ")";
402
555
  // "不完整:参考文献少 1 条,少 1 张图": a known word, then what it lists, each on its own.
403
- const listed = english === null && LISTED.exec(core);
404
- if (listed && trOne(listed[1]) !== listed[1]) english = trOne(listed[1]) + ": " + listed[2].split(",").map(trOne).join(", ");
405
- return english === null ? core : english;
556
+ const listed = said === null && LISTED.exec(core);
557
+ if (listed && trOne(listed[1], table) !== listed[1]) said = trOne(listed[1], table) + ": " + listed[2].split(",").map((p) => trOne(p, table)).join(", ");
558
+ // Japanese, Korean, French: what their table does not know, in English rather than in Chinese.
559
+ if (said === null && table !== TABLES.en && TABLES.en) return trOne(core, TABLES.en);
560
+ return said === null ? core : said;
406
561
  }
407
562
  function tr(text) {
408
563
  // "PDF、Markdown": the kinds' names need no table, only their separator.
409
- if (lang === "en" && text && !HAN.test(text) && String(text).includes("、")) return String(text).replace(/、/g, ", ");
410
- if (lang !== "en" || !EN || !text || !HAN.test(text)) return text;
564
+ if (commaLang() && text && !HAN.test(text) && String(text).includes("、")) return String(text).replace(/、/g, ", ");
565
+ if (!TABLES[lang] || !text || !HAN.test(text)) return text;
411
566
  return String(text).split(" · ").map((part) => {
412
567
  const core = part.trim();
413
568
  if (!core || !HAN.test(core)) return part;
414
- const english = trOne(core);
415
- return english === core ? part : part.replace(core, english);
569
+ const said = trOne(core);
570
+ return said === core ? part : part.replace(core, said);
416
571
  }).join(" · ");
417
572
  }
418
573
  function localize(node) {
419
- if (lang !== "en" || !EN) return;
574
+ if (!TABLES[lang]) return;
420
575
  const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
421
576
  for (let text = walker.nextNode(); text; text = walker.nextNode()) {
422
577
  const english = tr(text.nodeValue);
@@ -445,6 +600,13 @@ const ICONS = {
445
600
  left: '<path d="M15 6l-6 6 6 6"/>',
446
601
  right: '<path d="M9 6l6 6-6 6"/>',
447
602
  down: '<path d="M6 9l6 6 6-6"/>',
603
+ up: '<path d="M6 15l6-6 6 6"/>',
604
+ tick: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
605
+ // Two four-pointed stars: PaperSearch Pro's link (user, 2026-11-21).
606
+ upcircle: '<circle cx="12" cy="12" r="9"/><path d="M12 16V8M8.5 11.5L12 8l3.5 3.5"/>',
607
+ refresh: '<path d="M19.5 12a7.5 7.5 0 1 1-2.2-5.3"/><path d="M19.5 4.5v4h-4"/>',
608
+ sparkles: '<path d="M10 7a6 6 0 0 0 6 6a6 6 0 0 0 -6 6a6 6 0 0 0 -6 -6a6 6 0 0 0 6 -6z"/>'
609
+ + '<path d="M18.5 3a2.5 2.5 0 0 0 2.5 2.5a2.5 2.5 0 0 0 -2.5 2.5a2.5 2.5 0 0 0 -2.5 -2.5a2.5 2.5 0 0 0 2.5 -2.5z"/>',
448
610
  gear: gearPath(),
449
611
  clock: '<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/>',
450
612
  key: '<circle cx="8" cy="15" r="4"/><path d="M10.8 12.2L19 4M16 7l2.5 2.5M14 9l2 2"/>',
@@ -457,6 +619,8 @@ const ICONS = {
457
619
  gift: '<rect x="4" y="9" width="16" height="11" rx="1.5"/><path d="M3 9h18M12 9v11M12 9c-1.4-2.8-4.8-3.4-4.8-1.1 0 1.1 2.4 1.1 4.8 1.1zM12 9c1.4-2.8 4.8-3.4 4.8-1.1 0 1.1-2.4 1.1-4.8 1.1z"/>',
458
620
  plus: '<path d="M12 5v14M5 12h14"/>',
459
621
  globe: '<circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17M12 3.5c2.4 2.4 3.5 5.4 3.5 8.5s-1.1 6.1-3.5 8.5c-2.4-2.4-3.5-5.4-3.5-8.5s1.1-6.1 3.5-8.5z"/>',
622
+ search: '<circle cx="11" cy="11" r="6.5"/><path d="M20 20l-4.2-4.2"/>',
623
+ link: '<path d="M10 14a4.5 4.5 0 0 0 6.4 0l3.2-3.2a4.5 4.5 0 0 0-6.4-6.4L12 5.6"/><path d="M14 10a4.5 4.5 0 0 0-6.4 0l-3.2 3.2a4.5 4.5 0 0 0 6.4 6.4l1.2-1.2"/>',
460
624
  external: '<path d="M14 5h5v5M19 5l-8 8"/><path d="M18 14v4a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18V7a1.5 1.5 0 0 1 1.5-1.5H10"/>',
461
625
  };
462
626
  function gearPath() {
@@ -469,6 +633,27 @@ function gearPath() {
469
633
  return '<polygon points="' + pts.join(" ") + '"/><circle cx="12" cy="12" r="3"/>';
470
634
  }
471
635
  const icon = (name, extra) => '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"' + (extra || "") + ">" + ICONS[name] + "</svg>";
636
+ // PaperSearch's own icon (assets/icon.svg), and Pro's: the same paper and lens on a blue-violet turning to a soft rose
637
+ // gold, a light from its top left (user, 2026-11-21: 丙, elegant beside the plain one).
638
+ let appIconCount = 0;
639
+ function appIcon(size, pro) {
640
+ const id = "ai" + (++appIconCount);
641
+ const fill = pro ? '<linearGradient id="' + id + 'g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#6F78F2"/>'
642
+ + '<stop offset=".5" stop-color="#A67BD9"/><stop offset="1" stop-color="#E3AFC0"/></linearGradient>'
643
+ + '<radialGradient id="' + id + 's" cx=".28" cy=".2" r=".75"><stop offset="0" stop-color="#fff" stop-opacity=".3"/>'
644
+ + '<stop offset=".5" stop-color="#fff" stop-opacity=".05"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient>'
645
+ : '<linearGradient id="' + id + 'g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#5B9BFF"/><stop offset="1" stop-color="#9A72FF"/></linearGradient>';
646
+ return '<svg class="app-icon' + (pro ? " pro" : "") + '" width="' + size + '" height="' + size + '" viewBox="0 0 512 512" aria-hidden="true"><defs>' + fill + "</defs>"
647
+ + '<rect x="32" y="32" width="448" height="448" rx="104" fill="url(#' + id + 'g)"/>'
648
+ + (pro ? '<rect x="32" y="32" width="448" height="448" rx="104" fill="url(#' + id + 's)"/>' : "")
649
+ + '<g transform="rotate(-8 220 240)"><rect x="112" y="100" width="206" height="270" rx="30" fill="#fff" opacity=".96"/>'
650
+ + '<rect x="148" y="148" width="116" height="18" rx="9" fill="#DCE3FF"/><rect x="148" y="192" width="134" height="18" rx="9" fill="#DCE3FF"/>'
651
+ + '<rect x="148" y="236" width="80" height="18" rx="9" fill="#DCE3FF"/></g><circle cx="306" cy="300" r="92" fill="#8C8BFF" opacity=".55"/>'
652
+ + '<circle cx="306" cy="300" r="92" fill="none" stroke="#fff" stroke-width="26"/>'
653
+ + '<line x1="374" y1="368" x2="424" y2="418" stroke="#fff" stroke-width="32" stroke-linecap="round"/>'
654
+ + '<path d="M306 248 Q306 300 358 300 Q306 300 306 352 Q306 300 254 300 Q306 300 306 248Z" fill="#fff"/>'
655
+ + '<path d="M352 236 Q352 252 368 252 Q352 252 352 268 Q352 252 336 252 Q352 252 352 236Z" fill="#fff" opacity=".9"/></svg>';
656
+ }
472
657
  const esc = (s) => String(s == null ? "" : s).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
473
658
  function ring(pct, size, stroke, label) {
474
659
  const r = (size - stroke) / 2, c = 2 * Math.PI * r, d = Math.max(0, Math.min(100, pct)) / 100 * c;
@@ -498,14 +683,15 @@ let settingsDraft = {};
498
683
  let notifyCheck = null; // the notification check under the switch: {state: testing, sent, off, unseen or failed}
499
684
  // Settings pages: "home" lists download, wait and keys. settingsOnly: this window was started
500
685
  // just to show them (`paper-search-school settings`), so it closes with them unless a download runs.
501
- const SETTINGS_PAGES = ["home", "download", "wait", "keys", "pro", "markdown", "login"];
686
+ const SETTINGS_PAGES = ["home", "about", "download", "wait", "keys", "pro", "markdown", "login"];
502
687
  // PaperSearch Pro's pages (config/edition.ts): Pro itself (installing it, its version and updates), and
503
688
  // each of its features (user, 2026-11-19: the Markdown, the school's sign-in, more to come).
504
689
  const PRO_PAGES = ["pro", "markdown", "login"];
505
- // Installed, Pro's features are on the home page (the user's choice, 2026-11-19: 铺开); not yet, on
506
- // Pro's own page, under 安装.
690
+ // Pro's features are on the home page, under its title, installed or not (user, 2026-11-19: 铺开; 2026-11-21: C).
507
691
  const proInstalled = () => !!(proStatus && proStatus.ok && proStatus.installed) && proInstall.state !== "running";
508
- const parentPage = (page) => page === "login_schools" ? "login" : ["markdown", "login"].includes(page) && !proInstalled() ? "pro" : "home";
692
+ const parentPage = (page) => page === "login_schools" ? "login" : page === "pro_activate" ? "about" : "home";
693
+ // Pro's page became 关于 PaperSearch (user, 2026-11-21: one version, Pro part of it); asked for by its old name too.
694
+ const pageNamed = (page) => page === "pro" ? "about" : page;
509
695
  // The Markdown page is one of PaperSearch Pro's features: the backend says whether this edition has it (edition.py).
510
696
  const proOn = () => !settings || settings.pro !== false;
511
697
  let settingsPage = "home", settingsNote = "", settingsOnly = false, lastStrip = "";
@@ -518,13 +704,93 @@ let proStatus = null, proInstall = { state: "idle" }, proInstallTimer = 0;
518
704
  let schoolLogin = null, loginError = "", loginValues = {}, loginShown = false;
519
705
  // The school whose account is open on the page (its entityID), and 添加学校: what was typed, what was found.
520
706
  let loginOpen = "", schoolQuery = "", schoolFound = null, schoolFinding = false, confirmForget = "", loginAdding = false;
521
- // 支持哪些学校: the list Pro gives, what is typed to narrow it, the province open.
522
- let supportList = null, supportFilter = "", supportOpen = "";
707
+ // 测试登录 (school_test.py): the test as the window runs it ({state: idle, running (key, step, phase), done (key, ok,
708
+ // title, detail, seconds)}); the article it opens for the school open ({doi}: "" while none is set), and its box: open
709
+ // or not, what is typed, why it was not taken, a lookup going on; the account as saved (the test uses that: changed
710
+ // fields are saved first).
711
+ // One version and one update (user, 2026-11-21; updates.py): the version this window runs and the one installed now
712
+ // (an update elsewhere: they differ, 重新打开), the check's answer, the update as it goes.
713
+ let versionInfo = { running: "", installed: "" }, versionCheck = { state: "idle" }, updateRun = { state: "idle" };
714
+ let versionTimer = 0, updateTimer = 0;
715
+ const newerVersion = () => versionCheck.state === "done" && !!(versionCheck.update || versionCheck.pro_update) && updateRun.state !== "done";
716
+ async function refreshVersions() {
717
+ try { versionInfo = (await api().versions()) || versionInfo; } catch (error) { /* an older backend: none */ }
718
+ }
719
+ async function checkVersions(again = false) {
720
+ await refreshVersions();
721
+ try { versionCheck = (await api().check_versions(again)) || { state: "idle" }; } catch (error) { return; }
722
+ watchVersions();
723
+ if (panel === "settings") render(true);
724
+ }
725
+ function watchVersions() {
726
+ clearInterval(versionTimer);
727
+ if (versionCheck.state !== "running") return;
728
+ versionTimer = setInterval(async () => {
729
+ let next;
730
+ try { next = await api().versions_state(); } catch (error) { return; }
731
+ versionCheck = next || { state: "idle" };
732
+ if (versionCheck.state === "running") return;
733
+ clearInterval(versionTimer);
734
+ render(true); // the card's dot, the foot's line, the about page
735
+ }, 700);
736
+ }
737
+ // 更新 as it goes: each step, then (PaperSearch itself updated) the window opening again with the new one.
738
+ function watchUpdate() {
739
+ clearInterval(updateTimer);
740
+ if (updateRun.state !== "running") return;
741
+ updateTimer = setInterval(async () => {
742
+ let next;
743
+ try { next = await api().update_state(); } catch (error) { return; }
744
+ const before = JSON.stringify(updateRun);
745
+ updateRun = next || { state: "idle" };
746
+ if (updateRun.state !== "running") {
747
+ clearInterval(updateTimer);
748
+ if (updateRun.state === "done" && updateRun.reopen) {
749
+ render(true);
750
+ try { await api().reopen_window("about"); } catch (error) { /* the window stays; 重新打开 says the rest */ }
751
+ return;
752
+ }
753
+ if (updateRun.state === "done") {
754
+ // Pro alone updated: read again, the page as it is now.
755
+ try { proStatus = await api().pro_status(); } catch (error) { /* as it was */ }
756
+ updateRun = { state: "idle" };
757
+ await checkVersions(true);
758
+ }
759
+ }
760
+ if (JSON.stringify(updateRun) !== before && panel === "settings") render(true);
761
+ }, 600);
762
+ }
763
+ // Installed elsewhere since this window started (a terminal, an AI tool): said on every settings page, 重新打开.
764
+ const reopenLine = () => versionInfo.installed && versionInfo.running && versionInfo.installed !== versionInfo.running
765
+ && updateRun.state === "idle" ? '<button type="button" class="reopen-line" data-act="reopen_window">' + icon("refresh")
766
+ + "<span>" + esc("已更新到 " + versionInfo.installed) + '</span><span class="k">' + esc("重新打开") + "</span></button>" : "";
767
+ let schoolTest = { state: "idle" }, testArticle = null, testArticleFor = null, testTimer = 0, loginSavedValues = {};
768
+ let testEditing = false, testArticleText = "", testArticleError = "", testArticleSaving = false;
769
+ // 支持哪些学校: the list Pro gives, what is typed to narrow it, the regions open, the country whose page is open, its
770
+ // parts open, and where the regions' page was scrolled to, for going back to it.
771
+ let supportList = null, supportFilter = "", supportOpen = "", supportRegions = new Set(), supportParts = new Set(), supportBack = 0;
772
+ // Where the page was scrolled, put back once it is drawn again (user, 2026-11-21: a press on the card's background
773
+ // sent 支持的学校's long list to its top); where a page gone to or back to is to be (pageScroll, its top: 0).
774
+ let keepScroll = null, pageScroll = null;
775
+ const surfaceTop = () => root.querySelector(":scope > .surface")?.scrollTop || 0;
776
+ // What scrolls a row: the nearest box that scrolls its content, else the page.
777
+ function scrollerOf(el) {
778
+ for (let node = el.parentElement; node; node = node.parentElement) {
779
+ if (/(auto|scroll)/.test(getComputedStyle(node).overflowY) && node.scrollHeight > node.clientHeight) return node;
780
+ }
781
+ return document.scrollingElement || document.documentElement;
782
+ }
523
783
  // What the last 保存, 清除 or switch did, said under the fields (user, 2026-11-19: 保存 said nothing).
524
784
  let loginDone = "";
525
785
  // The Save button saying "已保存" a moment once pressed (user, 2026-11-20: not a line below).
526
786
  let loginSaved = false, loginSavedTimer = 0;
527
- let proCheck = { state: "idle" }, proCheckTimer = 0, proSitesOpen = false;
787
+ let proSitesOpen = false, proMeritsOpen = false;
788
+ // The activation code typed on Pro's page, and why it was not sent (none typed).
789
+ let proCode = "", proCodeError = "";
790
+ // The languages the window speaks, each in its own name, in one menu at the home page's foot (user, 2026-11-21:
791
+ // more to come, 日本語, 한국어, Français among them); whether that menu is open.
792
+ const LANGUAGES = [["zh", "简体中文"], ["zh-Hant", "繁體中文"], ["en", "English"], ["ja", "日本語"], ["ko", "한국어"], ["fr", "Français"]];
793
+ let languageOpen = false;
528
794
  let lastHtml = "", hoverTimer = 0, leaveTimer = 0, pollTimer = 0, kinds = [];
529
795
  const api = () => window.pywebview.api;
530
796
 
@@ -570,7 +836,7 @@ function header(title, sub, closable) {
570
836
  + (V.mode === "running" || V.mode === "attention" ? ring(V.pct, 40, 4, V.pct + "%") : "")
571
837
  + '<div class="text"><div class="title">' + esc(title) + '</div>' + (sub ? '<div class="sub">' + esc(sub) + "</div>" : "") + "</div></div>"
572
838
  + '<div class="tools">' + pinButton()
573
- + '<button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear") + "</button>"
839
+ + '<button class="iconbtn' + (newerVersion() ? " has-dot" : "") + '" data-act="settings" aria-label="设置">' + icon("gear") + "</button>"
574
840
  + '<button class="iconbtn" data-act="' + (closable ? "close" : "minimize") + '" aria-label="' + (closable ? "关闭" : "最小化")
575
841
  + '" title="' + (closable ? "关闭" : "最小化到程序坞") + '">' + icon(closable ? "close" : "minimize") + "</button></div></div>";
576
842
  }
@@ -586,13 +852,17 @@ function paperBlock() {
586
852
  html += note ? "<" + tag + ' class="notice">' + esc(note) + "</" + tag + ">"
587
853
  : (v.where ? "<" + tag + ' class="where">' + esc(v.where) + (v.title && v.current ? " · " + esc(v.current) : "") + "</" + tag + ">" : "");
588
854
  if (v.browser) html += "</button>";
855
+ // The step or the lane's line in one row of its own height, there when neither is (see .paper-status); a line
856
+ // longer than the row says the rest on hover.
857
+ html += '<div class="paper-status">';
589
858
  if (v.step) {
590
859
  html += '<div class="steps"><div class="bars">' + v.steps.map((_, i) =>
591
860
  "<span" + (i < v.step.index ? ' class="done"' : i === v.step.index ? ' class="now"' : "") + "></span>").join("")
592
861
  + '</div><span class="label">' + esc(v.step.label) + "</span></div>";
593
862
  } else if (v.line) {
594
- html += '<div class="line">' + esc(v.line) + "</div>";
863
+ html += '<div class="line" title="' + esc(v.line) + '">' + esc(v.line) + "</div>";
595
864
  }
865
+ html += "</div>";
596
866
  // What each lane got (开放下载, 机构下载), on one line.
597
867
  return html + "</div>";
598
868
  }
@@ -647,11 +917,11 @@ function heldBlock() {
647
917
  // The button says 已确认; the line, when they go on.
648
918
  const copy = V.held_wait ? "正在继续下载 " + heldCount() + " 篇" : "本篇完成后继续下载 " + heldCount() + " 篇";
649
919
  return '<div class="held"><div class="head"><span class="copy">' + esc(copy) + '</span><span class="btn done">' + icon("check") + "已确认</span></div>"
650
- + '<div class="names">' + esc(held.map((h) => h.name).join(lang === "en" ? ", " : "、")) + "</div></div>";
920
+ + '<div class="names">' + esc(held.map((h) => h.name).join(commaLang() ? ", " : "、")) + "</div></div>";
651
921
  }
652
922
  return '<div class="held"><div class="head"><span class="copy">' + esc("学校登录中途失败,已暂停 " + heldCount() + " 篇")
653
923
  + '</span><button class="btn" data-act="resume_held">登录并继续</button></div>'
654
- + '<div class="names">' + esc(held.map((h) => h.name).join(lang === "en" ? ", " : "、")) + "</div></div>";
924
+ + '<div class="names">' + esc(held.map((h) => h.name).join(commaLang() ? ", " : "、")) + "</div></div>";
655
925
  }
656
926
 
657
927
  // Pages from sites not yet supported this batch: the site (or how many), how their Markdown
@@ -727,7 +997,7 @@ function attentionCard() {
727
997
  + '<button type="button" class="prompt attention-target" data-act="show_browser" aria-label="打开下载浏览器">' + icon(a.login ? "lock" : "alert")
728
998
  + '<div class="attention-copy"><div class="t">' + esc(title) + '</div><div class="s">点击打开浏览器,查看并继续</div></div><span class="attention-arrow" aria-hidden="true">›</span></button>';
729
999
  if (panel === "confirm") return html + actionsBlock() + "</div>";
730
- html += '<div class="actions"><button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear")
1000
+ html += '<div class="actions"><button class="iconbtn' + (newerVersion() ? " has-dot" : "") + '" data-act="settings" aria-label="设置">' + icon("gear")
731
1001
  + '</button><span class="grow"></span>';
732
1002
  if (V.actions) {
733
1003
  html += '<button class="btn" data-act="skip_item">跳过本篇</button>'
@@ -891,13 +1161,16 @@ function taskStrip() {
891
1161
  return "";
892
1162
  }
893
1163
 
894
- function settingsHead(title) {
1164
+ function settingsHead(title, sub = "设置") {
1165
+ return settingsHeadOnly(title, sub) + reopenLine();
1166
+ }
1167
+ function settingsHeadOnly(title, sub = "设置") {
895
1168
  // A window opened just for the settings closes from any page; the home page has nothing to go back to.
896
1169
  const closable = settingsOnly && !busy(), home = settingsPage === "home";
897
1170
  lastStrip = taskStrip();
898
1171
  return '<div class="head">' + (home && closable ? "" : '<button class="iconbtn" data-act="back" aria-label="返回">' + icon("left") + "</button>")
899
1172
  + '<div class="drag capsule-drag-region"><div class="text"><div class="title">' + esc(title) + "</div>"
900
- + (home ? "" : '<div class="sub">设置</div>') + "</div></div>"
1173
+ + (home || !sub ? "" : '<div class="sub">' + esc(sub) + "</div>") + "</div></div>"
901
1174
  + (closable ? '<button class="iconbtn" data-act="close_settings" aria-label="关闭">' + icon("close") + "</button>" : "")
902
1175
  + '</div><div id="task-strip">' + lastStrip + "</div>";
903
1176
  }
@@ -905,25 +1178,43 @@ function settingsHead(title) {
905
1178
  const fieldsOn = (page) => settings.fields.filter((f) => (f.page || "wait") === page);
906
1179
  const field = (name) => settings.fields.find((f) => f.name === name);
907
1180
 
1181
+ // The user's own folder as ~ on the home page's line (user, 2026-11-21: /Users/<name>/Downloads and the hourly limit
1182
+ // did not fit one line in English); the download page shows the folder whole.
1183
+ const shortPath = (path) => String(path || "").replace(/^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:\\Users\\[^\\]+)(?=[\/\\]|$)/, "~");
908
1184
  function settingsHome() {
909
1185
  const hourly = field("hourly"), login = field("login");
910
1186
  const rows = [
911
- ["download", "folder", "下载", [settings.download_dir, hourly ? "每家每小时 " + hourly.value + " 篇" : ""]],
1187
+ ["download", "folder", "下载", [shortPath(settings.download_dir), hourly ? "每家每小时 " + hourly.value + " 篇" : ""]],
912
1188
  ["wait", "clock", "等待和提醒", [login ? "登录页 " + login.value + " 秒" : "", "系统通知" + (notifyOn ? "开" : "关")]],
913
1189
  ["keys", "key", "API key", [apiKeys && apiKeys.ok ? "已填 " + apiKeys.filled + "/" + apiKeys.total : ""]],
914
1190
  ];
915
- return settingsHead("设置") + rows.map(navRow).join("") + (proOn() ? proHomeRows() : "")
916
- // The language row reads the same in both languages.
917
- + '<div class="row"><span>语言</span><span class="seg">' + ["zh", "en"].map((code) => '<button type="button" data-act="language" data-lang="'
918
- + code + '" aria-pressed="' + (lang === code) + '"' + (lang === code ? ' class="on"' : "") + ">" + (code === "zh" ? "中文" : "English")
919
- + "</button>").join("") + "</span></div>"
1191
+ const installed = proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
1192
+ // Pro not there: one row of its own, last, to 关于 PaperSearch where it is introduced (user, 2026-11-21: 乙, its
1193
+ // line saying 需要激活); there: its features' rows.
1194
+ const pro = !proOn() ? "" : installed ? proFeatures().map(navRow).join("")
1195
+ : navRow(["about", "pro-app", "PaperSearch", [proActivated() ? "已激活 · 未安装" : proActivation().state === "expired" ? "激活已过期" : "需要激活"], "Pro"]);
1196
+ return settingsHead("设置") + rows.map(navRow).join("") + pro
1197
+ + '<div class="row home-foot">' + versionLink() + languageMenu() + "</div>"
920
1198
  + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
921
1199
  }
922
1200
 
1201
+ // The language, at the right of the home page's foot: its own name, and open, the others each in theirs.
1202
+ function languageMenu() {
1203
+ const name = (LANGUAGES.find(([code]) => code === lang) || LANGUAGES[0])[1];
1204
+ return '<span class="lang-wrap"><button type="button" class="lang-btn" data-act="language_menu" aria-haspopup="menu" aria-expanded="'
1205
+ + languageOpen + '" aria-label="' + esc("语言 · " + name) + '">' + icon("globe") + "<span>" + name + "</span>"
1206
+ + icon(languageOpen ? "up" : "down") + "</button>"
1207
+ + (languageOpen ? '<div class="lang-menu" role="menu">' + LANGUAGES.map(([code, own]) => '<button type="button" role="menuitemradio"'
1208
+ + ' data-act="language" data-lang="' + code + '" aria-checked="' + (code === lang) + '"><span>' + own + "</span>"
1209
+ + (code === lang ? icon("tick") : "") + "</button>").join("")
1210
+ + '<div class="lang-more">' + esc("更多语言陆续加入") + "</div></div>" : "") + "</span>";
1211
+ }
1212
+
923
1213
  // A row that opens a page: its icon, its name, what it holds now.
924
- function navRow([page, glyph, title, sub]) {
925
- return '<button type="button" class="nav-row" data-act="settings_page" data-page="' + page + '">' + icon(glyph)
926
- + '<span class="nav-text"><span class="nav-title">' + esc(title) + '</span><span class="nav-sub">'
1214
+ function navRow([page, glyph, title, sub, badge]) {
1215
+ return '<button type="button" class="nav-row" data-act="settings_page" data-page="' + page + '">' + (glyph === "pro-app" ? appIcon(16, true) : icon(glyph))
1216
+ + '<span class="nav-text"><span class="nav-title">' + esc(title)
1217
+ + (badge ? '<span class="pro-pill feature">' + esc(badge) + "</span>" : "") + '</span><span class="nav-sub">'
927
1218
  + esc(sub.filter(Boolean).join(" · ")) + "</span></span>" + icon("right") + "</button>";
928
1219
  }
929
1220
 
@@ -1006,21 +1297,13 @@ function settingsKeys() {
1006
1297
  + "</div>";
1007
1298
  }
1008
1299
 
1009
- // The Markdown page (user, 2026-11-18): PaperSearch Pro, a beta (测试版); what it does; 安装 when it
1010
- // is not here, with its progress, or 重试 after a failed one; and where to report a conversion.
1011
- // Nothing of subscriptions or keys while it is free.
1012
- function proStateLine() {
1013
- if (proInstall.state === "running") return ["", "正在安装…"];
1014
- if (proInstall.state === "failed") return ["bad", "安装没有完成:" + (proInstall.message || "安装出错")];
1015
- if (!proStatus || !proStatus.ok) return ["bad", (proStatus && proStatus.error) || "读取失败"];
1016
- if (!proStatus.installed) return ["", "未安装"];
1017
- const installed = "已安装" + (proStatus.version ? " · " + proStatus.version : "");
1018
- // 检查更新 (user, 2026-11-19): its answer after the version.
1019
- if (proCheck.state === "running") return ["ok", installed + " · 正在检查更新…"];
1020
- if (proCheck.state === "failed") return ["bad", installed + " · " + (proCheck.message || "检查更新出错")];
1021
- if (proCheck.state === "done") return ["ok", installed + " · " + (proCheck.update ? "有新版本 " + proCheck.latest : "已是最新")];
1022
- return ["ok", installed];
1023
- }
1300
+
1301
+ // PaperSearch Pro's state (user, 2026-11-18, -21): not installed, whether this computer is activated
1302
+ // (src/management/pro/activate.ts: PaperSearch's activation server, its address still to come); installing,
1303
+ // activating first when a code was typed.
1304
+ const proActivation = () => (proStatus && proStatus.activation) || { state: "none", tail: "", until: "" };
1305
+ const proActivated = () => proActivation().state === "active";
1306
+ const proActivating = () => proInstall.state !== "idle" && proInstall.step === "activate";
1024
1307
 
1025
1308
  function proProgress() {
1026
1309
  const done = proInstall.done || 0, total = proInstall.total || 0, mb = (bytes) => (bytes / 1048576).toFixed(1);
@@ -1028,24 +1311,67 @@ function proProgress() {
1028
1311
  note: total ? "正在下载 " + mb(done) + " / " + mb(total) + " MB" : "正在下载…" };
1029
1312
  }
1030
1313
 
1314
+ // Under Pro's state: the download's progress; installed, 更新到 a newer one; not installed,
1315
+ // 激活 Pro (the activation's own page), or 安装 once activated. No notes beside them (user, 2026-11-21).
1031
1316
  function proAction() {
1032
- const install = (label, hint) => '<button type="button" class="btn primary" data-act="install_pro">' + esc(label) + "</button>"
1033
- + '<div class="pro-hint">' + esc(hint) + "</div>";
1317
+ const button = (label) => '<button type="button" class="btn primary" data-act="install_pro">' + esc(label) + "</button>";
1034
1318
  if (proInstall.state === "running") {
1319
+ if (proActivating()) return "";
1035
1320
  const progress = proProgress();
1036
1321
  return '<div class="pro-bar"><span style="width:' + progress.width.toFixed(1) + '%"></span></div>'
1037
1322
  + '<div class="pro-hint" id="pro-progress">' + esc(progress.note) + "</div>";
1038
1323
  }
1039
- if (proInstall.state === "failed") return install("重试", "已下载的部分不会留下");
1040
- if (proStatus && proStatus.ok && proStatus.installed && proCheck.state === "done" && proCheck.update) {
1041
- return install("更新到 " + proCheck.latest, "核对完整后才替换原有的,转换记录保留");
1324
+ if (!proStatus || !proStatus.ok) return "";
1325
+ if (proInstall.state === "failed" && (proStatus.installed || proActivated()) && !proActivating()) return button("重试");
1326
+ if (proStatus.installed) {
1327
+ if (proActivation().state === "expired") return proCodeField("重新激活");
1328
+ // Its updates come with PaperSearch's, on the same page (user, 2026-11-21: one version, one button).
1329
+ return "";
1042
1330
  }
1043
- // About the size of Pro's bundle (pro/build.mjs --release), said before the download tells it.
1044
- return proStatus && proStatus.ok && !proStatus.installed ? install("安装", "约 4 MB · PDF 和补充材料不需要它") : "";
1331
+ return proActivated() ? button("安装")
1332
+ : '<button type="button" class="btn primary" data-act="settings_page" data-page="pro_activate">' + esc("激活 Pro") + "</button>";
1333
+ }
1334
+
1335
+ // The activation code, typed and kept through a redraw; why it was not taken, under it. While the code is sent,
1336
+ // its button says so.
1337
+ function proCodeField(label, sending = false) {
1338
+ const error = proCodeError || (proInstall.state === "failed" && proActivating() ? proInstall.message || "激活出错" : "");
1339
+ return '<div class="pro-code-label">' + esc("激活码") + '</div><div class="pro-code"><input id="pro-code" type="text" autocomplete="off"'
1340
+ + ' spellcheck="false" value="' + esc(proCode) + '" placeholder="XXXX-XXXX-XXXX" aria-label="' + esc("激活码") + '">'
1341
+ + '<button type="button" class="btn primary" data-act="activate_pro"' + (sending ? " disabled" : "") + ">"
1342
+ + esc(sending ? "正在激活…" : label) + "</button></div>"
1343
+ + (error ? '<div class="err pro-code-err" role="alert">' + esc(error) + "</div>" : "");
1344
+ }
1345
+
1346
+ // The activation, a page of its own from Pro's (user, 2026-11-21): the code and 激活; taken, the install's
1347
+ // progress here; installed, the home page, where Pro's features are now. An install that failed after the
1348
+ // activation: why, and 重试.
1349
+ function settingsProActivate() {
1350
+ const installing = proInstall.state === "running" && !proActivating();
1351
+ const failed = proInstall.state === "failed" && !proActivating() && proActivated();
1352
+ const body = installing ? proAction()
1353
+ : failed ? proAction() + '<div class="err pro-code-err" role="alert">' + esc("安装没有完成:" + (proInstall.message || "安装出错")) + "</div>"
1354
+ : proCodeField("激活", proInstall.state === "running");
1355
+ return settingsHead("激活 Pro") + '<div class="pro-action">' + body + "</div>"
1356
+ + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
1045
1357
  }
1046
1358
 
1047
1359
  // What a Markdown keeps, beside the description.
1048
1360
  const PRO_KEEPS = [["photo", "图片"], ["table", "表格"], ["formula", "公式"], ["list", "参考文献"]];
1361
+ // What sets it apart (user, 2026-11-21): a row like the platforms', its three names under the title; opened, each
1362
+ // said in full.
1363
+ const PRO_MERITS = [
1364
+ ["file", "出版社原文", "取自出版社网页或 XML,不从 PDF 识别:章节、图注、表格(含合并单元格)和 LaTeX 公式按原文还原,避免识别错误。"],
1365
+ ["check", "完整才保存", "图片或表格有缺失就不生成,记为失败并说明原因,后续重试。"],
1366
+ ["link", "来源可追溯", "每篇保留出版社原始网页或 XML,以及来源清单:来源地址、DOI 核对结果和获取时间。"],
1367
+ ];
1368
+ function proMerits() {
1369
+ return '<button type="button" class="nav-row pro-row" data-act="pro_merits" aria-expanded="' + proMeritsOpen + '">' + icon("shield")
1370
+ + '<span class="nav-text"><span class="nav-title">' + esc("三项特点") + '</span><span class="nav-sub">'
1371
+ + esc("出版社原文 · 完整才保存 · 来源可追溯") + "</span></span>" + icon(proMeritsOpen ? "down" : "right") + "</button>"
1372
+ + (proMeritsOpen ? '<div class="pro-merits">' + PRO_MERITS.map(([glyph, title, said]) => '<div class="pro-merit">' + icon(glyph)
1373
+ + "<div><b>" + esc(title) + "</b><span>" + esc(said) + "</span></div></div>").join("") + "</div>" : "");
1374
+ }
1049
1375
 
1050
1376
  // The Markdown saved on this computer, how many complete, and the publishers' platforms with rules.
1051
1377
  function proStats() {
@@ -1088,57 +1414,129 @@ function siteGroups(sites) {
1088
1414
  return groups.filter(([, names]) => names.length);
1089
1415
  }
1090
1416
 
1091
- // Whether Pro is free now and until when (the user, 2026-11-19: the page ends with it).
1092
- function proAccessSaid() {
1093
- const access = (proStatus && proStatus.access) || {};
1094
- return access.mode === "key" ? "需要密钥" : access.until ? "测试期间免费,至 " + access.until : "测试期间免费,截止日期待定";
1095
- }
1096
-
1097
- function proAccess() {
1098
- const said = proAccessSaid();
1099
- return '<div class="nav-row pro-row static">' + icon("gift") + '<span class="nav-text"><span class="nav-title">' + esc("使用状态")
1100
- + '</span><span class="nav-sub">' + esc(said) + "</span></span></div>";
1101
- }
1102
-
1103
- // PaperSearch Pro's page (user, 2026-11-19): installing it, its version and whether it is free, then
1104
- // its features, each a page of its own; where to report a problem at the foot.
1417
+ // What Pro does now and what is coming (user, 2026-11-21: Zotero, a map of related papers as ResearchRabbit
1418
+ // draws one, and new papers pushed by subscription), on its page, installed or not.
1419
+ const PRO_NOW = [
1420
+ ["file", "Markdown 全文", "出版社原文转成 Markdown,图表、公式完整"],
1421
+ ["lock", "学校自动登录", "学校登录页自动填写账号,批量下载不用守着"],
1422
+ ];
1423
+ const PRO_COMING = [
1424
+ ["Zotero 整合", "文献库里缺 PDF 的条目自动补下,挂回原条目"],
1425
+ ["文献关系图", "从一篇论文出发,沿引用找相关文献,画成关系图"],
1426
+ // User, 2026-11-21: what each one wants, pushed to them.
1427
+ ["文献订阅", "按关注的主题、期刊或作者,定期推送新论文"],
1428
+ ];
1429
+ // 使用状态 on Pro's page once installed: activated, its code's last four characters and until when; before the
1430
+ // activation server (none kept), whether Pro is free and until when (Pro's own switch).
1431
+ function proUsage(heading = true) {
1432
+ const activation = proActivation(), access = (proStatus && proStatus.access) || {};
1433
+ const row = (label, value, tone) => '<div class="row pro-use"><span>' + esc(label) + '</span><span class="' + (tone || "dim") + '">'
1434
+ + esc(value) + "</span></div>";
1435
+ const rows = activation.state !== "none"
1436
+ ? row("激活状态", activation.state === "active" ? "已激活" : "已过期", activation.state === "active" ? "ok" : "bad")
1437
+ + row("激活码", "••••" + activation.tail) + row("有效期", activation.until ? "至 " + activation.until : "不限")
1438
+ : access.mode === "key" ? row("使用方式", "需要激活")
1439
+ : row("使用方式", "测试期间免费") + row("截止日期", access.until || "待定");
1440
+ return (heading ? '<div class="key-group">' + esc("使用状态") + "</div>" : "") + rows;
1441
+ }
1442
+
1443
+ // PaperSearch Pro's features (user, 2026-11-19), each a page of its own; on the home page under Pro's title once installed.
1105
1444
  function proFeatures() {
1106
- const installed = !!(proStatus && proStatus.ok && proStatus.installed);
1107
- const converted = installed ? (proStatus.converted || 0) : 0, sites = installed ? (proStatus.sites || []).length : 0;
1445
+ const converted = proStatus.converted || 0, sites = (proStatus.sites || []).length;
1108
1446
  return [
1109
- ["markdown", "file", "Markdown 全文", installed ? ["已转换 " + converted.toLocaleString("en-US") + " 篇", sites + " 个平台"]
1110
- : ["把论文全文转成 Markdown"]],
1447
+ ["markdown", "file", "Markdown 全文", ["已转换 " + converted.toLocaleString("en-US") + " 篇", sites + " 个平台"], "Pro"],
1111
1448
  ["login", "lock", "学校自动登录", !schoolLogin || !schoolLogin.ok ? [] : !schoolLogin.saved ? ["未填"]
1112
- : [schoolLogin.enabled ? "已打开" : "已关闭", schoolLogin.username]],
1449
+ : [schoolLogin.enabled ? "已打开" : "已关闭", schoolLogin.username], "Pro"],
1113
1450
  ];
1114
1451
  }
1115
1452
 
1116
- // The home page's part of Pro (user, 2026-11-19: 铺开). Installed: its features under its name, then
1117
- // its version and updates; not yet (or installing): one row to Pro's page.
1118
- function proHomeRows() {
1119
- if (!proInstalled()) {
1120
- return navRow(["pro", "shield", "PaperSearch Pro", proInstall.state === "running" ? ["正在安装…"]
1121
- : [proStatus && proStatus.ok ? "未安装" : ""]]);
1122
- }
1123
- return '<div class="key-group pro-group">' + esc("PaperSearch Pro · 测试版") + "</div>"
1124
- + proFeatures().map(navRow).join("")
1125
- + navRow(["pro", "shield", "版本与更新", [proStatus.version || "", proAccessSaid()]]);
1453
+ // PaperSearch's version at the left of the home page's foot, for everyone, to 关于 PaperSearch (user, 2026-11-21: one
1454
+ // version and one update, Pro with it); a newer one there, the whole line in red saying so (乙).
1455
+ function versionLink() {
1456
+ const update = newerVersion();
1457
+ const said = update ? (versionCheck.update ? "有新版本 " + versionCheck.latest + ",点此更新" : "有新版本,点此更新")
1458
+ : "PaperSearch" + (versionInfo.running ? " " + versionInfo.running : "");
1459
+ return '<button type="button" class="version-link' + (update ? " new" : "") + '" data-act="settings_page" data-page="about">'
1460
+ + (update ? icon("upcircle") : "") + '<span class="pl-text">' + esc(said) + "</span></button>";
1126
1461
  }
1127
1462
 
1128
- function settingsPro() {
1129
- const [tone, state] = proStateLine();
1130
- const installed = proInstalled();
1131
- return settingsHead(installed ? "版本与更新" : "PaperSearch Pro")
1132
- + '<div class="pro-head"><span class="pro-tile">' + icon("shield") + '</span><span class="nav-text">'
1133
- + '<span class="pro-name">PaperSearch Pro<span class="pro-pill">' + esc("测试版") + "</span></span>"
1134
- + '<span class="pro-state' + (tone ? " " + tone : "") + '" role="status">' + esc(state) + "</span></span>"
1135
- + (installed && proCheck.state !== "running" ? '<button type="button" class="btn link pro-check" data-act="check_pro">'
1136
- + esc("检查更新") + "</button>" : "") + "</div>"
1137
- + '<div class="pro-action">' + proAction() + "</div>"
1138
- // Not installed yet: what it brings, each to its page; installed, they are on the home page.
1139
- + (installed ? proAccess() : '<div class="key-group">' + esc("功能") + "</div>" + proFeatures().map(navRow).join(""))
1140
- + '<div class="pro-foot"><span>' + esc("用着有问题?") + "</span>"
1141
- + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
1463
+
1464
+ // A Pro feature's page before Pro is there (user, 2026-11-21: as one not paid for sees it): what it needs, and
1465
+ // the way to Pro's page.
1466
+ function proNeeded() {
1467
+ const activated = proActivated();
1468
+ return '<div class="pro-needed"><span>' + esc(activated ? "安装 PaperSearch Pro 后可用" : "激活 PaperSearch Pro 后可用") + "</span>"
1469
+ + '<button type="button" class="btn link" data-act="settings_page" data-page="about">' + esc(activated ? "去安装" : "去激活")
1470
+ + icon("right") + "</button></div>";
1471
+ }
1472
+
1473
+ // 关于 PaperSearch (user, 2026-11-21, as drawn): its icon, name and version, and its update, Pro's with it; then Pro.
1474
+ // Not bought: its features, what is coming (计划中 after each name), 激活 Pro at the foot. Bought: the icon Pro's, Pro
1475
+ // beside the name (the line shifted a little to the right), its state, what is coming, 提交 issue.
1476
+ const UPDATE_STEPS = { paper_search: "PaperSearch", school: "学校订阅下载扩展", skills: "Skill", pro: "Pro" };
1477
+ function versionLine() {
1478
+ const running = versionInfo.running || versionCheck.current || "";
1479
+ const at = (said) => (running ? running + " · " : "") + said;
1480
+ if (updateRun.state === "running" || (updateRun.state === "done" && updateRun.reopen)) {
1481
+ return ["", updateRun.state === "done" ? "正在重新打开…" : updateRun.target ? "正在更新到 " + updateRun.target + "…" : "正在更新…"];
1482
+ }
1483
+ if (updateRun.state === "failed") return ["bad", at(updateRun.message || "更新出错")];
1484
+ if (versionCheck.state === "running") return ["", at("正在检查更新…")];
1485
+ if (versionCheck.state === "failed") return ["bad", at(versionCheck.message || "检查更新出错")];
1486
+ if (newerVersion()) return ["new", at(versionCheck.update ? "有新版本 " + versionCheck.latest : "有新版本")];
1487
+ if (versionCheck.state === "done") return ["", at("已是最新版本")];
1488
+ return ["", running];
1489
+ }
1490
+ function aboutAction() {
1491
+ const steps = updateRun.steps || [];
1492
+ if (updateRun.state === "running" || (updateRun.state === "done" && updateRun.reopen)) {
1493
+ const done = updateRun.state === "done" ? steps.length : updateRun.step || 0;
1494
+ return '<div class="about-action"><div class="pro-bar"><span style="width:' + (steps.length ? (done / steps.length) * 100 : 0).toFixed(1)
1495
+ + '%"></span></div><ol class="test-steps update-steps">' + steps.map((step, i) => '<li class="' + (i < done ? "done" : i === done ? "now" : "")
1496
+ + '">' + (i < done ? icon("check") : '<span class="mark"></span>') + "<span>"
1497
+ + esc(step === "paper_search" && updateRun.target ? "PaperSearch " + updateRun.target : UPDATE_STEPS[step] || step) + "</span></li>").join("")
1498
+ + "</ol>" + (steps.includes("paper_search") ? '<div class="about-caption">' + esc("完成后窗口会自动重新打开") + "</div>" : "") + "</div>";
1499
+ }
1500
+ if (updateRun.state === "failed") {
1501
+ return '<div class="about-action"><button type="button" class="btn primary" data-act="update_all">' + esc("重试") + "</button></div>";
1502
+ }
1503
+ if (newerVersion()) {
1504
+ const label = versionCheck.update ? "更新到 " + versionCheck.latest : "更新";
1505
+ return '<div class="about-action">' + (busy()
1506
+ ? '<button type="button" class="btn primary" disabled>' + esc("下载结束后更新") + "</button>"
1507
+ : '<button type="button" class="btn primary" data-act="update_all">' + esc(label) + "</button>")
1508
+ + (versionCheck.update && versionCheck.notes ? '<button type="button" class="btn link" data-act="release_notes">' + esc("这次更新了什么") + "</button>" : "")
1509
+ + "</div>";
1510
+ }
1511
+ return versionCheck.state === "running" ? "" : '<div class="about-action"><button type="button" class="btn link" data-act="check_versions">'
1512
+ + esc("检查更新") + "</button></div>";
1513
+ }
1514
+ const aboutFeature = ([title, said], planned) => '<div class="about-feat"><b>' + esc(title) + "</b>"
1515
+ + (planned ? '<span class="pro-tag">' + esc("计划中") + "</span>" : "") + '<span class="pl-sub">' + esc(said) + "</span></div>";
1516
+ const aboutComing = () => '<div class="about-sub">' + esc("即将推出") + "</div>" + PRO_COMING.map((f) => aboutFeature(f, true)).join("");
1517
+ function settingsAbout() {
1518
+ const installed = proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
1519
+ const [tone, line] = versionLine();
1520
+ const hero = '<div class="about-hero">' + appIcon(56, installed) + '<div class="about-name' + (installed ? " with-pill" : "") + '">PaperSearch'
1521
+ + (installed ? '<span class="pro-pill">Pro</span>' : "") + '</div><div class="about-version' + (tone ? " " + tone : "") + '" role="status">'
1522
+ + esc(line) + "</div></div>" + aboutAction();
1523
+ let pro = "";
1524
+ if (proOn() && installed) {
1525
+ pro = '<div class="about-gap"></div>' + (proAction() ? '<div class="pro-action">' + proAction() + "</div>" : "") + proUsage(false) + aboutComing()
1526
+ + '<div class="pro-foot"><span>' + esc("用着有问题?") + "</span>"
1527
+ + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>";
1528
+ } else if (proOn()) {
1529
+ const access = (proStatus && proStatus.access) || {};
1530
+ pro = '<div class="about-sec">' + appIcon(20, true) + '<span>PaperSearch</span><span class="pro-pill">Pro</span></div>'
1531
+ + PRO_NOW.map(([, title, said]) => aboutFeature([title, said], false)).join("") + aboutComing()
1532
+ + '<div class="pro-action pro-activate">' + proAction() + "</div>"
1533
+ // An install that did not finish says why under its 重试 (the activation's own page says it too).
1534
+ + (proInstall.state === "failed" && !proActivating() && proActivated() ? '<div class="err pro-code-err" role="alert">'
1535
+ + esc("安装没有完成:" + (proInstall.message || "安装出错")) + "</div>" : "")
1536
+ + (proInstall.state !== "running" && access.mode !== "key" && !proActivated() ? '<div class="about-caption">' + esc("测试期间免费") + "</div>" : "");
1537
+ }
1538
+ // Its head says 设置 alone: the name is the page's own, under the icon (user, 2026-11-21).
1539
+ return settingsHead("设置", "") + hero + pro
1142
1540
  + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
1143
1541
  }
1144
1542
 
@@ -1148,9 +1546,10 @@ function settingsMarkdown() {
1148
1546
  return settingsHead("Markdown 全文")
1149
1547
  + '<div class="pro-desc">' + esc("把论文全文转成 Markdown,以下内容一并保留:") + "</div>"
1150
1548
  + '<div class="pro-chips">' + PRO_KEEPS.map(([glyph, text]) => '<span class="pro-chip">' + icon(glyph) + esc(text) + "</span>").join("") + "</div>"
1151
- + (installed ? proStats() + proSites() : '<div class="pro-desc">' + esc("安装 PaperSearch Pro 后可用") + "</div>")
1152
- + '<div class="pro-foot"><span>' + esc("转换有缺漏、出错,或想加出版社?") + "</span>"
1153
- + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
1549
+ + (installed ? proStats() + proMerits() + proSites()
1550
+ + '<div class="pro-foot"><span>' + esc("转换有缺漏、出错,或想加出版社?") + "</span>"
1551
+ + '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
1552
+ : proMerits() + proNeeded())
1154
1553
  + (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
1155
1554
  }
1156
1555
 
@@ -1168,20 +1567,95 @@ function tagHtml(status) {
1168
1567
  const [cls, text] = schoolTag(status);
1169
1568
  return '<span class="tag ' + cls + '">' + esc(text) + "</span>";
1170
1569
  }
1171
- const schoolName = (s) => (lang === "en" && s.name_en ? s.name_en : s.name) || s.key;
1570
+ // A school's name in the window's language (user, 2026-11-21): in English its English name; in another its name in
1571
+ // that language where Pro has one (Wikidata's), in Traditional Chinese else its Chinese one (tr() turns its
1572
+ // characters); else its own name as its federation lists it, not a translation.
1573
+ function schoolName(s) {
1574
+ const names = s.names || {};
1575
+ if (lang === "en") return s.name_en || s.name || s.key;
1576
+ return names[lang] || (lang === "zh-Hant" ? names.zh : "") || s.name || s.name_en || s.key;
1577
+ }
1172
1578
 
1173
1579
  async function loadLoginValues() {
1174
1580
  try { loginValues = (await api().school_login_saved(loginOpen)) || {}; } catch (error) { loginValues = {}; }
1581
+ loginSavedValues = { ...loginValues };
1582
+ // 测试登录's article for the school open, and a test going on when the page was left.
1583
+ if (testArticleFor !== loginOpen) {
1584
+ testArticleFor = loginOpen; testArticle = null; testEditing = false; testArticleError = ""; testArticleText = "";
1585
+ try {
1586
+ const answer = await api().school_test_article(loginOpen);
1587
+ if (answer && answer.ok) testArticle = answer;
1588
+ } catch (error) { testArticle = null; }
1589
+ }
1590
+ try { schoolTest = (await api().school_test_state()) || { state: "idle" }; } catch (error) { schoolTest = { state: "idle" }; }
1591
+ if (schoolTest.state === "running") watchSchoolTest();
1592
+ }
1593
+
1594
+ // While a test runs, how it goes is asked for each second; the page is drawn again as its step or line changes.
1595
+ function watchSchoolTest() {
1596
+ clearInterval(testTimer);
1597
+ testTimer = setInterval(async () => {
1598
+ let next;
1599
+ try { next = await api().school_test_state(); } catch (error) { return; }
1600
+ const before = JSON.stringify(schoolTest);
1601
+ schoolTest = next || { state: "idle" };
1602
+ if (schoolTest.state !== "running") {
1603
+ clearInterval(testTimer);
1604
+ // The school's account may have been turned off (a password the school refused).
1605
+ try { const state = await api().school_login_state(); if (state && state.ok) schoolLogin = state; } catch (error) { /* as it was */ }
1606
+ }
1607
+ if (JSON.stringify(schoolTest) !== before && panel === "settings" && settingsPage === "login") render(true);
1608
+ }, 1000);
1609
+ }
1610
+
1611
+ // 测试登录 going on (user, 2026-11-21, as drawn): its steps, the one it is at and what the download says there; 停止测试.
1612
+ const TEST_STEPS = ["打开文章页", "学校登录", "下载全文", "核对 PDF"];
1613
+ function loginTesting(t) {
1614
+ return '<div class="login-test" role="status"><ol class="test-steps">' + TEST_STEPS.map((label, i) =>
1615
+ '<li class="' + (i < t.step ? "done" : i === t.step ? "now" : "") + '">' + (i < t.step ? icon("check") : '<span class="mark"></span>')
1616
+ + "<span>" + esc(label) + "</span></li>").join("") + "</ol>"
1617
+ + '<div class="test-phase">' + esc(t.stopping ? "正在停止…" : t.phase || "") + "</div>"
1618
+ + '<div class="key-actions"><span class="grow"></span><button class="btn" data-act="school_test_stop"' + (t.stopping ? " disabled" : "")
1619
+ + ">" + esc("停止测试") + "</button></div></div>";
1620
+ }
1621
+ // Before and after: how the last test of this school went, and the article the next opens, set by the user (user,
1622
+ // 2026-11-21: its DOI and 修改, which opens a box for a DOI or the article's address; none set for them, a short line
1623
+ // saying what to do and 填写), the test's own button 测试 at its end (甲: beside its article, so that it says what it
1624
+ // tests). 文章 beside 账号 and 密码, two characters each; its line ends where their boxes end.
1625
+ function loginTest(s) {
1626
+ if (!testArticle) return "";
1627
+ const label = "<span>" + esc("文章") + "</span>";
1628
+ const t = schoolTest.state === "done" && schoolTest.key === s.key ? schoolTest : null;
1629
+ const result = t ? '<div class="test-result ' + (t.ok ? "ok" : "bad") + '" role="status">' + icon(t.ok ? "check" : "alert")
1630
+ + '<div><div class="t">' + esc(t.title) + "</div>" + (t.detail ? '<div class="d">' + esc(t.detail) + "</div>" : "")
1631
+ + (t.ok ? '<div class="d">' + esc("用时 " + t.seconds + " 秒 · 测试下的 PDF 已删掉") + "</div>" : "") + "</div></div>" : "";
1632
+ // Also for a school whose account is not saved yet: 测试 saves what is typed first.
1633
+ const test = '<button class="btn test-btn" data-act="school_test">' + esc("测试") + "</button>";
1634
+ if (testEditing) {
1635
+ return result + label + '<div class="test-article"><span class="test-edit">'
1636
+ + '<input id="test-article" type="text" autocomplete="off" spellcheck="false" value="' + esc(testArticleText)
1637
+ + '" placeholder="' + esc("DOI 或文章网址") + '" aria-label="' + esc("测试文章") + '">'
1638
+ + '<button type="button" class="link-btn" data-act="test_article_save"' + (testArticleSaving ? " disabled" : "") + ">"
1639
+ + esc(testArticleSaving ? "查找中…" : "确定") + "</button></span>" + test + "</div>"
1640
+ + (testArticleError ? '<div class="err test-err" role="status">' + esc(testArticleError) + "</div>" : "");
1641
+ }
1642
+ const doi = testArticle.doi;
1643
+ return result + label + '<div class="test-article"><span class="what' + (doi ? "" : " empty") + '"' + (doi ? ' title="' + esc(doi) + '"' : "")
1644
+ + ">" + esc(doi || "填入学校订阅文章 DOI 或网址") + "</span>"
1645
+ + '<button type="button" class="link-btn" data-act="test_article_edit">' + esc(doi ? "修改" : "填写") + "</button>" + test + "</div>";
1175
1646
  }
1176
1647
 
1177
- function loginSchool(s) {
1648
+ function loginSchool(s, index) {
1178
1649
  const shown = loginOpen === s.key;
1650
+ // Their order, where there is more than one (user, 2026-11-21: 没权限时换下一所学校 goes down it; 1 the default).
1651
+ const many = ((schoolLogin && schoolLogin.schools) || []).length > 1;
1179
1652
  const row = '<button type="button" class="login-row" data-act="login_open" data-key="' + esc(s.key) + '" aria-expanded="' + shown + '">'
1180
- + '<span class="ls-name">' + esc(schoolName(s)) + "</span>"
1653
+ + (many ? '<span class="ls-n">' + (index + 1) + "</span>" : "") + '<span class="ls-name">' + esc(schoolName(s)) + "</span>"
1181
1654
  + (s.current ? '<span class="tag default">' + esc("默认") + "</span>" : "") + tagHtml(s.status)
1182
1655
  + '<span class="ls-acct">' + esc(s.saved ? (s.enabled ? s.username : "已关闭") : "未填账号") + "</span>"
1183
1656
  + icon(shown ? "down" : "right") + "</button>";
1184
1657
  if (!shown) return '<div class="login-school">' + row + "</div>";
1658
+ if (schoolTest.state === "running" && schoolTest.key === s.key) return '<div class="login-school">' + row + loginTesting(schoolTest) + "</div>";
1185
1659
  return '<div class="login-school">' + row
1186
1660
  + (s.off === "rejected" ? '<div class="err" style="text-align:left;margin:0 0 8px">'
1187
1661
  + esc("学校没有接受保存的密码,自动登录已关闭;更新密码后保存,就会重新打开") + "</div>" : "")
@@ -1195,6 +1669,7 @@ function loginSchool(s) {
1195
1669
  + icon("eye") + "</button></span>"
1196
1670
  // A line for an error, or the next step once a school is added; "saved" said on the button itself (user, 2026-11-20).
1197
1671
  + '<div class="err' + (loginError ? "" : " ok") + '" id="login-error" role="status">' + esc(loginError || loginDone) + "</div>"
1672
+ + loginTest(s)
1198
1673
  + '<div class="key-actions">'
1199
1674
  + (s.saved ? '<button class="btn" data-act="login_switch">' + esc(s.enabled ? "关闭自动登录" : "打开自动登录") + "</button>" : "")
1200
1675
  + '<span class="grow"></span>'
@@ -1228,7 +1703,7 @@ function loginFound() {
1228
1703
  function settingsLogin() {
1229
1704
  const s = schoolLogin, head = settingsHead("学校自动登录");
1230
1705
  if (!s || !s.ok) return head + '<div class="err" style="text-align:left">' + esc((s && s.error) || "读取失败") + "</div>";
1231
- if (!s.pro) return head + '<div class="settings-note" style="color:var(--bad)">' + esc("需要 PaperSearch Pro") + "</div>";
1706
+ if (!s.pro) return head + '<div class="pro-desc">' + esc("学校登录页自动填写账号和密码,批量下载不用守着。") + "</div>" + proNeeded();
1232
1707
  // 添加学校 a row like the schools', opened to its search (user, 2026-11-20: a box alone said nothing).
1233
1708
  return head + '<div style="margin-top:8px">' + (s.schools || []).map(loginSchool).join("")
1234
1709
  + '<div class="login-school"><button type="button" class="login-row login-add-row" data-act="login_add" aria-expanded="' + loginAdding + '">'
@@ -1237,52 +1712,153 @@ function settingsLogin() {
1237
1712
  + esc(schoolQuery) + '" placeholder="' + esc("中文名、英文名或学校网址") + '" aria-label="' + esc("学校名称") + '">'
1238
1713
  + '<button class="btn" data-act="find_school">' + esc("查找") + "</button></div>" + loginFound() + "</div>" : "")
1239
1714
  + "</div></div>"
1715
+ // 没权限时换下一所学校 (user, 2026-11-21; school_switch.py): one row, its switch at its right, on by default; there
1716
+ // with more than one school only.
1717
+ + ((s.schools || []).length > 1 ? '<div class="row switch-row"><span>' + esc("没权限时换下一所学校") + "</span>"
1718
+ + '<button class="switch' + (s.switch !== false ? " on" : "") + '" data-act="school_switch" role="switch" aria-checked="'
1719
+ + (s.switch !== false) + '" aria-label="' + esc("没权限时换下一所学校") + '"></button></div>' : "")
1240
1720
  // How many schools and which, on a page of their own (user, 2026-11-20: a link, not a line of numbers).
1241
1721
  + '<div class="login-more"><button type="button" class="btn link" data-act="settings_page" data-page="login_schools">'
1242
1722
  + esc("支持哪些学校") + icon("right") + "</button></div>";
1243
1723
  }
1244
1724
 
1245
- // 支持哪些学校: the schools Pro knows, how many of each kind, in groups (the most schools first): a mainland school by
1246
- // its province, any other by its country or region (user, 2026-11-20); narrowed by what is typed; each school with
1247
- // what Pro does for it.
1248
- function supportGroup(s) {
1249
- return (s.country && s.country !== "中国" ? s.country : s.province) || "其他";
1725
+ // 支持哪些学校: the schools Pro knows, how many of each kind, in two pages (user, 2026-11-21): the world's regions, each
1726
+ // opening in place to its countries (several may be open), and a country's schools on a page of their own (nested in one
1727
+ // list, they would not fit the window; a page for the regions' countries too was a level too many). On a big country's
1728
+ // page its parts open in place the same way (user, 2026-11-21, 甲): China's provinces, then Hong Kong, Macao and Taiwan;
1729
+ // a US school's state, a UK one's nation; Germany's by kind (Pro names no German states yet); a smaller country's schools
1730
+ // listed whole. Asia first and China first in it. The page's head (back, title, search) stays on top while its list
1731
+ // scrolls; a long name wraps. What is typed narrows the page's own country, or all; a province's or state's name finds
1732
+ // its schools. Each school with what Pro does for it.
1733
+ const SUPPORT_REGIONS = ["亚洲", "欧洲", "北美洲", "南美洲", "非洲", "大洋洲", "其他"];
1734
+ const CHINA_PLACES = ["香港", "澳门", "台湾"];
1735
+ // Each country the school lists name, by its region; one not here is listed under 其他 (Pro's tests check the lists
1736
+ // against this table).
1737
+ const SUPPORT_COUNTRIES = {
1738
+ "亚洲": "以色列 伊朗 卡塔尔 印度 印度尼西亚 哈萨克斯坦 土耳其 塞浦路斯 孟加拉国 巴基斯坦 巴林 斯里兰卡 新加坡 日本 沙特阿拉伯 泰国 科威特 约旦 菲律宾 越南 阿塞拜疆 阿曼 阿联酋 韩国 马来西亚 黎巴嫩 老挝 文莱",
1739
+ "欧洲": "丹麦 乌克兰 保加利亚 克罗地亚 冰岛 匈牙利 北马其顿 卢森堡 塞尔维亚 奥地利 希腊 德国 意大利 拉脱维亚 挪威 捷克 摩尔多瓦 斯洛伐克 斯洛文尼亚 比利时 法国 波兰 爱尔兰 爱沙尼亚 瑞典 瑞士 白俄罗斯 立陶宛 罗马尼亚 芬兰 英国 荷兰 葡萄牙 西班牙 阿尔巴尼亚 马耳他 黑山 安道尔 马恩岛 法罗群岛",
1740
+ "北美洲": "加拿大 哥斯达黎加 墨西哥 多米尼加 安圭拉 巴巴多斯 巴拿马 洪都拉斯 牙买加 特立尼达和多巴哥 美国 危地马拉 圣基茨和尼维斯",
1741
+ "南美洲": "乌拉圭 厄瓜多尔 哥伦比亚 巴西 智利 秘鲁 阿根廷",
1742
+ "非洲": "乌干达 加纳 南非 博茨瓦纳 坦桑尼亚 埃及 多哥 安哥拉 尼日利亚 布基纳法索 摩洛哥 肯尼亚 苏丹 赞比亚 马拉维 马里 阿尔及利亚 埃塞俄比亚 卢旺达 莱索托 埃斯瓦蒂尼 利比里亚 塞舌尔",
1743
+ "大洋洲": "新西兰 澳大利亚 斐济"
1744
+ };
1745
+ const REGION_OF = Object.fromEntries(Object.entries(SUPPORT_COUNTRIES).flatMap(([region, names]) =>
1746
+ names.split(" ").map((name) => [name, region])));
1747
+ const inChina = (s) => s.country === "中国" || CHINA_PLACES.includes(s.country);
1748
+ function supportRegion(s) {
1749
+ return inChina(s) ? "亚洲" : REGION_OF[s.country] || "其他";
1250
1750
  }
1251
- function supportRows(list) {
1252
- // In English, a school's English name (user, 2026-11-20); its own federation's name otherwise.
1253
- return list.map((s) => '<div class="login-found"><span class="ls-name">' + esc(lang === "en" && s.name_en ? s.name_en : s.name)
1254
- + "</span>" + tagHtml(s.status) + "</div>").join("");
1751
+ function supportGroup(s) {
1752
+ return inChina(s) ? "中国" : s.country || "国家未注明";
1753
+ }
1754
+ // A country's part: a mainland school's province (Hong Kong, Macao and Taiwan their own), a US school's state or a UK
1755
+ // one's nation where Pro names them, else its kind for a country of more schools than BIG_COUNTRY (Germany's 382:
1756
+ // user, 2026-11-21, by kind until Pro names its states); "" for a country listed whole.
1757
+ const BIG_COUNTRY = 350;
1758
+ const KIND_ORDER = ["大学", "研究机构", "医院", "其他"];
1759
+ const UNSTATED = ["未注明省份", "未注明州", "未注明地区", "国家未注明"];
1760
+ function supportPartOf(country, list) {
1761
+ if (country === "中国") return (s) => s.country === "中国" ? s.province || "未注明省份" : s.country;
1762
+ if (list.some((s) => s.area)) return (s) => s.area || (country === "美国" ? "未注明州" : "未注明地区");
1763
+ if (list.length > BIG_COUNTRY && list.some((s) => s.kind)) return (s) => KIND_ORDER.includes(s.kind) ? s.kind : "其他";
1764
+ return null;
1765
+ }
1766
+ // China first; the most schools first; Hong Kong, Macao and Taiwan after the provinces; a kind in KIND_ORDER's order;
1767
+ // a place not given last.
1768
+ function supportOrder(entries) {
1769
+ const rank = (name) => name === "中国" ? -1 : CHINA_PLACES.includes(name) ? 1 : UNSTATED.includes(name) ? 2 : 0;
1770
+ const kinds = entries.every(([name]) => KIND_ORDER.includes(name));
1771
+ return entries.sort((a, b) => (rank(a[0]) - rank(b[0]))
1772
+ || (kinds ? KIND_ORDER.indexOf(a[0]) - KIND_ORDER.indexOf(b[0]) : b[1].length - a[1].length));
1773
+ }
1774
+ function groupBy(list, key) {
1775
+ const groups = new Map();
1776
+ for (const s of list) groups.set(key(s), [...(groups.get(key(s)) || []), s]);
1777
+ return supportOrder([...groups.entries()]);
1778
+ }
1779
+ function supportRows(list, where = null) {
1780
+ // Its name in the window's language (schoolName), wrapped when long; found by a search, where it is beside it (its
1781
+ // country, or its part of the country open).
1782
+ return list.map((s) => '<div class="login-found"><span class="ls-name">' + esc(schoolName(s))
1783
+ + (where && where(s) ? '<span class="ls-fed"> · ' + esc(where(s)) + "</span>" : "") + "</span>" + tagHtml(s.status) + "</div>").join("");
1784
+ }
1785
+ function supportRow(act, key, count, open) {
1786
+ return '<button type="button" class="row" data-act="' + act + '" data-key="' + esc(key) + '"'
1787
+ + (open === undefined ? "" : ' aria-expanded="' + open + '"') + '>'
1788
+ + '<span class="reason">' + esc(key) + '</span><span class="n">' + count + "</span>" + icon(open ? "down" : "right") + "</button>";
1789
+ }
1790
+ // A school in two federations (its country's and OpenAthens: a university of Beijing's listed twice; 91 such in Chinese,
1791
+ // 2026-11-21) listed once, by its country and its name as the window shows it; what Pro does for it the better of the
1792
+ // two. Counted once in the numbers too.
1793
+ const STATUS_RANK = { verified: 0, surveyed: 0, trial: 1, check: 2 };
1794
+ let supportOnce = { list: null, lang: "", schools: [] };
1795
+ function supportSchools() {
1796
+ const listed = (supportList && supportList.schools) || [];
1797
+ if (supportOnce.list !== listed || supportOnce.lang !== lang) {
1798
+ const kept = new Map(), rank = (s) => STATUS_RANK[s.status] ?? 3;
1799
+ for (const s of listed) {
1800
+ const key = s.country + "\n" + schoolName(s), there = kept.get(key);
1801
+ if (!there || rank(s) < rank(there)) kept.set(key, s);
1802
+ }
1803
+ supportOnce = { list: listed, lang, schools: [...kept.values()] };
1804
+ }
1805
+ return supportOnce.schools;
1806
+ }
1807
+ // The schools of the page open: a country's, by their names as the window shows them, in its language's order (pinyin
1808
+ // in Chinese, strokes in Traditional Chinese; China's mainland first, then Hong Kong, Macao and Taiwan), or all.
1809
+ function supportHere() {
1810
+ const all = supportSchools();
1811
+ if (!supportOpen) return all;
1812
+ let order;
1813
+ try { order = new Intl.Collator(lang); } catch (error) { order = new Intl.Collator(); }
1814
+ const place = (s) => supportOpen === "中国" ? CHINA_PLACES.indexOf(s.country) : 0;
1815
+ return all.filter((s) => supportGroup(s) === supportOpen).map((s) => [place(s), schoolName(s), s])
1816
+ .sort((a, b) => a[0] - b[0] || order.compare(a[1], b[1])).map(([, , s]) => s);
1255
1817
  }
1256
1818
  function supportListHtml() {
1257
- const all = (supportList && supportList.schools) || [];
1258
- const wanted = supportFilter.trim().toLowerCase();
1819
+ const here = supportHere(), wanted = supportFilter.trim().toLowerCase();
1259
1820
  if (wanted) {
1260
- const said = (s) => [s.name, s.name_en, s.province, s.country, tr(s.province || ""), tr(s.country || "")].join(" ").toLowerCase();
1261
- const found = all.filter((s) => said(s).includes(wanted));
1262
- return found.length ? supportRows(found.slice(0, 80)) : '<div class="key-note">' + esc("没有符合的学校") + "</div>";
1821
+ // Found by any of its names, whatever the window's language, or its province's, state's or country's.
1822
+ const said = (s) => [s.name, s.name_en, ...Object.values(s.names || {}), s.province, s.area, s.country, tr(s.province || ""),
1823
+ tr(s.area || ""), tr(s.country || "")].join(" ").toLowerCase();
1824
+ const found = here.filter((s) => said(s).includes(wanted));
1825
+ const where = supportOpen ? supportPartOf(supportOpen, here) : (s) => s.country;
1826
+ return found.length ? supportRows(found.slice(0, 200), where) : '<div class="key-note">' + esc("没有符合的学校") + "</div>";
1827
+ }
1828
+ if (supportOpen) {
1829
+ // A big country's parts, each opening in place to its schools (several may be open), as the regions do.
1830
+ const part = supportPartOf(supportOpen, here);
1831
+ if (!part) return supportRows(here);
1832
+ return groupBy(here, part).map(([key, there]) => {
1833
+ const open = supportParts.has(key);
1834
+ return '<div class="support-region">' + supportRow("support_part", key, there.length, open)
1835
+ + (open ? '<div class="support-countries">' + supportRows(there) + "</div>" : "") + "</div>";
1836
+ }).join("");
1263
1837
  }
1264
- const provinces = new Map();
1265
- for (const s of all) provinces.set(supportGroup(s), [...(provinces.get(supportGroup(s)) || []), s]);
1266
- return [...provinces.entries()].sort((a, b) => b[1].length - a[1].length).map(([province, list]) => {
1267
- const shown = supportOpen === province;
1268
- return '<div class="grp"><button type="button" class="row" data-act="support_group" data-province="' + esc(province) + '" aria-expanded="' + shown + '">'
1269
- + '<span class="reason">' + esc(province) + '</span><span class="n">' + list.length + "</span>" + icon(shown ? "down" : "right") + "</button>"
1270
- + (shown ? '<div style="margin-top:4px">' + supportRows(list) + "</div>" : "") + "</div>";
1271
- }).join("");
1838
+ return SUPPORT_REGIONS.map((region) => [region, here.filter((s) => supportRegion(s) === region)]).filter(([, list]) => list.length)
1839
+ .map(([region, list]) => {
1840
+ const open = supportRegions.has(region);
1841
+ return '<div class="support-region">' + supportRow("support_region", region, list.length, open)
1842
+ + (open ? '<div class="support-countries">' + groupBy(list, supportGroup)
1843
+ .map(([key, there]) => supportRow("support_group", key, there.length)).join("") + "</div>" : "") + "</div>";
1844
+ }).join("");
1272
1845
  }
1273
1846
  function settingsLoginSchools() {
1274
- const head = settingsHead("支持的学校");
1847
+ const here = supportList && supportList.ok ? supportHere() : [];
1848
+ const head = settingsHead(supportOpen || "支持的学校", supportOpen ? here.length + " 所" : "设置");
1275
1849
  if (!supportList) return head + '<div class="key-note">' + esc("读取中…") + "</div>";
1276
1850
  if (!supportList.ok) return head + '<div class="err" style="text-align:left">' + esc(supportList.error || "读取失败") + "</div>";
1277
- const all = supportList.schools || [];
1851
+ const all = supportSchools();
1278
1852
  const filled = all.filter((s) => s.status === "surveyed" || s.status === "verified").length;
1279
1853
  const check = all.filter((s) => s.status === "check").length;
1280
- // What each number means, in a line (user, 2026-11-20: the page was not clear).
1281
- return head + '<div class="stats" style="margin-top:10px"><div><b>' + filled + "</b><span>" + esc("所学校自动填写账号密码") + "</span></div>"
1282
- + "<div><b>" + check + "</b><span>" + esc("所学校需自己登录") + "</span></div></div>"
1283
- + '<div class="key-note" style="margin-top:8px">' + esc("自动填写:打开学校登录页时,替你填好账号密码并提交。需自己登录:学校登录页有验证码、短信或扫码,要你自己完成。") + "</div>"
1284
- + '<div class="login-find" style="margin:6px 0 6px"><input id="support-filter" type="text" autocomplete="off" spellcheck="false" value="'
1285
- + esc(supportFilter) + '" placeholder="' + esc("筛选学校、省份或国家") + '" aria-label="' + esc("筛选学校、省份或国家") + '"></div>'
1854
+ // The numbers, each saying what it counts, on the first page only; the line explaining them was removed (user,
1855
+ // 2026-11-21).
1856
+ const stats = supportOpen ? "" : '<div class="stats" style="margin-top:10px"><div><b>' + filled + "</b><span>" + esc("所学校自动填写账号密码")
1857
+ + "</span></div><div><b>" + check + "</b><span>" + esc("所学校需自己登录") + "</span></div></div>";
1858
+ const hint = supportOpen ? "搜索学校" : "搜索学校或地区";
1859
+ return '<div class="support-top">' + head + stats
1860
+ + '<label class="support-search">' + icon("search") + '<input id="support-filter" type="search" autocomplete="off" spellcheck="false" value="'
1861
+ + esc(supportFilter) + '" placeholder="' + esc(hint) + '" aria-label="' + esc(hint) + '"></label></div>'
1286
1862
  + '<div id="support-list">' + supportListHtml() + "</div>";
1287
1863
  }
1288
1864
 
@@ -1295,35 +1871,28 @@ function watchProInstall() {
1295
1871
  let next;
1296
1872
  try { next = await api().pro_install_state(); } catch (error) { return; }
1297
1873
  proInstall = next || { state: "idle" };
1298
- if (proInstall.state === "running") return updateProProgress();
1874
+ if (proInstall.state === "running") return proActivating() ? undefined : updateProProgress();
1299
1875
  clearInterval(proInstallTimer);
1876
+ // Read again however it ended: an activation taken before a failed install is kept (重试, not the code again).
1877
+ const fresh = !(proStatus && proStatus.installed);
1878
+ try { proStatus = await api().pro_status(); } catch (error) { proStatus = null; }
1300
1879
  if (proInstall.state === "done") {
1301
- try { proStatus = await api().pro_status(); } catch (error) { proStatus = null; }
1302
1880
  proInstall = { state: "idle" };
1303
- proCheck = { state: "idle" }; // updated: what was found is installed now
1881
+ proCode = "";
1882
+ // Activated and installed (user, 2026-11-21): back on the home page, where its features are now.
1883
+ if (fresh && proStatus && proStatus.installed && panel === "settings" && ["about", "pro_activate"].includes(settingsPage)) {
1884
+ settingsPage = "home"; settingsNote = "PaperSearch Pro 已安装";
1885
+ }
1304
1886
  }
1305
1887
  // Not over another settings page, where something may be being typed.
1306
- if (panel === "settings" && ["home", "pro", "markdown"].includes(settingsPage)) render(true);
1888
+ if (panel === "settings" && ["home", "about", "pro_activate", "markdown"].includes(settingsPage)) render(true);
1307
1889
  }, 300);
1308
1890
  }
1309
1891
 
1310
- // 检查更新 runs a few seconds: asked for until it is done, then the page is drawn again.
1311
- function watchProCheck() {
1312
- clearInterval(proCheckTimer);
1313
- if (proCheck.state !== "running") return;
1314
- proCheckTimer = setInterval(async () => {
1315
- let next;
1316
- try { next = await api().pro_check_state(); } catch (error) { return; }
1317
- proCheck = next || { state: "idle" };
1318
- if (proCheck.state === "running") return;
1319
- clearInterval(proCheckTimer);
1320
- if (panel === "settings" && settingsPage === "pro") render(true);
1321
- }, 400);
1322
- }
1323
1892
 
1324
1893
  function updateProProgress() {
1325
1894
  const bar = root.querySelector(".pro-bar span"), line = root.querySelector("#pro-progress");
1326
- if (!bar || !line) return panel === "settings" && settingsPage === "pro" ? render(true) : undefined;
1895
+ if (!bar || !line) return panel === "settings" && ["about", "pro_activate"].includes(settingsPage) ? render(true) : undefined;
1327
1896
  const progress = proProgress();
1328
1897
  bar.style.width = progress.width.toFixed(1) + "%";
1329
1898
  line.textContent = tr(progress.note);
@@ -1367,7 +1936,9 @@ function holdSettingsHeight() {
1367
1936
 
1368
1937
  function settingsCard() {
1369
1938
  const page = { download: settingsDownload, wait: settingsWait, keys: settingsKeys,
1370
- ...(proOn() ? { pro: settingsPro, markdown: settingsMarkdown, login: settingsLogin, login_schools: settingsLoginSchools } : {}) }[settingsPage] || settingsHome;
1939
+ about: settingsAbout,
1940
+ ...(proOn() ? { pro_activate: settingsProActivate, markdown: settingsMarkdown, login: settingsLogin,
1941
+ login_schools: settingsLoginSchools } : {}) }[settingsPage] || settingsHome;
1371
1942
  return '<div class="card-body settings">' + page() + "</div>";
1372
1943
  }
1373
1944
 
@@ -1447,8 +2018,10 @@ async function loadSettings() {
1447
2018
 
1448
2019
  async function openSettings(request) {
1449
2020
  await loadSettings();
1450
- panel = "settings"; open = true; settingsNote = ""; confirmClear = ""; revealed = false;
1451
- settingsPage = SETTINGS_PAGES.includes(request.page) && (!PRO_PAGES.includes(request.page) || proOn()) ? request.page : "home";
2021
+ panel = "settings"; open = true; settingsNote = ""; confirmClear = ""; revealed = false; languageOpen = false;
2022
+ const asked = pageNamed(request.page);
2023
+ settingsPage = SETTINGS_PAGES.includes(asked) && (!PRO_PAGES.includes(asked) || proOn()) ? asked : "home";
2024
+ refreshVersions();
1452
2025
  editing = settingsPage === "keys" ? request.service || "" : "";
1453
2026
  editValues = editing ? await savedValues(editing) : {};
1454
2027
  loginShown = false;
@@ -1513,12 +2086,18 @@ function render(force) {
1513
2086
  // Keep the real button (and its pointer/focus target) through countdown ticks.
1514
2087
  if (unchanged && (!attention || !updateAttentionCountdown())) return;
1515
2088
  const previous = root.getBoundingClientRect();
2089
+ // Read before the height it scrolls in is taken off, which puts it back at its top.
2090
+ const scrolledTo = surfaceTop();
1516
2091
  root.style.width = ""; root.style.height = "";
1517
2092
  root.style.removeProperty("--content-max-height");
1518
2093
  if (!unchanged) {
1519
2094
  // A scrolled list keeps its place while its page is redrawn (a key opened or saved, a group opened).
1520
2095
  const place = panel + ":" + (panel === "settings" ? settingsPage : papersKind);
1521
2096
  const scrolled = place === lastPlace ? root.querySelector(".papers-scroll, .keys-scroll")?.scrollTop || 0 : 0;
2097
+ // The page itself scrolled (支持的学校's long list) keeps its place too (user, 2026-11-21: a press on the card's
2098
+ // background, which starts and ends a drag, drew it again at its top), put back once it scrolls (keepSupportPlace).
2099
+ if (pageScroll !== null) { keepScroll = pageScroll || null; pageScroll = null; }
2100
+ else if (place === lastPlace && scrolledTo > 0) keepScroll = scrolledTo;
1522
2101
  lastPlace = place;
1523
2102
  root.className = cls + " capsule-drag-region" + (cls !== lastCls ? " fade" : "");
1524
2103
  root.innerHTML = '<div class="surface">' + html + "</div>";
@@ -1532,6 +2111,17 @@ function render(force) {
1532
2111
  lastHtml = html;
1533
2112
  lastCls = cls;
1534
2113
  fit(previous);
2114
+ keepSupportPlace(!root.classList.contains("animating"));
2115
+ }
2116
+
2117
+ // The page stays where it was scrolled when drawn again (keepScroll). A page taller than the screen scrolls only once the
2118
+ // window has its size: the native resize (animateFit) sets the height it scrolls in, after the page was drawn anew at
2119
+ // its top, so it is put back then, and again when the resize ends; a page whose window does not change, at once.
2120
+ function keepSupportPlace(last) {
2121
+ if (keepScroll === null) return;
2122
+ const surface = root.querySelector(":scope > .surface");
2123
+ if (surface && surface.scrollHeight > surface.clientHeight) surface.scrollTop = keepScroll;
2124
+ if (last) keepScroll = null;
1535
2125
  }
1536
2126
 
1537
2127
  let fitGeneration = 0, layoutQueue = Promise.resolve();
@@ -1573,6 +2163,7 @@ async function animateFit(generation, expanded, from, to, pad) {
1573
2163
  const border = document.body.classList.contains("mac") ? 1 : 0;
1574
2164
  root.style.setProperty("--content-max-height", Math.max(0, to[1] - border) + "px");
1575
2165
  root.firstElementChild.style.width = Math.max(0, to[0] - border) + "px";
2166
+ keepSupportPlace(false);
1576
2167
  const duration = matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 240;
1577
2168
  const started = performance.now();
1578
2169
  // One outstanding native resize at a time; a newer layout cancels this animation.
@@ -1592,6 +2183,7 @@ async function animateFit(generation, expanded, from, to, pad) {
1592
2183
  if (generation === fitGeneration) {
1593
2184
  root.classList.remove("animating");
1594
2185
  settledGeneration = generation; settledSize = to; settledExpanded = expanded;
2186
+ keepSupportPlace(true);
1595
2187
  }
1596
2188
  }
1597
2189
  observeHover();
@@ -1624,8 +2216,16 @@ async function act(action, target) {
1624
2216
  switch (action) {
1625
2217
  // Back as a capsule when restored, unless pinned: a pinned card comes back open (user, 2026-11-20:
1626
2218
  // on Windows, minimized and restored, the pinned card had shrunk to the capsule).
1627
- case "minimize": if (!pinned) open = false; panel = ""; render(true); return api().minimize();
1628
- case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearInterval(proInstallTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
2219
+ case "minimize": {
2220
+ if (!pinned) open = false;
2221
+ panel = ""; minimizing = true;
2222
+ render(true);
2223
+ // Folded to the capsule before it goes into the Dock or the taskbar (user, 2026-11-21): minimized while it
2224
+ // still shrank, the window went at the card's size, and brought back showed the card a moment first.
2225
+ await layoutQueue;
2226
+ try { return await api().minimize(); } finally { setTimeout(() => { minimizing = false; }, 400); }
2227
+ }
2228
+ case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearInterval(proInstallTimer); clearInterval(testTimer); clearInterval(versionTimer); clearInterval(updateTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
1629
2229
  case "folder": return api().open_folder();
1630
2230
  case "expand": open = true; panel = ""; return render(true);
1631
2231
  case "pin":
@@ -1677,14 +2277,19 @@ async function act(action, target) {
1677
2277
  return say(said);
1678
2278
  }
1679
2279
  case "settings": return openSettings({ page: "home" });
2280
+ case "language_menu":
2281
+ languageOpen = !languageOpen;
2282
+ render(true);
2283
+ return root.querySelector(languageOpen ? ".lang-menu [aria-checked=true]" : ".lang-btn")?.focus();
1680
2284
  case "language": {
2285
+ languageOpen = false;
1681
2286
  const result = await api().set_language(target.dataset.lang);
1682
2287
  if (result.ok) lang = result.language;
1683
2288
  return render(true);
1684
2289
  }
1685
2290
  case "settings_page":
1686
- settingsPage = target.dataset.page; settingsErrors = {}; settingsDraft = {}; settingsNote = ""; editing = ""; editValues = {};
1687
- loginError = ""; loginDone = ""; confirmClear = ""; loginShown = false;
2291
+ settingsPage = pageNamed(target.dataset.page); settingsErrors = {}; settingsDraft = {}; settingsNote = ""; editing = ""; editValues = {};
2292
+ loginError = ""; loginDone = ""; confirmClear = ""; loginShown = false; languageOpen = false;
1688
2293
  if (settingsPage === "login") {
1689
2294
  // The default school open first; 添加学校 starts empty.
1690
2295
  loginOpen = ((schoolLogin && schoolLogin.schools) || []).find((s) => s.current)?.key || "";
@@ -1692,12 +2297,18 @@ async function act(action, target) {
1692
2297
  loginAdding = !loginOpen; // no school yet: straight to finding one
1693
2298
  }
1694
2299
  if (settingsPage === "login_schools") {
1695
- supportFilter = ""; supportOpen = ""; supportList = null; render(true);
2300
+ supportFilter = ""; supportOpen = ""; supportRegions = new Set(); supportParts = new Set(); supportBack = 0; supportList = null; render(true);
1696
2301
  try { supportList = await api().school_support_list(); } catch (error) { supportList = { ok: false, error: "读取失败" }; }
1697
2302
  }
1698
2303
  return render(true);
1699
2304
  case "back":
1700
2305
  if (panel !== "settings") { panel = ""; return render(true); }
2306
+ languageOpen = false;
2307
+ if (settingsPage === "login_schools" && supportOpen) {
2308
+ // From a country's page to the regions', where it was.
2309
+ supportOpen = ""; supportParts = new Set(); supportFilter = ""; pageScroll = supportBack || 0;
2310
+ return render(true);
2311
+ }
1701
2312
  if (settingsPage === "home") return leaveSettings();
1702
2313
  settingsPage = parentPage(settingsPage); editing = ""; editValues = {}; settingsErrors = {}; settingsDraft = {};
1703
2314
  loginError = ""; confirmClear = ""; return render(true);
@@ -1719,15 +2330,22 @@ async function act(action, target) {
1719
2330
  render(true);
1720
2331
  return watchProInstall();
1721
2332
  }
1722
- case "check_pro": {
1723
- try { proCheck = (await api().check_pro()) || { state: "idle" }; }
1724
- catch (error) { proCheck = { state: "failed", message: "检查更新出错" }; }
2333
+ case "activate_pro": {
2334
+ // 激活 (user, 2026-11-21): the code to the activation server, then the install.
2335
+ const code = proCode.trim();
2336
+ if (!code) { proCodeError = "请输入激活码"; render(true); return root.querySelector("#pro-code")?.focus(); }
2337
+ proCodeError = "";
2338
+ try { proInstall = (await api().install_pro(code)) || { state: "idle" }; }
2339
+ catch (error) { proInstall = { state: "failed", step: "activate", message: "激活出错" }; }
1725
2340
  render(true);
1726
- return watchProCheck();
2341
+ return watchProInstall();
1727
2342
  }
1728
2343
  case "pro_sites":
1729
2344
  proSitesOpen = !proSitesOpen;
1730
2345
  return render(true);
2346
+ case "pro_merits":
2347
+ proMeritsOpen = !proMeritsOpen;
2348
+ return render(true);
1731
2349
  case "pro_issue": {
1732
2350
  const result = await api().open_issue();
1733
2351
  if (!result.ok) { settingsNote = result.message; render(true); }
@@ -1770,8 +2388,83 @@ async function act(action, target) {
1770
2388
  }
1771
2389
  await loadLoginValues(); return render(true);
1772
2390
  }
2391
+ case "school_test": {
2392
+ // The test uses the account as saved: fields changed since are saved first.
2393
+ loginError = ""; loginDone = "";
2394
+ if ((loginValues.username || "") !== (loginSavedValues.username || "") || (loginValues.password || "") !== (loginSavedValues.password || "")) {
2395
+ const saved = await api().save_school_login(loginValues.username || "", loginValues.password || "", true, loginOpen);
2396
+ if (!saved.ok) { loginError = saved.error || "保存失败"; return render(true); }
2397
+ schoolLogin = saved; loginSavedValues = { ...loginValues };
2398
+ }
2399
+ if (testEditing && testArticleText.trim()) {
2400
+ // An article typed and not yet taken: taken first, or why not said.
2401
+ await act("test_article_save");
2402
+ if (testEditing) return;
2403
+ }
2404
+ if (!testArticle || !testArticle.doi) {
2405
+ // None filled in: its box opened for one.
2406
+ testEditing = true; testArticleError = "先填测试文章"; render(true);
2407
+ return root.querySelector("#test-article")?.focus();
2408
+ }
2409
+ const started = await api().start_school_test(loginOpen, testArticle ? testArticle.doi : "");
2410
+ if (started.error) { loginError = started.error; return render(true); }
2411
+ schoolTest = started; watchSchoolTest();
2412
+ return render(true);
2413
+ }
2414
+ case "school_switch": {
2415
+ let answer;
2416
+ try { answer = await api().set_school_switch(!(schoolLogin && schoolLogin.switch !== false)); } catch (error) { answer = null; }
2417
+ if (answer && answer.ok) schoolLogin = answer;
2418
+ else { loginError = (answer && answer.error) || "保存失败"; }
2419
+ return render(true);
2420
+ }
2421
+ case "check_versions":
2422
+ versionCheck = { state: "running" }; render(true);
2423
+ return checkVersions(true);
2424
+ case "update_all": {
2425
+ let started;
2426
+ try { started = await api().update_all(); } catch (error) { started = { state: "idle", error: "更新出错" }; }
2427
+ if (started && started.error) { settingsNote = started.error; return render(true); }
2428
+ updateRun = started || { state: "idle" }; settingsNote = "";
2429
+ watchUpdate();
2430
+ return render(true);
2431
+ }
2432
+ case "release_notes": {
2433
+ const answer = await api().open_release_notes();
2434
+ if (answer && !answer.ok) say(answer.message);
2435
+ return;
2436
+ }
2437
+ case "reopen_window": {
2438
+ const answer = await api().reopen_window(settingsPage === "about" ? "about" : "home");
2439
+ if (answer && !answer.ok) { settingsNote = answer.message; render(true); }
2440
+ return;
2441
+ }
2442
+ case "school_test_stop":
2443
+ schoolTest = await api().stop_school_test();
2444
+ return render(true);
2445
+ case "test_article_edit":
2446
+ testEditing = true; testArticleError = ""; testArticleText = (testArticle && testArticle.doi) || "";
2447
+ render(true);
2448
+ return root.querySelector("#test-article")?.focus();
2449
+ case "test_article_save": {
2450
+ // By its DOI or its page's address, the DOI looked up (school_test.doi_of); emptied, none.
2451
+ testArticleSaving = true; testArticleError = ""; render(true);
2452
+ let answer;
2453
+ try { answer = await api().set_school_test_article(loginOpen, testArticleText); } catch (error) { answer = { ok: false, error: "保存失败" }; }
2454
+ testArticleSaving = false;
2455
+ if (answer && answer.ok) { testArticle = answer; testEditing = false; } else testArticleError = (answer && answer.error) || "保存失败";
2456
+ return render(true);
2457
+ }
2458
+ case "support_region": case "support_part": {
2459
+ // Its countries (a country's part: its schools) shown or hidden in place, the page where it was; the others left
2460
+ // as they are.
2461
+ const open = action === "support_region" ? supportRegions : supportParts, key = target.dataset.key;
2462
+ if (!open.delete(key)) open.add(key);
2463
+ return render(true);
2464
+ }
1773
2465
  case "support_group":
1774
- supportOpen = supportOpen === target.dataset.province ? "" : target.dataset.province;
2466
+ // The country's page, at its top, its parts closed; where the regions' page was kept for coming back.
2467
+ supportBack = surfaceTop(); supportOpen = target.dataset.key; supportParts = new Set(); supportFilter = ""; pageScroll = 0;
1775
2468
  return render(true);
1776
2469
  case "login_add": {
1777
2470
  loginAdding = !loginAdding; schoolFound = null; loginError = "";
@@ -1892,8 +2585,9 @@ async function act(action, target) {
1892
2585
  }
1893
2586
  }
1894
2587
 
1895
- // A paper list scrolls; pressing in it must not drag the window.
1896
- const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll, .keys-scroll');
2588
+ // A paper list scrolls; pressing in it must not drag the window. Nor in 支持的学校's list (user, 2026-11-21: a press
2589
+ // between its rows dragged, and the redraw after it went back to the top).
2590
+ const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll, .keys-scroll, #support-list');
1897
2591
  // The dot's card: open while the pointer is on the dot or the card, a moment's grace between
1898
2592
  // them. Told by where the pointer moves, not by its leaving: the card is redrawn every second
1899
2593
  // and a dot redrawn under the pointer never says it was left.
@@ -1977,6 +2671,16 @@ root.addEventListener("input", (event) => {
1977
2671
  else if (input.id === "login-user") loginValues.username = input.value;
1978
2672
  else if (input.id === "login-password") loginValues.password = input.value;
1979
2673
  else if (input.id === "school-query") schoolQuery = input.value;
2674
+ else if (input.id === "test-article") { testArticleText = input.value; testArticleError = ""; }
2675
+ else if (input.id === "pro-code") {
2676
+ proCode = input.value;
2677
+ // Typing again clears why the last code was not taken.
2678
+ if (proCodeError || (proInstall.state === "failed" && proActivating())) {
2679
+ proCodeError = "";
2680
+ if (proInstall.state === "failed") proInstall = { state: "idle" };
2681
+ root.querySelector(".pro-code-err")?.remove();
2682
+ }
2683
+ }
1980
2684
  else if (input.id === "support-filter") {
1981
2685
  supportFilter = input.value;
1982
2686
  const box = root.querySelector("#support-list");
@@ -1987,6 +2691,21 @@ root.addEventListener("click", (event) => {
1987
2691
  const target = event.target.closest("[data-act]");
1988
2692
  if (target) { event.stopPropagation(); act(target.dataset.act, target); }
1989
2693
  });
2694
+ // The language menu closes on a press anywhere else, taken off at once: a press on the card's background starts
2695
+ // the window's drag, while which the page is not drawn again.
2696
+ document.addEventListener("pointerdown", (event) => {
2697
+ if (languageOpen && !event.target.closest(".lang-wrap")) closeLanguageMenu();
2698
+ }, true);
2699
+ function closeLanguageMenu() {
2700
+ languageOpen = false;
2701
+ root.querySelector(".lang-menu")?.remove();
2702
+ const button = root.querySelector(".lang-btn");
2703
+ if (!button) return;
2704
+ button.setAttribute("aria-expanded", "false");
2705
+ button.lastElementChild.outerHTML = icon("down");
2706
+ }
2707
+ // While the card folds to go into the Dock, the pointer still on it does not open it again.
2708
+ let minimizing = false;
1990
2709
  function setHover(inside, force = false) {
1991
2710
  // Minimize/task transitions can fold the card while the pointer stays inside.
1992
2711
  if (!force && hovering === inside && (!inside || open)) return;
@@ -1994,7 +2713,7 @@ function setHover(inside, force = false) {
1994
2713
  clearTimeout(hoverTimer); clearTimeout(leaveTimer);
1995
2714
  if (dragging || attentionPointer !== null) return;
1996
2715
  if (inside) {
1997
- hoverTimer = setTimeout(() => { if (!open) { open = true; render(true); } }, 100);
2716
+ hoverTimer = setTimeout(() => { if (!open && !minimizing) { open = true; render(true); } }, 100);
1998
2717
  } else {
1999
2718
  // Leave enough time to cross the edge; open menus and settings stay usable.
2000
2719
  leaveTimer = setTimeout(() => { if (!panel && !pinned) { open = false; render(true); } }, 280);
@@ -2037,13 +2756,17 @@ window.addEventListener("pointercancel", endAttentionPress);
2037
2756
  window.addEventListener("blur", endAttentionPress);
2038
2757
  document.addEventListener("keydown", (event) => {
2039
2758
  if (event.key === "Escape" && panel) {
2759
+ if (languageOpen) { closeLanguageMenu(); return root.querySelector(".lang-btn")?.focus(); }
2760
+ // Its box closed, the article as it was.
2761
+ if (testEditing && event.target.id === "test-article") { testEditing = false; testArticleError = ""; return render(true); }
2040
2762
  if (panel !== "settings") { panel = ""; render(true); }
2041
2763
  else act(editing ? "cancel_key" : "back");
2042
2764
  }
2043
2765
  if (event.key === "Enter" && panel === "settings" && event.target.tagName === "INPUT") {
2044
2766
  if (settingsPage === "keys" && editing) act("save_key", { dataset: { service: editing }, textContent: "" });
2045
2767
  else if (settingsPage === "download" || settingsPage === "wait") act("save");
2046
- else if (settingsPage === "login") act(event.target.id === "school-query" ? "find_school" : "save_login", { dataset: {} });
2768
+ else if (settingsPage === "login") act(event.target.id === "school-query" ? "find_school" : event.target.id === "test-article" ? "test_article_save" : "save_login", { dataset: {} });
2769
+ else if (["about", "pro_activate"].includes(settingsPage) && event.target.id === "pro-code") act("activate_pro");
2047
2770
  }
2048
2771
  });
2049
2772
 
@@ -2052,6 +2775,8 @@ window.addEventListener("pywebviewready", async () => {
2052
2775
  document.body.classList.add(platform === "darwin" ? "mac" : platform === "win32" ? "win" : "other");
2053
2776
  await tick();
2054
2777
  pollTimer = setInterval(tick, 500);
2778
+ setTimeout(() => checkVersions(), 3000);
2779
+ setInterval(() => checkVersions(), 6 * 3600 * 1000);
2055
2780
  });
2056
2781
  </script>
2057
2782
  </body>