papersearch 0.7.1 → 0.7.3
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.
- package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batch.js +306 -12
- package/dist/capabilities/download/batch/batch.js.map +1 -1
- package/dist/capabilities/download/batch/batchFolder.js +1 -1
- package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
- package/dist/capabilities/download/batch/batchSummary.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batchSummary.js +17 -8
- package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
- package/dist/capabilities/download/batch/journalKey.d.ts +12 -0
- package/dist/capabilities/download/batch/journalKey.d.ts.map +1 -0
- package/dist/capabilities/download/batch/journalKey.js +30 -0
- package/dist/capabilities/download/batch/journalKey.js.map +1 -0
- package/dist/capabilities/download/batch/networkLoss.d.ts +1 -1
- package/dist/capabilities/download/batch/networkLoss.js +1 -1
- package/dist/capabilities/download/content/markdown/shortfall.js +5 -5
- package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -1
- package/dist/capabilities/download/content/pdf/DownloadTier.d.ts +4 -0
- package/dist/capabilities/download/content/pdf/DownloadTier.d.ts.map +1 -1
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.d.ts.map +1 -1
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js +2 -0
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js.map +1 -1
- package/dist/capabilities/download/content/pdf/school.js +2 -0
- package/dist/capabilities/download/content/pdf/school.js.map +1 -1
- package/dist/capabilities/download/types.d.ts +4 -0
- package/dist/capabilities/download/types.d.ts.map +1 -1
- package/dist/cli.js +32 -9
- package/dist/cli.js.map +1 -1
- package/dist/infrastructure/runlog/failureClass.d.ts +16 -9
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +64 -54
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.js +61 -56
- package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts +9 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.js +31 -1
- package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
- package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.js +3 -0
- package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
- package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolResultNormalizer.js +5 -0
- package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
- package/dist/infrastructure/school/index.d.ts +1 -1
- package/dist/infrastructure/school/index.d.ts.map +1 -1
- package/dist/infrastructure/school/types.d.ts +19 -0
- package/dist/infrastructure/school/types.d.ts.map +1 -1
- package/dist/management/failures/index.d.ts +5 -2
- package/dist/management/failures/index.d.ts.map +1 -1
- package/dist/management/failures/index.js +21 -4
- package/dist/management/failures/index.js.map +1 -1
- package/dist/management/pro/activate.d.ts +36 -0
- package/dist/management/pro/activate.d.ts.map +1 -0
- package/dist/management/pro/activate.js +122 -0
- package/dist/management/pro/activate.js.map +1 -0
- package/dist/management/pro/install.d.ts +15 -0
- package/dist/management/pro/install.d.ts.map +1 -1
- package/dist/management/pro/install.js +39 -12
- package/dist/management/pro/install.js.map +1 -1
- package/dist/management/reports/index.d.ts +6 -0
- package/dist/management/reports/index.d.ts.map +1 -1
- package/dist/management/reports/index.js +6 -0
- package/dist/management/reports/index.js.map +1 -1
- package/dist/management/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +1 -0
- package/dist/management/school/autoUpdate.js.map +1 -1
- package/dist/management/school/cliProgress.d.ts.map +1 -1
- package/dist/management/school/cliProgress.js +1 -0
- package/dist/management/school/cliProgress.js.map +1 -1
- package/dist/management/school/settingsWindow.d.ts +1 -0
- package/dist/management/school/settingsWindow.d.ts.map +1 -1
- package/dist/management/school/settingsWindow.js +2 -0
- package/dist/management/school/settingsWindow.js.map +1 -1
- package/dist/management/updates/selfUpdate.d.ts +86 -0
- package/dist/management/updates/selfUpdate.d.ts.map +1 -0
- package/dist/management/updates/selfUpdate.js +194 -0
- package/dist/management/updates/selfUpdate.js.map +1 -0
- package/package.json +1 -1
- package/school/paper_search_school/adapters/annual_reviews/__init__.py +1 -0
- package/school/paper_search_school/adapters/base.py +4 -0
- package/school/paper_search_school/adapters/ieee/__init__.py +1 -0
- package/school/paper_search_school/adapters/oup/__init__.py +20 -0
- package/school/paper_search_school/adapters/sage/__init__.py +4 -1
- package/school/paper_search_school/adapters/taylor_francis/__init__.py +3 -0
- package/school/paper_search_school/adapters/thieme/__init__.py +4 -2
- package/school/paper_search_school/assets/capsule.html +1044 -243
- package/school/paper_search_school/assets/capsule_en.json +320 -74
- package/school/paper_search_school/assets/capsule_fr.json +1309 -0
- package/school/paper_search_school/assets/capsule_ja.json +1309 -0
- package/school/paper_search_school/assets/capsule_ko.json +1309 -0
- package/school/paper_search_school/assets/capsule_zh-Hant.json +2436 -0
- package/school/paper_search_school/cli.py +15 -1
- package/school/paper_search_school/cold_start.py +82 -9
- package/school/paper_search_school/config.py +2 -0
- package/school/paper_search_school/download_diagnostics.py +4 -4
- package/school/paper_search_school/engine/access_rules.py +3 -2
- package/school/paper_search_school/engine/batch.py +12 -4
- package/school/paper_search_school/engine/batch_access.py +21 -9
- package/school/paper_search_school/engine/batch_capture.py +36 -2
- package/school/paper_search_school/engine/batch_diagnostics.py +1 -1
- package/school/paper_search_school/engine/batch_institution.py +171 -29
- package/school/paper_search_school/engine/batch_login.py +65 -1
- package/school/paper_search_school/engine/batch_waits.py +22 -8
- package/school/paper_search_school/engine/bridge.py +27 -3
- package/school/paper_search_school/engine/router.py +2 -1
- package/school/paper_search_school/i18n.py +46 -22
- package/school/paper_search_school/orchestrator.py +90 -12
- package/school/paper_search_school/pro_status.py +54 -63
- package/school/paper_search_school/progress_capsule.py +180 -24
- package/school/paper_search_school/progress_reporter.py +68 -13
- package/school/paper_search_school/progress_view.py +4 -3
- package/school/paper_search_school/publishers/builtin/sage.json +4 -2
- package/school/paper_search_school/publishers/builtin/thieme.json +3 -1
- package/school/paper_search_school/school_login.py +18 -4
- package/school/paper_search_school/school_switch.py +84 -0
- package/school/paper_search_school/school_test.py +335 -0
- package/school/paper_search_school/server.py +21 -3
- package/school/paper_search_school/updates.py +222 -0
- package/school/paper_search_school/user_settings.py +8 -3
- package/skills/paper-search/SKILL.md +1 -1
- package/skills/paper-search/references/browser-download.md +7 -9
- package/skills/paper-search/references/cli-contract.md +1 -1
- package/skills/paper-search/references/publisher-support.md +2 -2
- package/skills/paper-search/references/school-setup.md +1 -1
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
through the card (user, 2026-11-10). */
|
|
10
10
|
--bg: #ffffff; --fg: #111827; --dim: #6b7280; --faint: #9ca3af;
|
|
11
11
|
--line: rgba(17, 24, 39, 0.10); --track: rgba(17, 24, 39, 0.10); --hover: rgba(17, 24, 39, 0.06);
|
|
12
|
+
--fill: rgba(17, 24, 39, 0.045); --edge: rgba(17, 24, 39, 0.12);
|
|
12
13
|
--accent: #2563eb; --ok: #16a34a; --bad: #dc2626;
|
|
13
14
|
--warn: #92400e; --warn-bg: #fef3c7; --warn-line: #f3d27a; --warn-dot: #d97706;
|
|
14
15
|
/* Inside the window's 10 px margin (body.mac): a shadow running past it was cut off
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
:root {
|
|
20
21
|
--bg: #202124; --fg: #f3f4f6; --dim: #a1a1aa; --faint: #71717a;
|
|
21
22
|
--line: rgba(255, 255, 255, 0.12); --track: rgba(255, 255, 255, 0.14); --hover: rgba(255, 255, 255, 0.08);
|
|
23
|
+
--fill: rgba(255, 255, 255, 0.05); --edge: rgba(255, 255, 255, 0.16);
|
|
22
24
|
--accent: #60a5fa; --ok: #4ade80; --bad: #f87171;
|
|
23
25
|
--warn: #fbbf24; --warn-bg: #3a2d10; --warn-line: #6b5216; --warn-dot: #fbbf24;
|
|
24
26
|
--shadow: 0 3px 7px rgba(0, 0, 0, 0.42), 0 1px 2px rgba(0, 0, 0, 0.32);
|
|
@@ -95,16 +97,28 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
95
97
|
.head .title { font-weight: 600; font-size: 14px; }
|
|
96
98
|
.head .sub { font-size: 12px; color: var(--dim); }
|
|
97
99
|
/* 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:
|
|
99
|
-
|
|
100
|
+
.tools { display: flex; align-items: center; gap: 0; margin-right: -3px; flex: none; }
|
|
101
|
+
/* Each a 32 px target, drawn where it was (user, 2026-11-21: 最小化 was hard to hit): the margins take back what the
|
|
102
|
+
padding adds, the icons 24 px apart as before. */
|
|
103
|
+
.tools .iconbtn { margin: -4px; padding: 8px; }
|
|
100
104
|
.iconbtn { background: none; border: none; padding: 4px; margin: -4px; border-radius: 6px; color: var(--dim); display: inline-flex; cursor: pointer; }
|
|
101
105
|
.iconbtn:hover { background: var(--hover); color: var(--fg); }
|
|
102
106
|
.paper { margin: 14px 0 12px; }
|
|
103
107
|
.paper .name { line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
104
108
|
.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; }
|
|
109
|
+
.paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
106
110
|
.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 .
|
|
111
|
+
.paper-link .where, .paper-link .notice { display: block; }
|
|
112
|
+
/* The paper's block is one height whatever the paper (user, 2026-11-21: the card shook up and down as papers went by,
|
|
113
|
+
each change of height resizing the window, whose edge moves): the title two lines high even when one, the journal or
|
|
114
|
+
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
|
|
115
|
+
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
|
|
116
|
+
as each other. test_the_running_card_keeps_its_height_whatever_the_paper. */
|
|
117
|
+
.paper .name { height: 2.9em; }
|
|
118
|
+
.paper .where, .paper .notice { height: 1.45em; line-height: 1.45; }
|
|
119
|
+
.paper-status { display: flex; align-items: center; height: 18px; margin-top: 8px; overflow: hidden; }
|
|
120
|
+
.paper-status .steps { flex: 1; min-width: 0; margin-top: 0; }
|
|
121
|
+
.paper-status .line { flex: 1; min-width: 0; margin-top: 0; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
108
122
|
.paper-link:hover .name { text-decoration: underline; }
|
|
109
123
|
.paper-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
110
124
|
.steps { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
|
|
@@ -219,17 +233,69 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
219
233
|
.nav-sub { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
220
234
|
.settings-note { font-size: 11px; color: var(--ok); margin-top: 8px; }
|
|
221
235
|
.key-group { font-size: 11px; color: var(--faint); margin: 12px 0 2px; }
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
.
|
|
228
|
-
.
|
|
236
|
+
/* The home page's last line (user, 2026-11-21): PaperSearch Pro, a blue link at its left; the language at its
|
|
237
|
+
right, one menu of the languages each in its own name. Installed, Pro's features are rows above, marked Pro. */
|
|
238
|
+
.settings .home-foot { gap: 12px; padding: 10px 0 0; }
|
|
239
|
+
/* 关于 PaperSearch (user, 2026-11-21): its icon and name centered, Pro's pill beside the name with the line a little to
|
|
240
|
+
the right (not the name alone centered: too far right), a wider space before Pro's part. */
|
|
241
|
+
.app-icon { display: block; flex: none; }
|
|
242
|
+
.about-hero { display: flex; flex-direction: column; align-items: center; margin-top: 12px; text-align: center; }
|
|
243
|
+
.about-name { font-size: 16px; font-weight: 600; margin-top: 8px; white-space: nowrap; }
|
|
244
|
+
.about-name.with-pill { transform: translateX(8px); }
|
|
245
|
+
.about-name .pro-pill { margin-left: 6px; vertical-align: 2px; }
|
|
246
|
+
.about-version { font-size: 12px; color: var(--dim); margin-top: 3px; }
|
|
247
|
+
.about-version.new, .about-version.bad { color: var(--bad); }
|
|
248
|
+
/* 有新版本 X, a link to what is new (user, 2026-11-22: 乙, in the line, not under the button). */
|
|
249
|
+
.about-version .ver-notes { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;
|
|
250
|
+
text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
|
|
251
|
+
.about-version .ver-notes svg.i { width: 11px; height: 11px; margin-left: 2px; vertical-align: -1px; stroke-width: 2.2; }
|
|
252
|
+
.about-action { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
|
|
253
|
+
.about-action .btn.primary { width: 100%; justify-content: center; padding: 6px 10px; font-size: 13px; }
|
|
254
|
+
.about-action .btn.link { padding: 0; font-size: 12px; }
|
|
255
|
+
.about-action .pro-bar { width: 100%; }
|
|
256
|
+
.update-steps { align-self: stretch; }
|
|
257
|
+
.about-caption { text-align: center; font-size: 11px; color: var(--dim); margin-top: 6px; }
|
|
258
|
+
.about-gap { height: 18px; }
|
|
259
|
+
.about-sec { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; margin-top: 22px; padding-bottom: 8px;
|
|
260
|
+
border-bottom: 0.5px solid var(--line); }
|
|
261
|
+
.about-feat { padding: 6px 0; }
|
|
262
|
+
.about-feat b { font-weight: 600; font-size: 12px; }
|
|
263
|
+
.about-feat .pro-tag { display: inline-block; margin-left: 6px; vertical-align: 1px; }
|
|
264
|
+
.about-feat .pl-sub { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 1px; }
|
|
265
|
+
.about-sub { font-size: 11px; color: var(--faint); margin: 12px 0 2px; }
|
|
266
|
+
.settings .pro-activate { margin-top: 14px; }
|
|
267
|
+
.version-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; border: none; background: none;
|
|
268
|
+
font: inherit; font-size: 12px; color: var(--dim); cursor: pointer; }
|
|
269
|
+
.version-link.new { color: var(--bad); font-weight: 600; }
|
|
270
|
+
.version-link .pl-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
271
|
+
.version-link:hover .pl-text { text-decoration: underline; }
|
|
272
|
+
.version-link svg.i { width: 14px; height: 14px; flex: none; }
|
|
273
|
+
.version-link .pro-pill { margin-left: 2px; flex: none; }
|
|
274
|
+
.reopen-line { display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 7px 10px; border: none; border-radius: 8px;
|
|
275
|
+
background: rgba(22, 163, 74, 0.10); color: var(--ok); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
|
276
|
+
.reopen-line svg.i { width: 14px; height: 14px; flex: none; }
|
|
277
|
+
.reopen-line .k { margin-left: auto; font-weight: 600; white-space: nowrap; }
|
|
278
|
+
.iconbtn.has-dot { position: relative; }
|
|
279
|
+
.iconbtn.has-dot::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
|
|
280
|
+
.tools .iconbtn.has-dot::after { top: 6px; right: 6px; }
|
|
281
|
+
.nav-row .app-icon { margin: 0 1px; }
|
|
282
|
+
.lang-btn { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 2px 0; border: none;
|
|
283
|
+
background: none; font: inherit; font-size: 12px; cursor: pointer; }
|
|
284
|
+
.lang-btn svg.i { width: 14px; height: 14px; flex: none; }
|
|
285
|
+
.lang-wrap { position: relative; flex: none; }
|
|
286
|
+
.lang-btn { color: var(--dim); }
|
|
287
|
+
.lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--fg); }
|
|
288
|
+
.lang-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; min-width: 150px; box-sizing: border-box; padding: 4px;
|
|
289
|
+
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); }
|
|
290
|
+
.lang-menu button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 5px 8px;
|
|
291
|
+
border: none; border-radius: 6px; background: none; font: inherit; font-size: 12px; color: var(--fg); text-align: left; cursor: pointer; }
|
|
292
|
+
.lang-menu button:hover { background: var(--hover); }
|
|
293
|
+
.lang-menu button[aria-checked="true"] { color: var(--accent); }
|
|
294
|
+
.lang-menu button svg.i { width: 14px; height: 14px; }
|
|
295
|
+
.lang-more { margin: 4px 4px 0; padding: 5px 4px 2px; border-top: 0.5px solid var(--line); font-size: 11px; color: var(--faint); }
|
|
296
|
+
.nav-title .pro-pill.feature { margin-left: 6px; }
|
|
297
|
+
/* Pro's pill (蓝标) and its texts, on the home page, 关于 PaperSearch and Pro's feature pages. */
|
|
229
298
|
.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
299
|
.pro-desc { font-size: 12px; line-height: 1.55; color: var(--dim); margin-top: 10px; }
|
|
234
300
|
.pro-action { margin-top: 12px; }
|
|
235
301
|
.pro-action:empty { display: none; }
|
|
@@ -244,13 +310,33 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
244
310
|
/* What Pro keeps, its counts, its sites and whether it is free (user, 2026-11-19). */
|
|
245
311
|
/* What a Markdown keeps, the counts, the sites and the usage, as drawn on 2026-11-19: taller than the
|
|
246
312
|
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
313
|
.pro-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
|
|
249
314
|
.pro-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px 2px 7px; border-radius: 999px;
|
|
250
315
|
border: 0.5px solid var(--line); color: var(--dim); }
|
|
251
316
|
.pro-chip svg.i { width: 13px; height: 13px; }
|
|
317
|
+
/* What sets Pro's Markdown apart, a row that opens like the platforms' (user, 2026-11-21). */
|
|
318
|
+
.pro-merits { padding: 0 0 8px 26px; }
|
|
319
|
+
.pro-merit { display: flex; gap: 8px; padding: 6px 0; }
|
|
320
|
+
.pro-merit svg.i { width: 15px; height: 15px; margin-top: 1px; color: var(--dim); }
|
|
321
|
+
.pro-merit b { display: block; font-weight: 600; font-size: 12px; }
|
|
322
|
+
.pro-merit span { display: block; font-size: 11.5px; color: var(--dim); line-height: 1.45; margin-top: 1px; }
|
|
252
323
|
.pro-stats { margin-top: 12px; }
|
|
253
|
-
|
|
324
|
+
/* Pro's page (user, 2026-11-21): what it does now and what is coming, each a line; the activation code. */
|
|
325
|
+
.pro-tag { flex: none; align-self: flex-start; font-size: 10.5px; line-height: 1.6; color: var(--dim); background: var(--hover);
|
|
326
|
+
border-radius: 4px; padding: 0 5px; }
|
|
327
|
+
.pro-activate { margin-top: 14px; padding-top: 12px; border-top: 0.5px solid var(--line); }
|
|
328
|
+
.pro-code-label { font-size: 11px; color: var(--dim); margin-bottom: 5px; }
|
|
329
|
+
.pro-code { display: flex; gap: 6px; }
|
|
330
|
+
.settings .pro-code input { flex: 1; min-width: 0; width: auto; height: 30px; text-align: left; background: var(--bg); padding: 0 8px;
|
|
331
|
+
font-size: 13px; letter-spacing: 0.04em; }
|
|
332
|
+
.pro-action .pro-code .btn.primary { width: auto; flex: none; padding: 5px 12px; }
|
|
333
|
+
.settings .pro-action .err { text-align: left; margin: 6px 0 0; }
|
|
334
|
+
.pro-needed { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px;
|
|
335
|
+
border-top: 0.5px solid var(--line); font-size: 12px; color: var(--dim); }
|
|
336
|
+
.pro-needed .btn.link { padding-right: 0; gap: 2px; white-space: nowrap; flex: none; }
|
|
337
|
+
.pro-needed .btn.link svg.i { width: 13px; height: 13px; }
|
|
338
|
+
.pro-use .ok { color: var(--ok); }
|
|
339
|
+
.pro-use .bad { color: var(--bad); }
|
|
254
340
|
.pro-sites { padding: 0 0 8px 26px; }
|
|
255
341
|
/* The platforms by kind, each site once (user, 2026-11-20: a list in groups, the multidisciplinary ones first). */
|
|
256
342
|
.site-group { font-size: 11px; color: var(--faint); margin: 6px 0 3px; }
|
|
@@ -263,12 +349,37 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
263
349
|
.key-edit { background: var(--hover); border-radius: 8px; padding: 8px 10px; margin: 0 0 6px; }
|
|
264
350
|
/* The school sign-in page (PaperSearch Pro): the schools saved, one the default for downloads, each with its
|
|
265
351
|
account; the fields beside their names, close together (user, 2026-11-20). */
|
|
266
|
-
|
|
267
|
-
|
|
352
|
+
/* A card per school (user, 2026-11-22: 甲, the schools hard to tell apart in one list): the closed ones filled, the open
|
|
353
|
+
one white with an edge, 添加学校 a dashed one; its rarer actions in ⋯, a confirmation in place of its last line. */
|
|
354
|
+
.login-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
|
|
355
|
+
.login-school { position: relative; border-radius: 10px; background: var(--fill); padding: 0 10px; }
|
|
356
|
+
.login-school.open { background: var(--bg); box-shadow: 0 0 0 1px var(--edge), 0 2px 8px rgba(17, 24, 39, 0.06); padding-bottom: 10px; }
|
|
357
|
+
.login-school.add { background: none; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
|
|
358
|
+
/* The open card's head: no masked account (its field is under it), room kept for ⋯ before the chevron. */
|
|
359
|
+
.login-row .ls-end { flex: none; width: 0; margin-left: auto; }
|
|
360
|
+
.login-row .ls-end.with-menu { width: 24px; }
|
|
361
|
+
.ls-dots { position: absolute; right: 29px; top: 7px; width: 24px; height: 24px; margin: 0; border-radius: 6px; background: var(--hover); }
|
|
362
|
+
.ls-dots svg.i { width: 15px; height: 15px; }
|
|
363
|
+
.ls-menu { position: absolute; right: 29px; top: 34px; z-index: 6; min-width: 120px; padding: 4px 0; border-radius: 8px; background: var(--bg);
|
|
364
|
+
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); }
|
|
365
|
+
.ls-menu button { display: block; width: 100%; padding: 6px 14px; border: none; background: none; font: inherit; font-size: 12.5px;
|
|
366
|
+
color: var(--fg); text-align: left; white-space: nowrap; cursor: pointer; }
|
|
367
|
+
.ls-menu button:hover, .ls-menu button:focus-visible { background: var(--hover); outline: none; }
|
|
368
|
+
.ls-menu button.danger { color: var(--bad); }
|
|
369
|
+
.login-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; height: 30px; margin-top: 2px; font-size: 12px; color: var(--dim); }
|
|
370
|
+
.login-foot .grow { flex: 1; }
|
|
371
|
+
.login-foot .switch, .login-foot .btn { flex: none; white-space: nowrap; }
|
|
372
|
+
.login-foot.asking { padding: 0 4px 0 10px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 9%, transparent); color: var(--bad); }
|
|
373
|
+
.login-foot.asking .q { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
374
|
+
.login-foot .btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
|
|
375
|
+
.login-row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 0; text-align: left; font-size: 13px;
|
|
268
376
|
border: none; background: none; color: inherit; font-family: inherit; cursor: pointer; }
|
|
269
377
|
.login-row:hover .ls-name { color: var(--accent); }
|
|
270
378
|
.login-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
|
|
271
379
|
.login-row .ls-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
380
|
+
.login-row .ls-n { flex: none; width: 12px; font-size: 11px; color: var(--faint); text-align: left; }
|
|
381
|
+
/* Under the schools, whose rows end in a line already: its own line below, none above (two showed, 2026-11-21). */
|
|
382
|
+
.settings .switch-row { border-top: none; border-bottom: 0.5px solid var(--line); }
|
|
272
383
|
.login-row .ls-acct { margin-left: auto; font-size: 11.5px; color: var(--dim); white-space: nowrap; }
|
|
273
384
|
.login-row svg.i { width: 13px; height: 13px; flex: none; color: var(--faint); }
|
|
274
385
|
.tag.fill { background: rgba(22, 163, 74, 0.12); color: var(--ok); }
|
|
@@ -278,9 +389,11 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
278
389
|
.tag.none { background: var(--hover); color: var(--dim); }
|
|
279
390
|
.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
391
|
.settings .login-form input { width: 100%; box-sizing: border-box; text-align: left; background: var(--bg); padding: 5px 8px; font-size: 13px; }
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
.login-pw
|
|
392
|
+
/* The eye inside the password's box, and the test article's line ending where the boxes end: the three rows' right
|
|
393
|
+
edges in line (user, 2026-11-21, 甲). */
|
|
394
|
+
.login-pw { position: relative; display: block; min-width: 0; }
|
|
395
|
+
.settings .login-pw input { padding-right: 30px; }
|
|
396
|
+
.login-pw .iconbtn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); margin: 0; }
|
|
284
397
|
.login-form .err, .login-form .key-actions { grid-column: 1 / -1; }
|
|
285
398
|
.login-form .err { text-align: left; margin: 0; }
|
|
286
399
|
.login-form .err:empty { display: none; }
|
|
@@ -288,18 +401,59 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
288
401
|
.login-form .key-actions .btn { white-space: nowrap; }
|
|
289
402
|
/* The less used ones under the buttons, the same for every school (user, 2026-11-20: rows of buttons that differed
|
|
290
403
|
from school to school, and wrapped). */
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
.login-
|
|
294
|
-
.login-
|
|
295
|
-
.
|
|
404
|
+
/* 测试登录 (user, 2026-11-21, as drawn): the article, then how the test went; while it runs, its steps in rows of their
|
|
405
|
+
own height and one line for what the download says, so that the page does not move as it goes. */
|
|
406
|
+
.login-form .test-result { grid-column: 1 / -1; }
|
|
407
|
+
.login-form .test-err { grid-column: 2; }
|
|
408
|
+
.test-article { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
409
|
+
.login-form .test-article { grid-column: 1 / -1; }
|
|
410
|
+
.test-article .lbl { flex: none; color: var(--dim); font-size: 12px; }
|
|
411
|
+
.test-article .link-btn.edit svg.i { width: 13px; height: 13px; }
|
|
412
|
+
.test-article .what { flex: 1; min-width: 0; color: var(--fg); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
413
|
+
.test-article .what.empty { color: var(--dim); font-size: 11.5px; } /* none filled in: what to do */
|
|
414
|
+
.test-article .test-btn { padding: 3px 10px; flex: none; white-space: nowrap; }
|
|
415
|
+
.test-article .link-btn, .test-edit .link-btn { border: none; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; flex: none; }
|
|
416
|
+
/* The box holds the text and its button side by side: 查找中… is wider than 确定 and went over the text (user,
|
|
417
|
+
2026-11-21); the text gives way to whatever the button says, in any language. */
|
|
418
|
+
.test-edit { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; height: 26px; box-sizing: border-box;
|
|
419
|
+
background: var(--bg); border: 0.5px solid var(--line); border-radius: 6px; padding: 0 8px; }
|
|
420
|
+
.test-edit:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
|
|
421
|
+
.settings .test-edit input { flex: 1; min-width: 0; width: auto; height: 24px; border: none; background: none; padding: 0;
|
|
422
|
+
text-align: left; font-size: 13px; }
|
|
423
|
+
.settings .test-edit input:focus { outline: none; }
|
|
424
|
+
.test-edit .link-btn { font-size: 12px; white-space: nowrap; }
|
|
425
|
+
.test-edit .link-btn:disabled { color: var(--dim); cursor: default; }
|
|
426
|
+
.test-result { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; }
|
|
427
|
+
.test-result svg.i { width: 15px; height: 15px; flex: none; margin-top: 1px; }
|
|
428
|
+
.test-result.ok { background: rgba(22, 163, 74, 0.10); } .test-result.ok svg.i { color: var(--ok); }
|
|
429
|
+
.test-result.bad { background: rgba(220, 38, 38, 0.08); } .test-result.bad svg.i { color: var(--bad); }
|
|
430
|
+
.test-result .t { color: var(--fg); font-weight: 600; } .test-result .d { margin-top: 2px; }
|
|
431
|
+
.login-test { padding: 2px 0 8px; font-size: 12px; color: var(--dim); }
|
|
432
|
+
.test-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
|
|
433
|
+
.test-steps li { display: flex; align-items: center; gap: 8px; height: 18px; color: var(--faint); }
|
|
434
|
+
.test-steps li svg.i { width: 15px; height: 15px; color: var(--ok); }
|
|
435
|
+
.test-steps li.done { color: var(--dim); }
|
|
436
|
+
.test-steps li.now { color: var(--fg); font-weight: 600; }
|
|
437
|
+
.test-steps .mark { width: 9px; height: 9px; margin: 0 3px; border-radius: 50%; border: 1.5px solid currentColor; box-sizing: border-box; }
|
|
438
|
+
.test-steps li.now .mark { background: var(--accent); border-color: var(--accent); }
|
|
439
|
+
.test-phase { height: 18px; line-height: 18px; margin: 6px 0 2px 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
440
|
+
.login-test .key-actions { margin-top: 6px; }
|
|
296
441
|
.login-add { padding: 0 0 10px; }
|
|
297
442
|
.login-add-row .ls-name { font-weight: 500; }
|
|
298
443
|
.login-add-row svg.i:first-child { color: var(--accent); }
|
|
299
444
|
.login-find { display: flex; gap: 6px; }
|
|
300
445
|
.settings .login-find input { flex: 1; min-width: 0; text-align: left; background: var(--bg); padding: 5px 8px; font-size: 13px; }
|
|
301
|
-
|
|
302
|
-
.
|
|
446
|
+
/* 支持的学校: a search field, its magnifier inside (user, 2026-11-21: the plain box looked out of place). */
|
|
447
|
+
.support-search { display: flex; align-items: center; gap: 6px; height: 32px; margin: 8px 0 6px; padding: 0 10px; box-sizing: border-box;
|
|
448
|
+
border: 0.5px solid var(--line); border-radius: 8px; background: var(--hover); color: var(--dim); }
|
|
449
|
+
.support-search:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
|
|
450
|
+
.settings .support-search input { flex: 1; min-width: 0; width: auto; height: 100%; padding: 0; border: none; background: none;
|
|
451
|
+
text-align: left; font-size: 13px; -webkit-appearance: none; appearance: none; }
|
|
452
|
+
.settings .support-search input:focus { outline: none; }
|
|
453
|
+
.login-found { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; padding: 5px 0; border-bottom: 0.5px solid var(--line); }
|
|
454
|
+
/* A long name wraps, not cut (user, 2026-11-21); what is said of it stays at its top right. */
|
|
455
|
+
.login-found .ls-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
456
|
+
.login-found .tag, .login-found .btn { flex: none; }
|
|
303
457
|
.login-found .ls-fed { font-size: 11px; color: var(--faint); }
|
|
304
458
|
.login-found .btn { margin-left: auto; }
|
|
305
459
|
.login-add .login-found:last-child { border-bottom: none; }
|
|
@@ -325,9 +479,6 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
325
479
|
.strip .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
326
480
|
.strip svg.i { width: 14px; height: 14px; }
|
|
327
481
|
.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
482
|
.prompt { display: flex; align-items: center; gap: 10px; }
|
|
332
483
|
.prompt svg.i { width: 22px; height: 22px; }
|
|
333
484
|
.prompt .t { font-weight: 600; font-size: 14px; }
|
|
@@ -354,6 +505,17 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
354
505
|
font: inherit; color: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
|
|
355
506
|
.grp .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
|
|
356
507
|
.grp .row .reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
508
|
+
/* 支持的学校's head (back, title, the numbers, search) on top while its list scrolls (user, 2026-11-21). */
|
|
509
|
+
.support-top { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-bottom: 2px; }
|
|
510
|
+
#support-list .row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 0; border: none;
|
|
511
|
+
border-bottom: 0.5px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
|
|
512
|
+
#support-list .row:hover .reason { color: var(--accent); }
|
|
513
|
+
#support-list .row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
|
|
514
|
+
#support-list .row .reason { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
515
|
+
#support-list .row .n { font-weight: 600; }
|
|
516
|
+
#support-list .row svg.i { width: 14px; height: 14px; color: var(--faint); }
|
|
517
|
+
.support-region > .row .reason { font-weight: 600; }
|
|
518
|
+
.support-countries { padding-left: 14px; }
|
|
357
519
|
.grp .row .n { font-weight: 600; }
|
|
358
520
|
.grp .row svg.i { width: 14px; height: 14px; color: var(--faint); }
|
|
359
521
|
.grp .m { font-size: 12px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
@@ -371,7 +533,7 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
371
533
|
.paper-list .open-article:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
|
|
372
534
|
.tag { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 5px; flex: none; }
|
|
373
535
|
.tag.no_access, .tag.other { background: var(--hover); color: var(--fg); }
|
|
374
|
-
.tag.user_side, .tag.
|
|
536
|
+
.tag.user_side, .tag.external { background: var(--warn-bg); color: var(--warn); }
|
|
375
537
|
.tag.unsupported { background: rgba(37, 99, 235, 0.12); color: var(--accent); }
|
|
376
538
|
.tag.unexplained { background: rgba(220, 38, 38, 0.12); color: var(--bad); }
|
|
377
539
|
.tag.doubt { background: var(--hover); color: var(--dim); }
|
|
@@ -381,42 +543,62 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
381
543
|
<div id="root" class="pill capsule-drag-region"></div>
|
|
382
544
|
<script>
|
|
383
545
|
"use strict";
|
|
384
|
-
//
|
|
385
|
-
//
|
|
546
|
+
// The window's progress_language: Chinese (zh, simplified) is the page's
|
|
547
|
+
// own; English (assets/capsule_en.json) and Traditional Chinese (assets/capsule_zh-Hant.json, made from it by
|
|
548
|
+
// school/tools/zh_hant_table.py, user 2026-11-21) are put in here when the window loads the page; every text shown
|
|
549
|
+
// passes through tr().
|
|
550
|
+
// Japanese, Korean and French too (user, 2026-11-21: "中文、英文、日语、韩文,还有法语…都需要支持"): a text their table
|
|
551
|
+
// does not know is said in English, not left in Chinese.
|
|
386
552
|
const EN = /*CAPSULE_EN*/null;
|
|
387
|
-
const
|
|
553
|
+
const HANT = /*CAPSULE_ZH_HANT*/null;
|
|
554
|
+
const JA = /*CAPSULE_JA*/null;
|
|
555
|
+
const KO = /*CAPSULE_KO*/null;
|
|
556
|
+
const FR = /*CAPSULE_FR*/null;
|
|
557
|
+
const TABLES = Object.fromEntries([["en", EN], ["zh-Hant", HANT], ["ja", JA], ["ko", KO], ["fr", FR]].filter(([, table]) => table)
|
|
558
|
+
.map(([code, table]) => [code, { ...table, patterns: table.patterns.map(([source, target]) => [new RegExp(source), target]) }]));
|
|
388
559
|
const HAN = /[\u4e00-\u9fff]/;
|
|
389
560
|
let lang = "zh";
|
|
561
|
+
// The languages that list with a comma, not 、 (Japanese keeps 、).
|
|
562
|
+
const commaLang = () => ["en", "ko", "fr"].includes(lang);
|
|
390
563
|
const BRACKETS = /^(.+?)((.+))$/;
|
|
391
564
|
const LISTED = /^([^:]+):(.+)$/;
|
|
392
|
-
function trOne(core) {
|
|
565
|
+
function trOne(core, table = TABLES[lang]) {
|
|
393
566
|
if (!HAN.test(core)) return core;
|
|
394
|
-
let
|
|
395
|
-
if (
|
|
396
|
-
const found =
|
|
397
|
-
|
|
567
|
+
let said = Object.hasOwn(table.exact, core) ? table.exact[core] : null;
|
|
568
|
+
if (said === null) {
|
|
569
|
+
const found = table.patterns.find(([pattern]) => pattern.test(core));
|
|
570
|
+
// What the text names in it is said too where it is a text of the table ("更新学校订阅下载扩展出错"); a name keeps
|
|
571
|
+
// its words, in Traditional Chinese its characters ("没权限,换红木兰大学").
|
|
572
|
+
if (found) {
|
|
573
|
+
const parts = found[0].exec(core);
|
|
574
|
+
said = core.replace(found[0], found[1].replace(/\$(\d)/g, (_, i) => (HAN.test(parts[i] || "") ? trOne(parts[i], table) : parts[i] || "")));
|
|
575
|
+
}
|
|
398
576
|
}
|
|
399
|
-
|
|
577
|
+
// Traditional Chinese: a text the table does not know, its characters (a name keeps its words).
|
|
578
|
+
if (said === null && table.chars) return core.replace(/[\u4e00-\u9fff]/g, (c) => table.chars[c] || c);
|
|
579
|
+
const parts = said === null && BRACKETS.exec(core);
|
|
400
580
|
// "开放下载 18(出版社 API 3、预印本 1)": the text and what its brackets list, each on its own.
|
|
401
|
-
if (parts)
|
|
581
|
+
if (parts) said = trOne(parts[1], table) + " (" + parts[2].split("、").map((p) => trOne(p, table)).join(", ") + ")";
|
|
402
582
|
// "不完整:参考文献少 1 条,少 1 张图": a known word, then what it lists, each on its own.
|
|
403
|
-
const listed =
|
|
404
|
-
if (listed && trOne(listed[1]) !== listed[1])
|
|
405
|
-
|
|
583
|
+
const listed = said === null && LISTED.exec(core);
|
|
584
|
+
if (listed && trOne(listed[1], table) !== listed[1]) said = trOne(listed[1], table) + ": " + listed[2].split(",").map((p) => trOne(p, table)).join(", ");
|
|
585
|
+
// Japanese, Korean, French: what their table does not know, in English rather than in Chinese.
|
|
586
|
+
if (said === null && table !== TABLES.en && TABLES.en) return trOne(core, TABLES.en);
|
|
587
|
+
return said === null ? core : said;
|
|
406
588
|
}
|
|
407
589
|
function tr(text) {
|
|
408
590
|
// "PDF、Markdown": the kinds' names need no table, only their separator.
|
|
409
|
-
if (
|
|
410
|
-
if (lang
|
|
591
|
+
if (commaLang() && text && !HAN.test(text) && String(text).includes("、")) return String(text).replace(/、/g, ", ");
|
|
592
|
+
if (!TABLES[lang] || !text || !HAN.test(text)) return text;
|
|
411
593
|
return String(text).split(" · ").map((part) => {
|
|
412
594
|
const core = part.trim();
|
|
413
595
|
if (!core || !HAN.test(core)) return part;
|
|
414
|
-
const
|
|
415
|
-
return
|
|
596
|
+
const said = trOne(core);
|
|
597
|
+
return said === core ? part : part.replace(core, said);
|
|
416
598
|
}).join(" · ");
|
|
417
599
|
}
|
|
418
600
|
function localize(node) {
|
|
419
|
-
if (lang
|
|
601
|
+
if (!TABLES[lang]) return;
|
|
420
602
|
const walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT);
|
|
421
603
|
for (let text = walker.nextNode(); text; text = walker.nextNode()) {
|
|
422
604
|
const english = tr(text.nodeValue);
|
|
@@ -443,8 +625,17 @@ const ICONS = {
|
|
|
443
625
|
pause: '<path d="M9 6.5v11M15 6.5v11"/>',
|
|
444
626
|
dots: '<circle cx="6" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="18" cy="12" r="1"/>',
|
|
445
627
|
left: '<path d="M15 6l-6 6 6 6"/>',
|
|
628
|
+
external: '<path d="M7 17L17 7M9 7h8v8"/>',
|
|
629
|
+
edit: '<path d="M4 20h4L19 9l-4-4L4 16z"/><path d="M13.5 6.5l4 4"/>',
|
|
446
630
|
right: '<path d="M9 6l6 6-6 6"/>',
|
|
447
631
|
down: '<path d="M6 9l6 6 6-6"/>',
|
|
632
|
+
up: '<path d="M6 15l6-6 6 6"/>',
|
|
633
|
+
tick: '<path d="M5 12.5l4.5 4.5L19 7.5"/>',
|
|
634
|
+
// Two four-pointed stars: PaperSearch Pro's link (user, 2026-11-21).
|
|
635
|
+
upcircle: '<circle cx="12" cy="12" r="9"/><path d="M12 16V8M8.5 11.5L12 8l3.5 3.5"/>',
|
|
636
|
+
refresh: '<path d="M19.5 12a7.5 7.5 0 1 1-2.2-5.3"/><path d="M19.5 4.5v4h-4"/>',
|
|
637
|
+
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"/>'
|
|
638
|
+
+ '<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
639
|
gear: gearPath(),
|
|
449
640
|
clock: '<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/>',
|
|
450
641
|
key: '<circle cx="8" cy="15" r="4"/><path d="M10.8 12.2L19 4M16 7l2.5 2.5M14 9l2 2"/>',
|
|
@@ -457,6 +648,8 @@ const ICONS = {
|
|
|
457
648
|
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
649
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
459
650
|
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"/>',
|
|
651
|
+
search: '<circle cx="11" cy="11" r="6.5"/><path d="M20 20l-4.2-4.2"/>',
|
|
652
|
+
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
653
|
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
654
|
};
|
|
462
655
|
function gearPath() {
|
|
@@ -469,6 +662,27 @@ function gearPath() {
|
|
|
469
662
|
return '<polygon points="' + pts.join(" ") + '"/><circle cx="12" cy="12" r="3"/>';
|
|
470
663
|
}
|
|
471
664
|
const icon = (name, extra) => '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"' + (extra || "") + ">" + ICONS[name] + "</svg>";
|
|
665
|
+
// PaperSearch's own icon (assets/icon.svg), and Pro's: the same paper and lens on a blue-violet turning to a soft rose
|
|
666
|
+
// gold, a light from its top left (user, 2026-11-21: 丙, elegant beside the plain one).
|
|
667
|
+
let appIconCount = 0;
|
|
668
|
+
function appIcon(size, pro) {
|
|
669
|
+
const id = "ai" + (++appIconCount);
|
|
670
|
+
const fill = pro ? '<linearGradient id="' + id + 'g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#6F78F2"/>'
|
|
671
|
+
+ '<stop offset=".5" stop-color="#A67BD9"/><stop offset="1" stop-color="#E3AFC0"/></linearGradient>'
|
|
672
|
+
+ '<radialGradient id="' + id + 's" cx=".28" cy=".2" r=".75"><stop offset="0" stop-color="#fff" stop-opacity=".3"/>'
|
|
673
|
+
+ '<stop offset=".5" stop-color="#fff" stop-opacity=".05"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient>'
|
|
674
|
+
: '<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>';
|
|
675
|
+
return '<svg class="app-icon' + (pro ? " pro" : "") + '" width="' + size + '" height="' + size + '" viewBox="0 0 512 512" aria-hidden="true"><defs>' + fill + "</defs>"
|
|
676
|
+
+ '<rect x="32" y="32" width="448" height="448" rx="104" fill="url(#' + id + 'g)"/>'
|
|
677
|
+
+ (pro ? '<rect x="32" y="32" width="448" height="448" rx="104" fill="url(#' + id + 's)"/>' : "")
|
|
678
|
+
+ '<g transform="rotate(-8 220 240)"><rect x="112" y="100" width="206" height="270" rx="30" fill="#fff" opacity=".96"/>'
|
|
679
|
+
+ '<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"/>'
|
|
680
|
+
+ '<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"/>'
|
|
681
|
+
+ '<circle cx="306" cy="300" r="92" fill="none" stroke="#fff" stroke-width="26"/>'
|
|
682
|
+
+ '<line x1="374" y1="368" x2="424" y2="418" stroke="#fff" stroke-width="32" stroke-linecap="round"/>'
|
|
683
|
+
+ '<path d="M306 248 Q306 300 358 300 Q306 300 306 352 Q306 300 254 300 Q306 300 306 248Z" fill="#fff"/>'
|
|
684
|
+
+ '<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>';
|
|
685
|
+
}
|
|
472
686
|
const esc = (s) => String(s == null ? "" : s).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
|
473
687
|
function ring(pct, size, stroke, label) {
|
|
474
688
|
const r = (size - stroke) / 2, c = 2 * Math.PI * r, d = Math.max(0, Math.min(100, pct)) / 100 * c;
|
|
@@ -498,14 +712,15 @@ let settingsDraft = {};
|
|
|
498
712
|
let notifyCheck = null; // the notification check under the switch: {state: testing, sent, off, unseen or failed}
|
|
499
713
|
// Settings pages: "home" lists download, wait and keys. settingsOnly: this window was started
|
|
500
714
|
// 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"];
|
|
715
|
+
const SETTINGS_PAGES = ["home", "about", "download", "wait", "keys", "pro", "markdown", "login"];
|
|
502
716
|
// PaperSearch Pro's pages (config/edition.ts): Pro itself (installing it, its version and updates), and
|
|
503
717
|
// each of its features (user, 2026-11-19: the Markdown, the school's sign-in, more to come).
|
|
504
718
|
const PRO_PAGES = ["pro", "markdown", "login"];
|
|
505
|
-
//
|
|
506
|
-
// Pro's own page, under 安装.
|
|
719
|
+
// Pro's features are on the home page, under its title, installed or not (user, 2026-11-19: 铺开; 2026-11-21: C).
|
|
507
720
|
const proInstalled = () => !!(proStatus && proStatus.ok && proStatus.installed) && proInstall.state !== "running";
|
|
508
|
-
const parentPage = (page) => page === "login_schools" ? "login" :
|
|
721
|
+
const parentPage = (page) => page === "login_schools" ? "login" : page === "pro_activate" ? "about" : "home";
|
|
722
|
+
// Pro's page became 关于 PaperSearch (user, 2026-11-21: one version, Pro part of it); asked for by its old name too.
|
|
723
|
+
const pageNamed = (page) => page === "pro" ? "about" : page;
|
|
509
724
|
// The Markdown page is one of PaperSearch Pro's features: the backend says whether this edition has it (edition.py).
|
|
510
725
|
const proOn = () => !settings || settings.pro !== false;
|
|
511
726
|
let settingsPage = "home", settingsNote = "", settingsOnly = false, lastStrip = "";
|
|
@@ -517,14 +732,95 @@ let proStatus = null, proInstall = { state: "idle" }, proInstallTimer = 0;
|
|
|
517
732
|
// The school sign-in page (school_login_state); its error line.
|
|
518
733
|
let schoolLogin = null, loginError = "", loginValues = {}, loginShown = false;
|
|
519
734
|
// The school whose account is open on the page (its entityID), and 添加学校: what was typed, what was found.
|
|
735
|
+
let loginMenu = ""; // the open school's ⋯ menu, open (its key)
|
|
520
736
|
let loginOpen = "", schoolQuery = "", schoolFound = null, schoolFinding = false, confirmForget = "", loginAdding = false;
|
|
521
|
-
//
|
|
522
|
-
|
|
737
|
+
// 测试登录 (school_test.py): the test as the window runs it ({state: idle, running (key, step, phase), done (key, ok,
|
|
738
|
+
// title, detail, seconds)}); the article it opens for the school open ({doi}: "" while none is set), and its box: open
|
|
739
|
+
// or not, what is typed, why it was not taken, a lookup going on; the account as saved (the test uses that: changed
|
|
740
|
+
// fields are saved first).
|
|
741
|
+
// One version and one update (user, 2026-11-21; updates.py): the version this window runs and the one installed now
|
|
742
|
+
// (an update elsewhere: they differ, 重新打开), the check's answer, the update as it goes.
|
|
743
|
+
let versionInfo = { running: "", installed: "" }, versionCheck = { state: "idle" }, updateRun = { state: "idle" };
|
|
744
|
+
let versionTimer = 0, updateTimer = 0;
|
|
745
|
+
const newerVersion = () => versionCheck.state === "done" && !!(versionCheck.update || versionCheck.pro_update) && updateRun.state !== "done";
|
|
746
|
+
async function refreshVersions() {
|
|
747
|
+
try { versionInfo = (await api().versions()) || versionInfo; } catch (error) { /* an older backend: none */ }
|
|
748
|
+
}
|
|
749
|
+
async function checkVersions(again = false) {
|
|
750
|
+
await refreshVersions();
|
|
751
|
+
try { versionCheck = (await api().check_versions(again)) || { state: "idle" }; } catch (error) { return; }
|
|
752
|
+
watchVersions();
|
|
753
|
+
if (panel === "settings") render(true);
|
|
754
|
+
}
|
|
755
|
+
function watchVersions() {
|
|
756
|
+
clearInterval(versionTimer);
|
|
757
|
+
if (versionCheck.state !== "running") return;
|
|
758
|
+
versionTimer = setInterval(async () => {
|
|
759
|
+
let next;
|
|
760
|
+
try { next = await api().versions_state(); } catch (error) { return; }
|
|
761
|
+
versionCheck = next || { state: "idle" };
|
|
762
|
+
if (versionCheck.state === "running") return;
|
|
763
|
+
clearInterval(versionTimer);
|
|
764
|
+
render(true); // the card's dot, the foot's line, the about page
|
|
765
|
+
}, 700);
|
|
766
|
+
}
|
|
767
|
+
// 更新 as it goes: each step, then (PaperSearch itself updated) the window opening again with the new one.
|
|
768
|
+
function watchUpdate() {
|
|
769
|
+
clearInterval(updateTimer);
|
|
770
|
+
if (updateRun.state !== "running") return;
|
|
771
|
+
updateTimer = setInterval(async () => {
|
|
772
|
+
let next;
|
|
773
|
+
try { next = await api().update_state(); } catch (error) { return; }
|
|
774
|
+
const before = JSON.stringify(updateRun);
|
|
775
|
+
updateRun = next || { state: "idle" };
|
|
776
|
+
if (updateRun.state !== "running") {
|
|
777
|
+
clearInterval(updateTimer);
|
|
778
|
+
if (updateRun.state === "done" && updateRun.reopen) {
|
|
779
|
+
render(true);
|
|
780
|
+
try { await api().reopen_window("about"); } catch (error) { /* the window stays; 重新打开 says the rest */ }
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
if (updateRun.state === "done") {
|
|
784
|
+
// Pro alone updated: read again, the page as it is now.
|
|
785
|
+
try { proStatus = await api().pro_status(); } catch (error) { /* as it was */ }
|
|
786
|
+
updateRun = { state: "idle" };
|
|
787
|
+
await checkVersions(true);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (JSON.stringify(updateRun) !== before && panel === "settings") render(true);
|
|
791
|
+
}, 600);
|
|
792
|
+
}
|
|
793
|
+
// Installed elsewhere since this window started (a terminal, an AI tool): said on every settings page, 重新打开.
|
|
794
|
+
const reopenLine = () => versionInfo.installed && versionInfo.running && versionInfo.installed !== versionInfo.running
|
|
795
|
+
&& updateRun.state === "idle" ? '<button type="button" class="reopen-line" data-act="reopen_window">' + icon("refresh")
|
|
796
|
+
+ "<span>" + esc("已更新到 " + versionInfo.installed) + '</span><span class="k">' + esc("重新打开") + "</span></button>" : "";
|
|
797
|
+
let schoolTest = { state: "idle" }, testArticle = null, testArticleFor = null, testTimer = 0, loginSavedValues = {};
|
|
798
|
+
let testEditing = false, testArticleText = "", testArticleError = "", testArticleSaving = false;
|
|
799
|
+
// 支持哪些学校: the list Pro gives, what is typed to narrow it, the regions open, the country whose page is open, its
|
|
800
|
+
// parts open, and where the regions' page was scrolled to, for going back to it.
|
|
801
|
+
let supportList = null, supportFilter = "", supportOpen = "", supportRegions = new Set(), supportParts = new Set(), supportBack = 0;
|
|
802
|
+
// Where the page was scrolled, put back once it is drawn again (user, 2026-11-21: a press on the card's background
|
|
803
|
+
// sent 支持的学校's long list to its top); where a page gone to or back to is to be (pageScroll, its top: 0).
|
|
804
|
+
let keepScroll = null, pageScroll = null;
|
|
805
|
+
const surfaceTop = () => root.querySelector(":scope > .surface")?.scrollTop || 0;
|
|
806
|
+
// What scrolls a row: the nearest box that scrolls its content, else the page.
|
|
807
|
+
function scrollerOf(el) {
|
|
808
|
+
for (let node = el.parentElement; node; node = node.parentElement) {
|
|
809
|
+
if (/(auto|scroll)/.test(getComputedStyle(node).overflowY) && node.scrollHeight > node.clientHeight) return node;
|
|
810
|
+
}
|
|
811
|
+
return document.scrollingElement || document.documentElement;
|
|
812
|
+
}
|
|
523
813
|
// What the last 保存, 清除 or switch did, said under the fields (user, 2026-11-19: 保存 said nothing).
|
|
524
814
|
let loginDone = "";
|
|
525
815
|
// The Save button saying "已保存" a moment once pressed (user, 2026-11-20: not a line below).
|
|
526
816
|
let loginSaved = false, loginSavedTimer = 0;
|
|
527
|
-
let
|
|
817
|
+
let proSitesOpen = false, proMeritsOpen = false;
|
|
818
|
+
// The activation code typed on Pro's page, and why it was not sent (none typed).
|
|
819
|
+
let proCode = "", proCodeError = "";
|
|
820
|
+
// The languages the window speaks, each in its own name, in one menu at the home page's foot (user, 2026-11-21:
|
|
821
|
+
// more to come, 日本語, 한국어, Français among them); whether that menu is open.
|
|
822
|
+
const LANGUAGES = [["zh", "简体中文"], ["zh-Hant", "繁體中文"], ["en", "English"], ["ja", "日本語"], ["ko", "한국어"], ["fr", "Français"]];
|
|
823
|
+
let languageOpen = false;
|
|
528
824
|
let lastHtml = "", hoverTimer = 0, leaveTimer = 0, pollTimer = 0, kinds = [];
|
|
529
825
|
const api = () => window.pywebview.api;
|
|
530
826
|
|
|
@@ -570,7 +866,7 @@ function header(title, sub, closable) {
|
|
|
570
866
|
+ (V.mode === "running" || V.mode === "attention" ? ring(V.pct, 40, 4, V.pct + "%") : "")
|
|
571
867
|
+ '<div class="text"><div class="title">' + esc(title) + '</div>' + (sub ? '<div class="sub">' + esc(sub) + "</div>" : "") + "</div></div>"
|
|
572
868
|
+ '<div class="tools">' + pinButton()
|
|
573
|
-
+ '<button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear") + "</button>"
|
|
869
|
+
+ '<button class="iconbtn' + (newerVersion() ? " has-dot" : "") + '" data-act="settings" aria-label="设置">' + icon("gear") + "</button>"
|
|
574
870
|
+ '<button class="iconbtn" data-act="' + (closable ? "close" : "minimize") + '" aria-label="' + (closable ? "关闭" : "最小化")
|
|
575
871
|
+ '" title="' + (closable ? "关闭" : "最小化到程序坞") + '">' + icon(closable ? "close" : "minimize") + "</button></div></div>";
|
|
576
872
|
}
|
|
@@ -586,13 +882,17 @@ function paperBlock() {
|
|
|
586
882
|
html += note ? "<" + tag + ' class="notice">' + esc(note) + "</" + tag + ">"
|
|
587
883
|
: (v.where ? "<" + tag + ' class="where">' + esc(v.where) + (v.title && v.current ? " · " + esc(v.current) : "") + "</" + tag + ">" : "");
|
|
588
884
|
if (v.browser) html += "</button>";
|
|
885
|
+
// The step or the lane's line in one row of its own height, there when neither is (see .paper-status); a line
|
|
886
|
+
// longer than the row says the rest on hover.
|
|
887
|
+
html += '<div class="paper-status">';
|
|
589
888
|
if (v.step) {
|
|
590
889
|
html += '<div class="steps"><div class="bars">' + v.steps.map((_, i) =>
|
|
591
890
|
"<span" + (i < v.step.index ? ' class="done"' : i === v.step.index ? ' class="now"' : "") + "></span>").join("")
|
|
592
891
|
+ '</div><span class="label">' + esc(v.step.label) + "</span></div>";
|
|
593
892
|
} else if (v.line) {
|
|
594
|
-
html += '<div class="line">' + esc(v.line) + "</div>";
|
|
893
|
+
html += '<div class="line" title="' + esc(v.line) + '">' + esc(v.line) + "</div>";
|
|
595
894
|
}
|
|
895
|
+
html += "</div>";
|
|
596
896
|
// What each lane got (开放下载, 机构下载), on one line.
|
|
597
897
|
return html + "</div>";
|
|
598
898
|
}
|
|
@@ -647,11 +947,11 @@ function heldBlock() {
|
|
|
647
947
|
// The button says 已确认; the line, when they go on.
|
|
648
948
|
const copy = V.held_wait ? "正在继续下载 " + heldCount() + " 篇" : "本篇完成后继续下载 " + heldCount() + " 篇";
|
|
649
949
|
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(
|
|
950
|
+
+ '<div class="names">' + esc(held.map((h) => h.name).join(commaLang() ? ", " : "、")) + "</div></div>";
|
|
651
951
|
}
|
|
652
952
|
return '<div class="held"><div class="head"><span class="copy">' + esc("学校登录中途失败,已暂停 " + heldCount() + " 篇")
|
|
653
953
|
+ '</span><button class="btn" data-act="resume_held">登录并继续</button></div>'
|
|
654
|
-
+ '<div class="names">' + esc(held.map((h) => h.name).join(
|
|
954
|
+
+ '<div class="names">' + esc(held.map((h) => h.name).join(commaLang() ? ", " : "、")) + "</div></div>";
|
|
655
955
|
}
|
|
656
956
|
|
|
657
957
|
// Pages from sites not yet supported this batch: the site (or how many), how their Markdown
|
|
@@ -727,7 +1027,7 @@ function attentionCard() {
|
|
|
727
1027
|
+ '<button type="button" class="prompt attention-target" data-act="show_browser" aria-label="打开下载浏览器">' + icon(a.login ? "lock" : "alert")
|
|
728
1028
|
+ '<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
1029
|
if (panel === "confirm") return html + actionsBlock() + "</div>";
|
|
730
|
-
html += '<div class="actions"><button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear")
|
|
1030
|
+
html += '<div class="actions"><button class="iconbtn' + (newerVersion() ? " has-dot" : "") + '" data-act="settings" aria-label="设置">' + icon("gear")
|
|
731
1031
|
+ '</button><span class="grow"></span>';
|
|
732
1032
|
if (V.actions) {
|
|
733
1033
|
html += '<button class="btn" data-act="skip_item">跳过本篇</button>'
|
|
@@ -736,8 +1036,9 @@ function attentionCard() {
|
|
|
736
1036
|
return html + "</div></div>";
|
|
737
1037
|
}
|
|
738
1038
|
|
|
739
|
-
|
|
740
|
-
|
|
1039
|
+
// The five failure classes by the names PaperSearch gives them everywhere (failureClass.ts, 2026-11-22).
|
|
1040
|
+
const CLASS_TAGS = { no_access: "没权限", user_side: "要你处理", external: "外部原因", unsupported: "暂不支持",
|
|
1041
|
+
unexplained: "原因不明", other: "其他", doubt: "待核对" };
|
|
741
1042
|
let openGroups = null, groupsRun = ""; // null: each reason row as the view opens it
|
|
742
1043
|
// Main-text rows first, then the supplementary files' rows, numbered on.
|
|
743
1044
|
function allGroups() { return V.summary.groups.concat(V.summary.supplement_groups || [], V.summary.markdown_groups || [], V.summary.doubt_groups || []); }
|
|
@@ -891,13 +1192,16 @@ function taskStrip() {
|
|
|
891
1192
|
return "";
|
|
892
1193
|
}
|
|
893
1194
|
|
|
894
|
-
function settingsHead(title) {
|
|
1195
|
+
function settingsHead(title, sub = "设置") {
|
|
1196
|
+
return settingsHeadOnly(title, sub) + reopenLine();
|
|
1197
|
+
}
|
|
1198
|
+
function settingsHeadOnly(title, sub = "设置") {
|
|
895
1199
|
// A window opened just for the settings closes from any page; the home page has nothing to go back to.
|
|
896
1200
|
const closable = settingsOnly && !busy(), home = settingsPage === "home";
|
|
897
1201
|
lastStrip = taskStrip();
|
|
898
1202
|
return '<div class="head">' + (home && closable ? "" : '<button class="iconbtn" data-act="back" aria-label="返回">' + icon("left") + "</button>")
|
|
899
1203
|
+ '<div class="drag capsule-drag-region"><div class="text"><div class="title">' + esc(title) + "</div>"
|
|
900
|
-
+ (home ? "" : '<div class="sub"
|
|
1204
|
+
+ (home || !sub ? "" : '<div class="sub">' + esc(sub) + "</div>") + "</div></div>"
|
|
901
1205
|
+ (closable ? '<button class="iconbtn" data-act="close_settings" aria-label="关闭">' + icon("close") + "</button>" : "")
|
|
902
1206
|
+ '</div><div id="task-strip">' + lastStrip + "</div>";
|
|
903
1207
|
}
|
|
@@ -905,25 +1209,43 @@ function settingsHead(title) {
|
|
|
905
1209
|
const fieldsOn = (page) => settings.fields.filter((f) => (f.page || "wait") === page);
|
|
906
1210
|
const field = (name) => settings.fields.find((f) => f.name === name);
|
|
907
1211
|
|
|
1212
|
+
// The user's own folder as ~ on the home page's line (user, 2026-11-21: /Users/<name>/Downloads and the hourly limit
|
|
1213
|
+
// did not fit one line in English); the download page shows the folder whole.
|
|
1214
|
+
const shortPath = (path) => String(path || "").replace(/^(?:\/Users\/[^/]+|\/home\/[^/]+|[A-Za-z]:\\Users\\[^\\]+)(?=[\/\\]|$)/, "~");
|
|
908
1215
|
function settingsHome() {
|
|
909
1216
|
const hourly = field("hourly"), login = field("login");
|
|
910
1217
|
const rows = [
|
|
911
|
-
["download", "folder", "下载", [settings.download_dir, hourly ? "每家每小时 " + hourly.value + " 篇" : ""]],
|
|
1218
|
+
["download", "folder", "下载", [shortPath(settings.download_dir), hourly ? "每家每小时 " + hourly.value + " 篇" : ""]],
|
|
912
1219
|
["wait", "clock", "等待和提醒", [login ? "登录页 " + login.value + " 秒" : "", "系统通知" + (notifyOn ? "开" : "关")]],
|
|
913
1220
|
["keys", "key", "API key", [apiKeys && apiKeys.ok ? "已填 " + apiKeys.filled + "/" + apiKeys.total : ""]],
|
|
914
1221
|
];
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1222
|
+
const installed = proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
|
|
1223
|
+
// Pro not there: one row of its own, last, to 关于 PaperSearch where it is introduced (user, 2026-11-21: 乙, its
|
|
1224
|
+
// line saying 需要激活); there: its features' rows.
|
|
1225
|
+
const pro = !proOn() ? "" : installed ? proFeatures().map(navRow).join("")
|
|
1226
|
+
: navRow(["about", "pro-app", "PaperSearch", [proActivated() ? "已激活 · 未安装" : proActivation().state === "expired" ? "激活已过期" : "需要激活"], "Pro"]);
|
|
1227
|
+
return settingsHead("设置") + rows.map(navRow).join("") + pro
|
|
1228
|
+
+ '<div class="row home-foot">' + versionLink() + languageMenu() + "</div>"
|
|
920
1229
|
+ (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
|
|
921
1230
|
}
|
|
922
1231
|
|
|
1232
|
+
// The language, at the right of the home page's foot: its own name, and open, the others each in theirs.
|
|
1233
|
+
function languageMenu() {
|
|
1234
|
+
const name = (LANGUAGES.find(([code]) => code === lang) || LANGUAGES[0])[1];
|
|
1235
|
+
return '<span class="lang-wrap"><button type="button" class="lang-btn" data-act="language_menu" aria-haspopup="menu" aria-expanded="'
|
|
1236
|
+
+ languageOpen + '" aria-label="' + esc("语言 · " + name) + '">' + icon("globe") + "<span>" + name + "</span>"
|
|
1237
|
+
+ icon(languageOpen ? "up" : "down") + "</button>"
|
|
1238
|
+
+ (languageOpen ? '<div class="lang-menu" role="menu">' + LANGUAGES.map(([code, own]) => '<button type="button" role="menuitemradio"'
|
|
1239
|
+
+ ' data-act="language" data-lang="' + code + '" aria-checked="' + (code === lang) + '"><span>' + own + "</span>"
|
|
1240
|
+
+ (code === lang ? icon("tick") : "") + "</button>").join("")
|
|
1241
|
+
+ '<div class="lang-more">' + esc("更多语言陆续加入") + "</div></div>" : "") + "</span>";
|
|
1242
|
+
}
|
|
1243
|
+
|
|
923
1244
|
// 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)
|
|
1245
|
+
function navRow([page, glyph, title, sub, badge]) {
|
|
1246
|
+
return '<button type="button" class="nav-row" data-act="settings_page" data-page="' + page + '">' + (glyph === "pro-app" ? appIcon(16, true) : icon(glyph))
|
|
1247
|
+
+ '<span class="nav-text"><span class="nav-title">' + esc(title)
|
|
1248
|
+
+ (badge ? '<span class="pro-pill feature">' + esc(badge) + "</span>" : "") + '</span><span class="nav-sub">'
|
|
927
1249
|
+ esc(sub.filter(Boolean).join(" · ")) + "</span></span>" + icon("right") + "</button>";
|
|
928
1250
|
}
|
|
929
1251
|
|
|
@@ -1006,21 +1328,13 @@ function settingsKeys() {
|
|
|
1006
1328
|
+ "</div>";
|
|
1007
1329
|
}
|
|
1008
1330
|
|
|
1009
|
-
|
|
1010
|
-
//
|
|
1011
|
-
//
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
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
|
-
}
|
|
1331
|
+
|
|
1332
|
+
// PaperSearch Pro's state (user, 2026-11-18, -21): not installed, whether this computer is activated
|
|
1333
|
+
// (src/management/pro/activate.ts: PaperSearch's activation server, its address still to come); installing,
|
|
1334
|
+
// activating first when a code was typed.
|
|
1335
|
+
const proActivation = () => (proStatus && proStatus.activation) || { state: "none", tail: "", until: "" };
|
|
1336
|
+
const proActivated = () => proActivation().state === "active";
|
|
1337
|
+
const proActivating = () => proInstall.state !== "idle" && proInstall.step === "activate";
|
|
1024
1338
|
|
|
1025
1339
|
function proProgress() {
|
|
1026
1340
|
const done = proInstall.done || 0, total = proInstall.total || 0, mb = (bytes) => (bytes / 1048576).toFixed(1);
|
|
@@ -1028,24 +1342,67 @@ function proProgress() {
|
|
|
1028
1342
|
note: total ? "正在下载 " + mb(done) + " / " + mb(total) + " MB" : "正在下载…" };
|
|
1029
1343
|
}
|
|
1030
1344
|
|
|
1345
|
+
// Under Pro's state: the download's progress; installed, 更新到 a newer one; not installed,
|
|
1346
|
+
// 激活 Pro (the activation's own page), or 安装 once activated. No notes beside them (user, 2026-11-21).
|
|
1031
1347
|
function proAction() {
|
|
1032
|
-
const
|
|
1033
|
-
+ '<div class="pro-hint">' + esc(hint) + "</div>";
|
|
1348
|
+
const button = (label) => '<button type="button" class="btn primary" data-act="install_pro">' + esc(label) + "</button>";
|
|
1034
1349
|
if (proInstall.state === "running") {
|
|
1350
|
+
if (proActivating()) return "";
|
|
1035
1351
|
const progress = proProgress();
|
|
1036
1352
|
return '<div class="pro-bar"><span style="width:' + progress.width.toFixed(1) + '%"></span></div>'
|
|
1037
1353
|
+ '<div class="pro-hint" id="pro-progress">' + esc(progress.note) + "</div>";
|
|
1038
1354
|
}
|
|
1039
|
-
if (
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1355
|
+
if (!proStatus || !proStatus.ok) return "";
|
|
1356
|
+
if (proInstall.state === "failed" && (proStatus.installed || proActivated()) && !proActivating()) return button("重试");
|
|
1357
|
+
if (proStatus.installed) {
|
|
1358
|
+
if (proActivation().state === "expired") return proCodeField("重新激活");
|
|
1359
|
+
// Its updates come with PaperSearch's, on the same page (user, 2026-11-21: one version, one button).
|
|
1360
|
+
return "";
|
|
1042
1361
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1362
|
+
return proActivated() ? button("安装")
|
|
1363
|
+
: '<button type="button" class="btn primary" data-act="settings_page" data-page="pro_activate">' + esc("激活 Pro") + "</button>";
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
// The activation code, typed and kept through a redraw; why it was not taken, under it. While the code is sent,
|
|
1367
|
+
// its button says so.
|
|
1368
|
+
function proCodeField(label, sending = false) {
|
|
1369
|
+
const error = proCodeError || (proInstall.state === "failed" && proActivating() ? proInstall.message || "激活出错" : "");
|
|
1370
|
+
return '<div class="pro-code-label">' + esc("激活码") + '</div><div class="pro-code"><input id="pro-code" type="text" autocomplete="off"'
|
|
1371
|
+
+ ' spellcheck="false" value="' + esc(proCode) + '" placeholder="XXXX-XXXX-XXXX" aria-label="' + esc("激活码") + '">'
|
|
1372
|
+
+ '<button type="button" class="btn primary" data-act="activate_pro"' + (sending ? " disabled" : "") + ">"
|
|
1373
|
+
+ esc(sending ? "正在激活…" : label) + "</button></div>"
|
|
1374
|
+
+ (error ? '<div class="err pro-code-err" role="alert">' + esc(error) + "</div>" : "");
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// The activation, a page of its own from Pro's (user, 2026-11-21): the code and 激活; taken, the install's
|
|
1378
|
+
// progress here; installed, the home page, where Pro's features are now. An install that failed after the
|
|
1379
|
+
// activation: why, and 重试.
|
|
1380
|
+
function settingsProActivate() {
|
|
1381
|
+
const installing = proInstall.state === "running" && !proActivating();
|
|
1382
|
+
const failed = proInstall.state === "failed" && !proActivating() && proActivated();
|
|
1383
|
+
const body = installing ? proAction()
|
|
1384
|
+
: failed ? proAction() + '<div class="err pro-code-err" role="alert">' + esc("安装没有完成:" + (proInstall.message || "安装出错")) + "</div>"
|
|
1385
|
+
: proCodeField("激活", proInstall.state === "running");
|
|
1386
|
+
return settingsHead("激活 Pro") + '<div class="pro-action">' + body + "</div>"
|
|
1387
|
+
+ (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
|
|
1045
1388
|
}
|
|
1046
1389
|
|
|
1047
1390
|
// What a Markdown keeps, beside the description.
|
|
1048
1391
|
const PRO_KEEPS = [["photo", "图片"], ["table", "表格"], ["formula", "公式"], ["list", "参考文献"]];
|
|
1392
|
+
// What sets it apart (user, 2026-11-21): a row like the platforms', its three names under the title; opened, each
|
|
1393
|
+
// said in full.
|
|
1394
|
+
const PRO_MERITS = [
|
|
1395
|
+
["file", "出版社原文", "取自出版社网页或 XML,不从 PDF 识别:章节、图注、表格(含合并单元格)和 LaTeX 公式按原文还原,避免识别错误。"],
|
|
1396
|
+
["check", "完整才保存", "图片或表格有缺失就不生成,记为失败并说明原因,后续重试。"],
|
|
1397
|
+
["link", "来源可追溯", "每篇保留出版社原始网页或 XML,以及来源清单:来源地址、DOI 核对结果和获取时间。"],
|
|
1398
|
+
];
|
|
1399
|
+
function proMerits() {
|
|
1400
|
+
return '<button type="button" class="nav-row pro-row" data-act="pro_merits" aria-expanded="' + proMeritsOpen + '">' + icon("shield")
|
|
1401
|
+
+ '<span class="nav-text"><span class="nav-title">' + esc("三项特点") + '</span><span class="nav-sub">'
|
|
1402
|
+
+ esc("出版社原文 · 完整才保存 · 来源可追溯") + "</span></span>" + icon(proMeritsOpen ? "down" : "right") + "</button>"
|
|
1403
|
+
+ (proMeritsOpen ? '<div class="pro-merits">' + PRO_MERITS.map(([glyph, title, said]) => '<div class="pro-merit">' + icon(glyph)
|
|
1404
|
+
+ "<div><b>" + esc(title) + "</b><span>" + esc(said) + "</span></div></div>").join("") + "</div>" : "");
|
|
1405
|
+
}
|
|
1049
1406
|
|
|
1050
1407
|
// The Markdown saved on this computer, how many complete, and the publishers' platforms with rules.
|
|
1051
1408
|
function proStats() {
|
|
@@ -1088,57 +1445,136 @@ function siteGroups(sites) {
|
|
|
1088
1445
|
return groups.filter(([, names]) => names.length);
|
|
1089
1446
|
}
|
|
1090
1447
|
|
|
1091
|
-
//
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
//
|
|
1104
|
-
//
|
|
1448
|
+
// What Pro does now and what is coming (user, 2026-11-21: Zotero, a map of related papers as ResearchRabbit
|
|
1449
|
+
// draws one, and new papers pushed by subscription), on its page, installed or not.
|
|
1450
|
+
const PRO_NOW = [
|
|
1451
|
+
["file", "Markdown 全文", "出版社原文转成 Markdown,图表、公式完整"],
|
|
1452
|
+
["lock", "学校自动登录", "学校登录页自动填写账号,批量下载不用守着"],
|
|
1453
|
+
];
|
|
1454
|
+
const PRO_COMING = [
|
|
1455
|
+
["Zotero 整合", "文献库里缺 PDF 的条目自动补下,挂回原条目"],
|
|
1456
|
+
["文献关系图", "从一篇论文出发,沿引用找相关文献,画成关系图"],
|
|
1457
|
+
// User, 2026-11-21: what each one wants, pushed to them.
|
|
1458
|
+
["文献订阅", "按关注的主题、期刊或作者,定期推送新论文"],
|
|
1459
|
+
];
|
|
1460
|
+
// 使用状态 on Pro's page once installed: activated, its code's last four characters and until when; before the
|
|
1461
|
+
// activation server (none kept), whether Pro is free and until when (Pro's own switch).
|
|
1462
|
+
function proUsage(heading = true) {
|
|
1463
|
+
const activation = proActivation(), access = (proStatus && proStatus.access) || {};
|
|
1464
|
+
const row = (label, value, tone) => '<div class="row pro-use"><span>' + esc(label) + '</span><span class="' + (tone || "dim") + '">'
|
|
1465
|
+
+ esc(value) + "</span></div>";
|
|
1466
|
+
const rows = activation.state !== "none"
|
|
1467
|
+
? row("激活状态", activation.state === "active" ? "已激活" : "已过期", activation.state === "active" ? "ok" : "bad")
|
|
1468
|
+
+ row("激活码", "••••" + activation.tail) + row("有效期", activation.until ? "至 " + activation.until : "不限")
|
|
1469
|
+
: access.mode === "key" ? row("使用方式", "需要激活")
|
|
1470
|
+
: row("使用方式", "测试期间免费") + row("截止日期", access.until || "待定");
|
|
1471
|
+
return (heading ? '<div class="key-group">' + esc("使用状态") + "</div>" : "") + rows;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
// 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
1475
|
function proFeatures() {
|
|
1106
|
-
const
|
|
1107
|
-
const converted = installed ? (proStatus.converted || 0) : 0, sites = installed ? (proStatus.sites || []).length : 0;
|
|
1476
|
+
const converted = proStatus.converted || 0, sites = (proStatus.sites || []).length;
|
|
1108
1477
|
return [
|
|
1109
|
-
["markdown", "file", "Markdown 全文",
|
|
1110
|
-
: ["把论文全文转成 Markdown"]],
|
|
1478
|
+
["markdown", "file", "Markdown 全文", ["已转换 " + converted.toLocaleString("en-US") + " 篇", sites + " 个平台"], "Pro"],
|
|
1111
1479
|
["login", "lock", "学校自动登录", !schoolLogin || !schoolLogin.ok ? [] : !schoolLogin.saved ? ["未填"]
|
|
1112
|
-
: [schoolLogin.enabled ? "已打开" : "已关闭", schoolLogin.username]],
|
|
1480
|
+
: [schoolLogin.enabled ? "已打开" : "已关闭", schoolLogin.username], "Pro"],
|
|
1113
1481
|
];
|
|
1114
1482
|
}
|
|
1115
1483
|
|
|
1116
|
-
//
|
|
1117
|
-
//
|
|
1118
|
-
function
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1484
|
+
// PaperSearch's version at the left of the home page's foot, for everyone, to 关于 PaperSearch (user, 2026-11-21: one
|
|
1485
|
+
// version and one update, Pro with it); a newer one there, the whole line in red saying so (乙).
|
|
1486
|
+
function versionLink() {
|
|
1487
|
+
const update = newerVersion();
|
|
1488
|
+
const said = update ? (versionCheck.update ? "有新版本 " + versionCheck.latest + ",点此更新" : "有新版本,点此更新")
|
|
1489
|
+
: "PaperSearch" + (versionInfo.running ? " " + versionInfo.running : "");
|
|
1490
|
+
// Pro installed: its pill after the version, as on its features' rows (user, 2026-11-22); a newer version's red line alone.
|
|
1491
|
+
const pro = !update && proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
|
|
1492
|
+
return '<button type="button" class="version-link' + (update ? " new" : "") + '" data-act="settings_page" data-page="about">'
|
|
1493
|
+
+ (update ? icon("upcircle") : "") + '<span class="pl-text">' + esc(said) + "</span>"
|
|
1494
|
+
+ (pro ? '<span class="pro-pill">Pro</span>' : "") + "</button>";
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
// A Pro feature's page before Pro is there (user, 2026-11-21: as one not paid for sees it): what it needs, and
|
|
1499
|
+
// the way to Pro's page.
|
|
1500
|
+
function proNeeded() {
|
|
1501
|
+
const activated = proActivated();
|
|
1502
|
+
return '<div class="pro-needed"><span>' + esc(activated ? "安装 PaperSearch Pro 后可用" : "激活 PaperSearch Pro 后可用") + "</span>"
|
|
1503
|
+
+ '<button type="button" class="btn link" data-act="settings_page" data-page="about">' + esc(activated ? "去安装" : "去激活")
|
|
1504
|
+
+ icon("right") + "</button></div>";
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
// 关于 PaperSearch (user, 2026-11-21, as drawn): its icon, name and version, and its update, Pro's with it; then Pro.
|
|
1508
|
+
// Not bought: its features, what is coming (计划中 after each name), 激活 Pro at the foot. Bought: the icon Pro's, Pro
|
|
1509
|
+
// beside the name (the line shifted a little to the right), its state, what is coming, 提交 issue.
|
|
1510
|
+
const UPDATE_STEPS = { paper_search: "PaperSearch", school: "学校订阅下载扩展", skills: "Skill", pro: "Pro" };
|
|
1511
|
+
function versionLine() {
|
|
1512
|
+
const running = versionInfo.running || versionCheck.current || "";
|
|
1513
|
+
const at = (said) => (running ? running + " · " : "") + said;
|
|
1514
|
+
if (updateRun.state === "running" || (updateRun.state === "done" && updateRun.reopen)) {
|
|
1515
|
+
return ["", updateRun.state === "done" ? "正在重新打开…" : updateRun.target ? "正在更新到 " + updateRun.target + "…" : "正在更新…"];
|
|
1122
1516
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1517
|
+
if (updateRun.state === "failed") return ["bad", at(updateRun.message || "更新出错")];
|
|
1518
|
+
if (versionCheck.state === "running") return ["", at("正在检查更新…")];
|
|
1519
|
+
if (versionCheck.state === "failed") return ["bad", at(versionCheck.message || "检查更新出错")];
|
|
1520
|
+
if (newerVersion()) return ["new", at(versionCheck.update ? "有新版本 " + versionCheck.latest : "有新版本")];
|
|
1521
|
+
if (versionCheck.state === "done") return ["", at("已是最新版本")];
|
|
1522
|
+
return ["", running];
|
|
1523
|
+
}
|
|
1524
|
+
function aboutAction() {
|
|
1525
|
+
const steps = updateRun.steps || [];
|
|
1526
|
+
if (updateRun.state === "running" || (updateRun.state === "done" && updateRun.reopen)) {
|
|
1527
|
+
const done = updateRun.state === "done" ? steps.length : updateRun.step || 0;
|
|
1528
|
+
return '<div class="about-action"><div class="pro-bar"><span style="width:' + (steps.length ? (done / steps.length) * 100 : 0).toFixed(1)
|
|
1529
|
+
+ '%"></span></div><ol class="test-steps update-steps">' + steps.map((step, i) => '<li class="' + (i < done ? "done" : i === done ? "now" : "")
|
|
1530
|
+
+ '">' + (i < done ? icon("check") : '<span class="mark"></span>') + "<span>"
|
|
1531
|
+
+ esc(step === "paper_search" && updateRun.target ? "PaperSearch " + updateRun.target : UPDATE_STEPS[step] || step) + "</span></li>").join("")
|
|
1532
|
+
+ "</ol>" + (steps.includes("paper_search") ? '<div class="about-caption">' + esc("完成后窗口会自动重新打开") + "</div>" : "") + "</div>";
|
|
1533
|
+
}
|
|
1534
|
+
if (updateRun.state === "failed") {
|
|
1535
|
+
return '<div class="about-action"><button type="button" class="btn primary" data-act="update_all">' + esc("重试") + "</button></div>";
|
|
1536
|
+
}
|
|
1537
|
+
if (newerVersion()) {
|
|
1538
|
+
const label = versionCheck.update ? "更新到 " + versionCheck.latest : "更新";
|
|
1539
|
+
return '<div class="about-action">' + (busy()
|
|
1540
|
+
? '<button type="button" class="btn primary" disabled>' + esc("下载结束后更新") + "</button>"
|
|
1541
|
+
: '<button type="button" class="btn primary" data-act="update_all">' + esc(label) + "</button>")
|
|
1542
|
+
+ "</div>";
|
|
1543
|
+
}
|
|
1544
|
+
return versionCheck.state === "running" ? "" : '<div class="about-action"><button type="button" class="btn link" data-act="check_versions">'
|
|
1545
|
+
+ esc("检查更新") + "</button></div>";
|
|
1546
|
+
}
|
|
1547
|
+
const aboutFeature = ([title, said], planned) => '<div class="about-feat"><b>' + esc(title) + "</b>"
|
|
1548
|
+
+ (planned ? '<span class="pro-tag">' + esc("计划中") + "</span>" : "") + '<span class="pl-sub">' + esc(said) + "</span></div>";
|
|
1549
|
+
const aboutComing = () => '<div class="about-sub">' + esc("即将推出") + "</div>" + PRO_COMING.map((f) => aboutFeature(f, true)).join("");
|
|
1550
|
+
function settingsAbout() {
|
|
1551
|
+
const installed = proOn() && !!(proStatus && proStatus.ok && proStatus.installed);
|
|
1552
|
+
const [tone, line] = versionLine();
|
|
1553
|
+
// A newer PaperSearch with its notes: 有新版本 X is the link to them, ↗ after it (user, 2026-11-22: 乙).
|
|
1554
|
+
const said = "有新版本 " + versionCheck.latest;
|
|
1555
|
+
const notes = tone === "new" && versionCheck.update && versionCheck.notes && line.endsWith(said);
|
|
1556
|
+
const version = notes ? esc(line.slice(0, -said.length)) + '<button type="button" class="ver-notes" data-act="release_notes">'
|
|
1557
|
+
+ esc(said) + icon("external") + "</button>" : esc(line);
|
|
1558
|
+
const hero = '<div class="about-hero">' + appIcon(56, installed) + '<div class="about-name' + (installed ? " with-pill" : "") + '">PaperSearch'
|
|
1559
|
+
+ (installed ? '<span class="pro-pill">Pro</span>' : "") + '</div><div class="about-version' + (tone ? " " + tone : "") + '" role="status">'
|
|
1560
|
+
+ version + "</div></div>" + aboutAction();
|
|
1561
|
+
let pro = "";
|
|
1562
|
+
if (proOn() && installed) {
|
|
1563
|
+
pro = '<div class="about-gap"></div>' + (proAction() ? '<div class="pro-action">' + proAction() + "</div>" : "") + proUsage(false) + aboutComing()
|
|
1564
|
+
+ '<div class="pro-foot"><span>' + esc("用着有问题?") + "</span>"
|
|
1565
|
+
+ '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>";
|
|
1566
|
+
} else if (proOn()) {
|
|
1567
|
+
const access = (proStatus && proStatus.access) || {};
|
|
1568
|
+
pro = '<div class="about-sec">' + appIcon(20, true) + '<span>PaperSearch</span><span class="pro-pill">Pro</span></div>'
|
|
1569
|
+
+ PRO_NOW.map(([, title, said]) => aboutFeature([title, said], false)).join("") + aboutComing()
|
|
1570
|
+
+ '<div class="pro-action pro-activate">' + proAction() + "</div>"
|
|
1571
|
+
// An install that did not finish says why under its 重试 (the activation's own page says it too).
|
|
1572
|
+
+ (proInstall.state === "failed" && !proActivating() && proActivated() ? '<div class="err pro-code-err" role="alert">'
|
|
1573
|
+
+ esc("安装没有完成:" + (proInstall.message || "安装出错")) + "</div>" : "")
|
|
1574
|
+
+ (proInstall.state !== "running" && access.mode !== "key" && !proActivated() ? '<div class="about-caption">' + esc("测试期间免费") + "</div>" : "");
|
|
1575
|
+
}
|
|
1576
|
+
// Its head says 设置 alone: the name is the page's own, under the icon (user, 2026-11-21).
|
|
1577
|
+
return settingsHead("设置", "") + hero + pro
|
|
1142
1578
|
+ (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
|
|
1143
1579
|
}
|
|
1144
1580
|
|
|
@@ -1148,9 +1584,10 @@ function settingsMarkdown() {
|
|
|
1148
1584
|
return settingsHead("Markdown 全文")
|
|
1149
1585
|
+ '<div class="pro-desc">' + esc("把论文全文转成 Markdown,以下内容一并保留:") + "</div>"
|
|
1150
1586
|
+ '<div class="pro-chips">' + PRO_KEEPS.map(([glyph, text]) => '<span class="pro-chip">' + icon(glyph) + esc(text) + "</span>").join("") + "</div>"
|
|
1151
|
-
+ (installed ? proStats() +
|
|
1152
|
-
|
|
1153
|
-
|
|
1587
|
+
+ (installed ? proStats() + proMerits() + proSites()
|
|
1588
|
+
+ '<div class="pro-foot"><span>' + esc("转换有缺漏、出错,或想加出版社?") + "</span>"
|
|
1589
|
+
+ '<button type="button" class="btn link" data-act="pro_issue">' + esc("提交 issue") + icon("right") + "</button></div>"
|
|
1590
|
+
: proMerits() + proNeeded())
|
|
1154
1591
|
+ (settingsNote ? '<div class="settings-note" role="status">' + esc(settingsNote) + "</div>" : "");
|
|
1155
1592
|
}
|
|
1156
1593
|
|
|
@@ -1168,21 +1605,100 @@ function tagHtml(status) {
|
|
|
1168
1605
|
const [cls, text] = schoolTag(status);
|
|
1169
1606
|
return '<span class="tag ' + cls + '">' + esc(text) + "</span>";
|
|
1170
1607
|
}
|
|
1171
|
-
|
|
1608
|
+
// A school's name in the window's language (user, 2026-11-21): in English its English name; in another its name in
|
|
1609
|
+
// that language where Pro has one (Wikidata's), in Traditional Chinese else its Chinese one (tr() turns its
|
|
1610
|
+
// characters); else its own name as its federation lists it, not a translation.
|
|
1611
|
+
function schoolName(s) {
|
|
1612
|
+
const names = s.names || {};
|
|
1613
|
+
if (lang === "en") return s.name_en || s.name || s.key;
|
|
1614
|
+
return names[lang] || (lang === "zh-Hant" ? names.zh : "") || s.name || s.name_en || s.key;
|
|
1615
|
+
}
|
|
1172
1616
|
|
|
1173
1617
|
async function loadLoginValues() {
|
|
1174
1618
|
try { loginValues = (await api().school_login_saved(loginOpen)) || {}; } catch (error) { loginValues = {}; }
|
|
1619
|
+
loginSavedValues = { ...loginValues };
|
|
1620
|
+
// 测试登录's article for the school open, and a test going on when the page was left.
|
|
1621
|
+
if (testArticleFor !== loginOpen) {
|
|
1622
|
+
testArticleFor = loginOpen; testArticle = null; testEditing = false; testArticleError = ""; testArticleText = "";
|
|
1623
|
+
try {
|
|
1624
|
+
const answer = await api().school_test_article(loginOpen);
|
|
1625
|
+
if (answer && answer.ok) testArticle = answer;
|
|
1626
|
+
} catch (error) { testArticle = null; }
|
|
1627
|
+
}
|
|
1628
|
+
try { schoolTest = (await api().school_test_state()) || { state: "idle" }; } catch (error) { schoolTest = { state: "idle" }; }
|
|
1629
|
+
if (schoolTest.state === "running") watchSchoolTest();
|
|
1175
1630
|
}
|
|
1176
1631
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1632
|
+
// While a test runs, how it goes is asked for each second; the page is drawn again as its step or line changes.
|
|
1633
|
+
function watchSchoolTest() {
|
|
1634
|
+
clearInterval(testTimer);
|
|
1635
|
+
testTimer = setInterval(async () => {
|
|
1636
|
+
let next;
|
|
1637
|
+
try { next = await api().school_test_state(); } catch (error) { return; }
|
|
1638
|
+
const before = JSON.stringify(schoolTest);
|
|
1639
|
+
schoolTest = next || { state: "idle" };
|
|
1640
|
+
if (schoolTest.state !== "running") {
|
|
1641
|
+
clearInterval(testTimer);
|
|
1642
|
+
// The school's account may have been turned off (a password the school refused).
|
|
1643
|
+
try { const state = await api().school_login_state(); if (state && state.ok) schoolLogin = state; } catch (error) { /* as it was */ }
|
|
1644
|
+
}
|
|
1645
|
+
if (JSON.stringify(schoolTest) !== before && panel === "settings" && settingsPage === "login") render(true);
|
|
1646
|
+
}, 1000);
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// 测试登录 going on (user, 2026-11-21, as drawn): its steps, the one it is at and what the download says there; 停止测试.
|
|
1650
|
+
const TEST_STEPS = ["打开文章页", "学校登录", "下载全文", "核对 PDF"];
|
|
1651
|
+
function loginTesting(t) {
|
|
1652
|
+
return '<div class="login-test" role="status"><ol class="test-steps">' + TEST_STEPS.map((label, i) =>
|
|
1653
|
+
'<li class="' + (i < t.step ? "done" : i === t.step ? "now" : "") + '">' + (i < t.step ? icon("check") : '<span class="mark"></span>')
|
|
1654
|
+
+ "<span>" + esc(label) + "</span></li>").join("") + "</ol>"
|
|
1655
|
+
+ '<div class="test-phase">' + esc(t.stopping ? "正在停止…" : t.phase || "") + "</div>"
|
|
1656
|
+
+ '<div class="key-actions"><span class="grow"></span><button class="btn" data-act="school_test_stop"' + (t.stopping ? " disabled" : "")
|
|
1657
|
+
+ ">" + esc("停止测试") + "</button></div></div>";
|
|
1658
|
+
}
|
|
1659
|
+
// Before and after: how the last test of this school went, and the article the next opens, set by the user (user,
|
|
1660
|
+
// 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
|
|
1661
|
+
// saying what to do and 填写), the test's own button 测试 at its end (甲: beside its article, so that it says what it
|
|
1662
|
+
// tests). 文章 beside 账号 and 密码, two characters each; its line ends where their boxes end.
|
|
1663
|
+
function loginTest(s) {
|
|
1664
|
+
if (!testArticle) return "";
|
|
1665
|
+
const label = testArticle.doi || testEditing ? '<span class="lbl">' + esc("测试文章") + "</span>" : "";
|
|
1666
|
+
const t = schoolTest.state === "done" && schoolTest.key === s.key ? schoolTest : null;
|
|
1667
|
+
const result = t ? '<div class="test-result ' + (t.ok ? "ok" : "bad") + '" role="status">' + icon(t.ok ? "check" : "alert")
|
|
1668
|
+
+ '<div><div class="t">' + esc(t.title) + "</div>" + (t.detail ? '<div class="d">' + esc(t.detail) + "</div>" : "")
|
|
1669
|
+
+ (t.ok ? '<div class="d">' + esc("用时 " + t.seconds + " 秒 · 测试下的 PDF 已删掉") + "</div>" : "") + "</div></div>" : "";
|
|
1670
|
+
// Also for a school whose account is not saved yet: 测试 saves what is typed first.
|
|
1671
|
+
const test = '<button class="btn test-btn" data-act="school_test">' + esc("测试") + "</button>";
|
|
1672
|
+
if (testEditing) {
|
|
1673
|
+
return result + '<div class="test-article">' + label + '<span class="test-edit">'
|
|
1674
|
+
+ '<input id="test-article" type="text" autocomplete="off" spellcheck="false" value="' + esc(testArticleText)
|
|
1675
|
+
+ '" placeholder="' + esc("DOI 或文章网址") + '" aria-label="' + esc("测试文章") + '">'
|
|
1676
|
+
+ '<button type="button" class="link-btn" data-act="test_article_save"' + (testArticleSaving ? " disabled" : "") + ">"
|
|
1677
|
+
+ esc(testArticleSaving ? "查找中…" : "确定") + "</button></span>" + test + "</div>"
|
|
1678
|
+
+ (testArticleError ? '<div class="err test-err" role="status">' + esc(testArticleError) + "</div>" : "");
|
|
1679
|
+
}
|
|
1680
|
+
const doi = testArticle.doi;
|
|
1681
|
+
return result + '<div class="test-article">' + label + '<span class="what' + (doi ? "" : " empty") + '"' + (doi ? ' title="' + esc(doi) + '"' : "")
|
|
1682
|
+
+ ">" + esc(doi || "填入学校订阅文章 DOI 或网址") + "</span>"
|
|
1683
|
+
+ (doi ? '<button type="button" class="link-btn edit" data-act="test_article_edit" aria-label="' + esc("修改") + '">' + icon("edit") + "</button>"
|
|
1684
|
+
: '<button type="button" class="link-btn" data-act="test_article_edit">' + esc("填写") + "</button>") + test + "</div>";
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
function loginSchool(s, index) {
|
|
1688
|
+
const shown = loginOpen === s.key, items = loginMenuItems(s);
|
|
1689
|
+
// Their order, where there is more than one (user, 2026-11-21: 没权限时换下一所学校 goes down it; 1 the default).
|
|
1690
|
+
const many = ((schoolLogin && schoolLogin.schools) || []).length > 1;
|
|
1179
1691
|
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>"
|
|
1692
|
+
+ (many ? '<span class="ls-n">' + (index + 1) + "</span>" : "") + '<span class="ls-name">' + esc(schoolName(s)) + "</span>"
|
|
1181
1693
|
+ (s.current ? '<span class="tag default">' + esc("默认") + "</span>" : "") + tagHtml(s.status)
|
|
1182
|
-
+ '<span class="ls-
|
|
1694
|
+
+ (shown ? '<span class="ls-end' + (items.length ? " with-menu" : "") + '"></span>'
|
|
1695
|
+
: '<span class="ls-acct">' + esc(s.saved ? (s.enabled ? s.username : "已关闭") : "未填账号") + "</span>")
|
|
1183
1696
|
+ icon(shown ? "down" : "right") + "</button>";
|
|
1184
1697
|
if (!shown) return '<div class="login-school">' + row + "</div>";
|
|
1185
|
-
return '<div class="login-school">' + row
|
|
1698
|
+
if (schoolTest.state === "running" && schoolTest.key === s.key) return '<div class="login-school open">' + row + loginTesting(schoolTest) + "</div>";
|
|
1699
|
+
const menu = !items.length ? "" : '<button type="button" class="iconbtn ls-dots" data-act="login_menu" aria-label="' + esc("更多操作") + '" aria-expanded="'
|
|
1700
|
+
+ (loginMenu === s.key) + '">' + icon("dots") + "</button>" + (loginMenu === s.key ? '<div class="ls-menu" role="menu">' + items.join("") + "</div>" : "");
|
|
1701
|
+
return '<div class="login-school open">' + row + menu
|
|
1186
1702
|
+ (s.off === "rejected" ? '<div class="err" style="text-align:left;margin:0 0 8px">'
|
|
1187
1703
|
+ esc("学校没有接受保存的密码,自动登录已关闭;更新密码后保存,就会重新打开") + "</div>" : "")
|
|
1188
1704
|
+ '<div class="login-form">'
|
|
@@ -1195,23 +1711,34 @@ function loginSchool(s) {
|
|
|
1195
1711
|
+ icon("eye") + "</button></span>"
|
|
1196
1712
|
// 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
1713
|
+ '<div class="err' + (loginError ? "" : " ok") + '" id="login-error" role="status">' + esc(loginError || loginDone) + "</div>"
|
|
1198
|
-
+
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1714
|
+
+ loginTest(s) + loginFoot(s) + "</div></div>";
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// ⋯, the same for every school: set it as the default (not the default already), clear its account and password (saved
|
|
1718
|
+
// ones), remove it (not the default: another is made the default first); the last two asked again in place (loginFoot).
|
|
1719
|
+
function loginMenuItems(s) {
|
|
1720
|
+
const items = [];
|
|
1721
|
+
if (!s.current) items.push('<button type="button" role="menuitem" data-act="set_default" data-key="' + esc(s.key) + '">' + esc("设为默认") + "</button>");
|
|
1722
|
+
if (s.saved) items.push('<button type="button" role="menuitem" class="danger" data-act="clear_login">' + esc("清除账号密码") + "</button>");
|
|
1723
|
+
if (!s.current) items.push('<button type="button" role="menuitem" class="danger" data-act="forget_school" data-key="' + esc(s.key) + '">'
|
|
1724
|
+
+ esc("移除这所学校") + "</button>");
|
|
1725
|
+
return items;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
// The card's last line: 自动登录's switch (a saved account) and 保存; while a clearing or a removal is asked, that question
|
|
1729
|
+
// in its place, the same height (user, 2026-11-22: the old confirmation moved the page down).
|
|
1730
|
+
function loginFoot(s) {
|
|
1731
|
+
const forget = confirmForget === s.key;
|
|
1732
|
+
if (forget || confirmClear === "login") {
|
|
1733
|
+
return '<div class="login-foot asking" role="alert"><span class="q">' + esc(forget ? "移除这所学校?" : "清除账号和密码?") + '</span><span class="grow"></span>'
|
|
1734
|
+
+ '<button type="button" class="btn" data-act="cancel_confirm">' + esc("取消") + "</button>"
|
|
1735
|
+
+ (forget ? '<button type="button" class="btn danger" data-act="forget_school" data-key="' + esc(s.key) + '">' + esc("移除") + "</button>"
|
|
1736
|
+
: '<button type="button" class="btn danger" data-act="clear_login">' + esc("清除") + "</button>") + "</div>";
|
|
1737
|
+
}
|
|
1738
|
+
return '<div class="login-foot">' + (s.saved ? "<span>" + esc("自动登录") + '</span><button type="button" class="switch' + (s.enabled ? " on" : "")
|
|
1739
|
+
+ '" data-act="login_switch" role="switch" aria-checked="' + !!s.enabled + '" aria-label="' + esc("自动登录") + '"></button>' : "")
|
|
1740
|
+
+ '<span class="grow"></span><button type="button" class="btn primary" data-act="save_login">'
|
|
1741
|
+
+ (loginSaved ? icon("check") + esc("已保存") : esc("保存")) + "</button></div>";
|
|
1215
1742
|
}
|
|
1216
1743
|
|
|
1217
1744
|
function loginFound() {
|
|
@@ -1228,61 +1755,162 @@ function loginFound() {
|
|
|
1228
1755
|
function settingsLogin() {
|
|
1229
1756
|
const s = schoolLogin, head = settingsHead("学校自动登录");
|
|
1230
1757
|
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="
|
|
1758
|
+
if (!s.pro) return head + '<div class="pro-desc">' + esc("学校登录页自动填写账号和密码,批量下载不用守着。") + "</div>" + proNeeded();
|
|
1232
1759
|
// 添加学校 a row like the schools', opened to its search (user, 2026-11-20: a box alone said nothing).
|
|
1233
|
-
return head + '<div
|
|
1234
|
-
+ '<div class="login-school"><button type="button" class="login-row login-add-row" data-act="login_add" aria-expanded="' + loginAdding + '">'
|
|
1760
|
+
return head + '<div class="login-list">' + (s.schools || []).map(loginSchool).join("")
|
|
1761
|
+
+ '<div class="login-school add"><button type="button" class="login-row login-add-row" data-act="login_add" aria-expanded="' + loginAdding + '">'
|
|
1235
1762
|
+ icon("plus") + '<span class="ls-name">' + esc("添加学校") + "</span>" + icon(loginAdding ? "down" : "right") + "</button>"
|
|
1236
1763
|
+ (loginAdding ? '<div class="login-add"><div class="login-find"><input id="school-query" type="text" autocomplete="off" spellcheck="false" value="'
|
|
1237
1764
|
+ esc(schoolQuery) + '" placeholder="' + esc("中文名、英文名或学校网址") + '" aria-label="' + esc("学校名称") + '">'
|
|
1238
1765
|
+ '<button class="btn" data-act="find_school">' + esc("查找") + "</button></div>" + loginFound() + "</div>" : "")
|
|
1239
1766
|
+ "</div></div>"
|
|
1767
|
+
// 没权限时换下一所学校 (user, 2026-11-21; school_switch.py): one row, its switch at its right, on by default; there
|
|
1768
|
+
// with more than one school only.
|
|
1769
|
+
+ ((s.schools || []).length > 1 ? '<div class="row switch-row"><span>' + esc("没权限时换下一所学校") + "</span>"
|
|
1770
|
+
+ '<button class="switch' + (s.switch !== false ? " on" : "") + '" data-act="school_switch" role="switch" aria-checked="'
|
|
1771
|
+
+ (s.switch !== false) + '" aria-label="' + esc("没权限时换下一所学校") + '"></button></div>' : "")
|
|
1240
1772
|
// How many schools and which, on a page of their own (user, 2026-11-20: a link, not a line of numbers).
|
|
1241
1773
|
+ '<div class="login-more"><button type="button" class="btn link" data-act="settings_page" data-page="login_schools">'
|
|
1242
1774
|
+ esc("支持哪些学校") + icon("right") + "</button></div>";
|
|
1243
1775
|
}
|
|
1244
1776
|
|
|
1245
|
-
// 支持哪些学校: the schools Pro knows, how many of each kind, in
|
|
1246
|
-
//
|
|
1247
|
-
//
|
|
1248
|
-
|
|
1249
|
-
|
|
1777
|
+
// 支持哪些学校: the schools Pro knows, how many of each kind, in two pages (user, 2026-11-21): the world's regions, each
|
|
1778
|
+
// opening in place to its countries (several may be open), and a country's schools on a page of their own (nested in one
|
|
1779
|
+
// list, they would not fit the window; a page for the regions' countries too was a level too many). On a big country's
|
|
1780
|
+
// page its parts open in place the same way (user, 2026-11-21, 甲): China's provinces, then Hong Kong, Macao and Taiwan;
|
|
1781
|
+
// 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
|
|
1782
|
+
// listed whole. Asia first and China first in it. The page's head (back, title, search) stays on top while its list
|
|
1783
|
+
// scrolls; a long name wraps. What is typed narrows the page's own country, or all; a province's or state's name finds
|
|
1784
|
+
// its schools. Each school with what Pro does for it.
|
|
1785
|
+
const SUPPORT_REGIONS = ["亚洲", "欧洲", "北美洲", "南美洲", "非洲", "大洋洲", "其他"];
|
|
1786
|
+
const CHINA_PLACES = ["香港", "澳门", "台湾"];
|
|
1787
|
+
// Each country the school lists name, by its region; one not here is listed under 其他 (Pro's tests check the lists
|
|
1788
|
+
// against this table).
|
|
1789
|
+
const SUPPORT_COUNTRIES = {
|
|
1790
|
+
"亚洲": "以色列 伊朗 卡塔尔 印度 印度尼西亚 哈萨克斯坦 土耳其 塞浦路斯 孟加拉国 巴基斯坦 巴林 斯里兰卡 新加坡 日本 沙特阿拉伯 泰国 科威特 约旦 菲律宾 越南 阿塞拜疆 阿曼 阿联酋 韩国 马来西亚 黎巴嫩 老挝 文莱",
|
|
1791
|
+
"欧洲": "丹麦 乌克兰 保加利亚 克罗地亚 冰岛 匈牙利 北马其顿 卢森堡 塞尔维亚 奥地利 希腊 德国 意大利 拉脱维亚 挪威 捷克 摩尔多瓦 斯洛伐克 斯洛文尼亚 比利时 法国 波兰 爱尔兰 爱沙尼亚 瑞典 瑞士 白俄罗斯 立陶宛 罗马尼亚 芬兰 英国 荷兰 葡萄牙 西班牙 阿尔巴尼亚 马耳他 黑山 安道尔 马恩岛 法罗群岛",
|
|
1792
|
+
"北美洲": "加拿大 哥斯达黎加 墨西哥 多米尼加 安圭拉 巴巴多斯 巴拿马 洪都拉斯 牙买加 特立尼达和多巴哥 美国 危地马拉 圣基茨和尼维斯",
|
|
1793
|
+
"南美洲": "乌拉圭 厄瓜多尔 哥伦比亚 巴西 智利 秘鲁 阿根廷",
|
|
1794
|
+
"非洲": "乌干达 加纳 南非 博茨瓦纳 坦桑尼亚 埃及 多哥 安哥拉 尼日利亚 布基纳法索 摩洛哥 肯尼亚 苏丹 赞比亚 马拉维 马里 阿尔及利亚 埃塞俄比亚 卢旺达 莱索托 埃斯瓦蒂尼 利比里亚 塞舌尔",
|
|
1795
|
+
"大洋洲": "新西兰 澳大利亚 斐济"
|
|
1796
|
+
};
|
|
1797
|
+
const REGION_OF = Object.fromEntries(Object.entries(SUPPORT_COUNTRIES).flatMap(([region, names]) =>
|
|
1798
|
+
names.split(" ").map((name) => [name, region])));
|
|
1799
|
+
const inChina = (s) => s.country === "中国" || CHINA_PLACES.includes(s.country);
|
|
1800
|
+
function supportRegion(s) {
|
|
1801
|
+
return inChina(s) ? "亚洲" : REGION_OF[s.country] || "其他";
|
|
1250
1802
|
}
|
|
1251
|
-
function
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1803
|
+
function supportGroup(s) {
|
|
1804
|
+
return inChina(s) ? "中国" : s.country || "国家未注明";
|
|
1805
|
+
}
|
|
1806
|
+
// A country's part: a mainland school's province (Hong Kong, Macao and Taiwan their own), a US school's state or a UK
|
|
1807
|
+
// one's nation where Pro names them, else its kind for a country of more schools than BIG_COUNTRY (Germany's 382:
|
|
1808
|
+
// user, 2026-11-21, by kind until Pro names its states); "" for a country listed whole.
|
|
1809
|
+
const BIG_COUNTRY = 350;
|
|
1810
|
+
const KIND_ORDER = ["大学", "研究机构", "医院", "其他"];
|
|
1811
|
+
const UNSTATED = ["未注明省份", "未注明州", "未注明地区", "国家未注明"];
|
|
1812
|
+
function supportPartOf(country, list) {
|
|
1813
|
+
if (country === "中国") return (s) => s.country === "中国" ? s.province || "未注明省份" : s.country;
|
|
1814
|
+
if (list.some((s) => s.area)) return (s) => s.area || (country === "美国" ? "未注明州" : "未注明地区");
|
|
1815
|
+
if (list.length > BIG_COUNTRY && list.some((s) => s.kind)) return (s) => KIND_ORDER.includes(s.kind) ? s.kind : "其他";
|
|
1816
|
+
return null;
|
|
1817
|
+
}
|
|
1818
|
+
// China first; the most schools first; Hong Kong, Macao and Taiwan after the provinces; a kind in KIND_ORDER's order;
|
|
1819
|
+
// a place not given last.
|
|
1820
|
+
function supportOrder(entries) {
|
|
1821
|
+
const rank = (name) => name === "中国" ? -1 : CHINA_PLACES.includes(name) ? 1 : UNSTATED.includes(name) ? 2 : 0;
|
|
1822
|
+
const kinds = entries.every(([name]) => KIND_ORDER.includes(name));
|
|
1823
|
+
return entries.sort((a, b) => (rank(a[0]) - rank(b[0]))
|
|
1824
|
+
|| (kinds ? KIND_ORDER.indexOf(a[0]) - KIND_ORDER.indexOf(b[0]) : b[1].length - a[1].length));
|
|
1825
|
+
}
|
|
1826
|
+
function groupBy(list, key) {
|
|
1827
|
+
const groups = new Map();
|
|
1828
|
+
for (const s of list) groups.set(key(s), [...(groups.get(key(s)) || []), s]);
|
|
1829
|
+
return supportOrder([...groups.entries()]);
|
|
1830
|
+
}
|
|
1831
|
+
function supportRows(list, where = null) {
|
|
1832
|
+
// Its name in the window's language (schoolName), wrapped when long; found by a search, where it is beside it (its
|
|
1833
|
+
// country, or its part of the country open).
|
|
1834
|
+
return list.map((s) => '<div class="login-found"><span class="ls-name">' + esc(schoolName(s))
|
|
1835
|
+
+ (where && where(s) ? '<span class="ls-fed"> · ' + esc(where(s)) + "</span>" : "") + "</span>" + tagHtml(s.status) + "</div>").join("");
|
|
1836
|
+
}
|
|
1837
|
+
function supportRow(act, key, count, open) {
|
|
1838
|
+
return '<button type="button" class="row" data-act="' + act + '" data-key="' + esc(key) + '"'
|
|
1839
|
+
+ (open === undefined ? "" : ' aria-expanded="' + open + '"') + '>'
|
|
1840
|
+
+ '<span class="reason">' + esc(key) + '</span><span class="n">' + count + "</span>" + icon(open ? "down" : "right") + "</button>";
|
|
1841
|
+
}
|
|
1842
|
+
// A school in two federations (its country's and OpenAthens: a university of Beijing's listed twice; 91 such in Chinese,
|
|
1843
|
+
// 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
|
|
1844
|
+
// two. Counted once in the numbers too.
|
|
1845
|
+
const STATUS_RANK = { verified: 0, surveyed: 0, trial: 1, check: 2 };
|
|
1846
|
+
let supportOnce = { list: null, lang: "", schools: [] };
|
|
1847
|
+
function supportSchools() {
|
|
1848
|
+
const listed = (supportList && supportList.schools) || [];
|
|
1849
|
+
if (supportOnce.list !== listed || supportOnce.lang !== lang) {
|
|
1850
|
+
const kept = new Map(), rank = (s) => STATUS_RANK[s.status] ?? 3;
|
|
1851
|
+
for (const s of listed) {
|
|
1852
|
+
const key = s.country + "\n" + schoolName(s), there = kept.get(key);
|
|
1853
|
+
if (!there || rank(s) < rank(there)) kept.set(key, s);
|
|
1854
|
+
}
|
|
1855
|
+
supportOnce = { list: listed, lang, schools: [...kept.values()] };
|
|
1856
|
+
}
|
|
1857
|
+
return supportOnce.schools;
|
|
1858
|
+
}
|
|
1859
|
+
// The schools of the page open: a country's, by their names as the window shows them, in its language's order (pinyin
|
|
1860
|
+
// in Chinese, strokes in Traditional Chinese; China's mainland first, then Hong Kong, Macao and Taiwan), or all.
|
|
1861
|
+
function supportHere() {
|
|
1862
|
+
const all = supportSchools();
|
|
1863
|
+
if (!supportOpen) return all;
|
|
1864
|
+
let order;
|
|
1865
|
+
try { order = new Intl.Collator(lang); } catch (error) { order = new Intl.Collator(); }
|
|
1866
|
+
const place = (s) => supportOpen === "中国" ? CHINA_PLACES.indexOf(s.country) : 0;
|
|
1867
|
+
return all.filter((s) => supportGroup(s) === supportOpen).map((s) => [place(s), schoolName(s), s])
|
|
1868
|
+
.sort((a, b) => a[0] - b[0] || order.compare(a[1], b[1])).map(([, , s]) => s);
|
|
1255
1869
|
}
|
|
1256
1870
|
function supportListHtml() {
|
|
1257
|
-
const
|
|
1258
|
-
const wanted = supportFilter.trim().toLowerCase();
|
|
1871
|
+
const here = supportHere(), wanted = supportFilter.trim().toLowerCase();
|
|
1259
1872
|
if (wanted) {
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1873
|
+
// Found by any of its names, whatever the window's language, or its province's, state's or country's.
|
|
1874
|
+
const said = (s) => [s.name, s.name_en, ...Object.values(s.names || {}), s.province, s.area, s.country, tr(s.province || ""),
|
|
1875
|
+
tr(s.area || ""), tr(s.country || "")].join(" ").toLowerCase();
|
|
1876
|
+
const found = here.filter((s) => said(s).includes(wanted));
|
|
1877
|
+
const where = supportOpen ? supportPartOf(supportOpen, here) : (s) => s.country;
|
|
1878
|
+
return found.length ? supportRows(found.slice(0, 200), where) : '<div class="key-note">' + esc("没有符合的学校") + "</div>";
|
|
1879
|
+
}
|
|
1880
|
+
if (supportOpen) {
|
|
1881
|
+
// A big country's parts, each opening in place to its schools (several may be open), as the regions do.
|
|
1882
|
+
const part = supportPartOf(supportOpen, here);
|
|
1883
|
+
if (!part) return supportRows(here);
|
|
1884
|
+
return groupBy(here, part).map(([key, there]) => {
|
|
1885
|
+
const open = supportParts.has(key);
|
|
1886
|
+
return '<div class="support-region">' + supportRow("support_part", key, there.length, open)
|
|
1887
|
+
+ (open ? '<div class="support-countries">' + supportRows(there) + "</div>" : "") + "</div>";
|
|
1888
|
+
}).join("");
|
|
1263
1889
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}).join("");
|
|
1890
|
+
return SUPPORT_REGIONS.map((region) => [region, here.filter((s) => supportRegion(s) === region)]).filter(([, list]) => list.length)
|
|
1891
|
+
.map(([region, list]) => {
|
|
1892
|
+
const open = supportRegions.has(region);
|
|
1893
|
+
return '<div class="support-region">' + supportRow("support_region", region, list.length, open)
|
|
1894
|
+
+ (open ? '<div class="support-countries">' + groupBy(list, supportGroup)
|
|
1895
|
+
.map(([key, there]) => supportRow("support_group", key, there.length)).join("") + "</div>" : "") + "</div>";
|
|
1896
|
+
}).join("");
|
|
1272
1897
|
}
|
|
1273
1898
|
function settingsLoginSchools() {
|
|
1274
|
-
const
|
|
1899
|
+
const here = supportList && supportList.ok ? supportHere() : [];
|
|
1900
|
+
const head = settingsHead(supportOpen || "支持的学校", supportOpen ? here.length + " 所" : "设置");
|
|
1275
1901
|
if (!supportList) return head + '<div class="key-note">' + esc("读取中…") + "</div>";
|
|
1276
1902
|
if (!supportList.ok) return head + '<div class="err" style="text-align:left">' + esc(supportList.error || "读取失败") + "</div>";
|
|
1277
|
-
const all =
|
|
1903
|
+
const all = supportSchools();
|
|
1278
1904
|
const filled = all.filter((s) => s.status === "surveyed" || s.status === "verified").length;
|
|
1279
1905
|
const check = all.filter((s) => s.status === "check").length;
|
|
1280
|
-
//
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
+
|
|
1284
|
-
|
|
1285
|
-
|
|
1906
|
+
// The numbers, each saying what it counts, on the first page only; the line explaining them was removed (user,
|
|
1907
|
+
// 2026-11-21).
|
|
1908
|
+
const stats = supportOpen ? "" : '<div class="stats" style="margin-top:10px"><div><b>' + filled + "</b><span>" + esc("所学校自动填写账号密码")
|
|
1909
|
+
+ "</span></div><div><b>" + check + "</b><span>" + esc("所学校需自己登录") + "</span></div></div>";
|
|
1910
|
+
const hint = supportOpen ? "搜索学校" : "搜索学校或地区";
|
|
1911
|
+
return '<div class="support-top">' + head + stats
|
|
1912
|
+
+ '<label class="support-search">' + icon("search") + '<input id="support-filter" type="search" autocomplete="off" spellcheck="false" value="'
|
|
1913
|
+
+ esc(supportFilter) + '" placeholder="' + esc(hint) + '" aria-label="' + esc(hint) + '"></label></div>'
|
|
1286
1914
|
+ '<div id="support-list">' + supportListHtml() + "</div>";
|
|
1287
1915
|
}
|
|
1288
1916
|
|
|
@@ -1295,35 +1923,28 @@ function watchProInstall() {
|
|
|
1295
1923
|
let next;
|
|
1296
1924
|
try { next = await api().pro_install_state(); } catch (error) { return; }
|
|
1297
1925
|
proInstall = next || { state: "idle" };
|
|
1298
|
-
if (proInstall.state === "running") return updateProProgress();
|
|
1926
|
+
if (proInstall.state === "running") return proActivating() ? undefined : updateProProgress();
|
|
1299
1927
|
clearInterval(proInstallTimer);
|
|
1928
|
+
// Read again however it ended: an activation taken before a failed install is kept (重试, not the code again).
|
|
1929
|
+
const fresh = !(proStatus && proStatus.installed);
|
|
1930
|
+
try { proStatus = await api().pro_status(); } catch (error) { proStatus = null; }
|
|
1300
1931
|
if (proInstall.state === "done") {
|
|
1301
|
-
try { proStatus = await api().pro_status(); } catch (error) { proStatus = null; }
|
|
1302
1932
|
proInstall = { state: "idle" };
|
|
1303
|
-
|
|
1933
|
+
proCode = "";
|
|
1934
|
+
// Activated and installed (user, 2026-11-21): back on the home page, where its features are now.
|
|
1935
|
+
if (fresh && proStatus && proStatus.installed && panel === "settings" && ["about", "pro_activate"].includes(settingsPage)) {
|
|
1936
|
+
settingsPage = "home"; settingsNote = "PaperSearch Pro 已安装";
|
|
1937
|
+
}
|
|
1304
1938
|
}
|
|
1305
1939
|
// Not over another settings page, where something may be being typed.
|
|
1306
|
-
if (panel === "settings" && ["home", "
|
|
1940
|
+
if (panel === "settings" && ["home", "about", "pro_activate", "markdown"].includes(settingsPage)) render(true);
|
|
1307
1941
|
}, 300);
|
|
1308
1942
|
}
|
|
1309
1943
|
|
|
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
1944
|
|
|
1324
1945
|
function updateProProgress() {
|
|
1325
1946
|
const bar = root.querySelector(".pro-bar span"), line = root.querySelector("#pro-progress");
|
|
1326
|
-
if (!bar || !line) return panel === "settings" &&
|
|
1947
|
+
if (!bar || !line) return panel === "settings" && ["about", "pro_activate"].includes(settingsPage) ? render(true) : undefined;
|
|
1327
1948
|
const progress = proProgress();
|
|
1328
1949
|
bar.style.width = progress.width.toFixed(1) + "%";
|
|
1329
1950
|
line.textContent = tr(progress.note);
|
|
@@ -1367,7 +1988,9 @@ function holdSettingsHeight() {
|
|
|
1367
1988
|
|
|
1368
1989
|
function settingsCard() {
|
|
1369
1990
|
const page = { download: settingsDownload, wait: settingsWait, keys: settingsKeys,
|
|
1370
|
-
|
|
1991
|
+
about: settingsAbout,
|
|
1992
|
+
...(proOn() ? { pro_activate: settingsProActivate, markdown: settingsMarkdown, login: settingsLogin,
|
|
1993
|
+
login_schools: settingsLoginSchools } : {}) }[settingsPage] || settingsHome;
|
|
1371
1994
|
return '<div class="card-body settings">' + page() + "</div>";
|
|
1372
1995
|
}
|
|
1373
1996
|
|
|
@@ -1447,8 +2070,10 @@ async function loadSettings() {
|
|
|
1447
2070
|
|
|
1448
2071
|
async function openSettings(request) {
|
|
1449
2072
|
await loadSettings();
|
|
1450
|
-
panel = "settings"; open = true; settingsNote = ""; confirmClear = ""; revealed = false;
|
|
1451
|
-
|
|
2073
|
+
panel = "settings"; open = true; settingsNote = ""; confirmClear = ""; revealed = false; languageOpen = false;
|
|
2074
|
+
const asked = pageNamed(request.page);
|
|
2075
|
+
settingsPage = SETTINGS_PAGES.includes(asked) && (!PRO_PAGES.includes(asked) || proOn()) ? asked : "home";
|
|
2076
|
+
refreshVersions();
|
|
1452
2077
|
editing = settingsPage === "keys" ? request.service || "" : "";
|
|
1453
2078
|
editValues = editing ? await savedValues(editing) : {};
|
|
1454
2079
|
loginShown = false;
|
|
@@ -1513,12 +2138,18 @@ function render(force) {
|
|
|
1513
2138
|
// Keep the real button (and its pointer/focus target) through countdown ticks.
|
|
1514
2139
|
if (unchanged && (!attention || !updateAttentionCountdown())) return;
|
|
1515
2140
|
const previous = root.getBoundingClientRect();
|
|
2141
|
+
// Read before the height it scrolls in is taken off, which puts it back at its top.
|
|
2142
|
+
const scrolledTo = surfaceTop();
|
|
1516
2143
|
root.style.width = ""; root.style.height = "";
|
|
1517
2144
|
root.style.removeProperty("--content-max-height");
|
|
1518
2145
|
if (!unchanged) {
|
|
1519
2146
|
// A scrolled list keeps its place while its page is redrawn (a key opened or saved, a group opened).
|
|
1520
2147
|
const place = panel + ":" + (panel === "settings" ? settingsPage : papersKind);
|
|
1521
2148
|
const scrolled = place === lastPlace ? root.querySelector(".papers-scroll, .keys-scroll")?.scrollTop || 0 : 0;
|
|
2149
|
+
// The page itself scrolled (支持的学校's long list) keeps its place too (user, 2026-11-21: a press on the card's
|
|
2150
|
+
// background, which starts and ends a drag, drew it again at its top), put back once it scrolls (keepSupportPlace).
|
|
2151
|
+
if (pageScroll !== null) { keepScroll = pageScroll || null; pageScroll = null; }
|
|
2152
|
+
else if (place === lastPlace && scrolledTo > 0) keepScroll = scrolledTo;
|
|
1522
2153
|
lastPlace = place;
|
|
1523
2154
|
root.className = cls + " capsule-drag-region" + (cls !== lastCls ? " fade" : "");
|
|
1524
2155
|
root.innerHTML = '<div class="surface">' + html + "</div>";
|
|
@@ -1532,6 +2163,26 @@ function render(force) {
|
|
|
1532
2163
|
lastHtml = html;
|
|
1533
2164
|
lastCls = cls;
|
|
1534
2165
|
fit(previous);
|
|
2166
|
+
keepSupportPlace(!root.classList.contains("animating"));
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
// The page stays where it was scrolled when drawn again (keepScroll). A page taller than the screen scrolls only once the
|
|
2170
|
+
// window has its size: the native resize (animateFit) sets the height it scrolls in, after the page was drawn anew at
|
|
2171
|
+
// its top, so it is put back then, and again when the resize ends; a page whose window does not change, at once.
|
|
2172
|
+
function keepSupportPlace(last) {
|
|
2173
|
+
if (keepScroll === null) return;
|
|
2174
|
+
const surface = root.querySelector(":scope > .surface");
|
|
2175
|
+
if (surface && surface.scrollHeight > surface.clientHeight) surface.scrollTop = keepScroll;
|
|
2176
|
+
if (last) keepScroll = null;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
// The card's own border, as drawn: 0.5px a side is one device pixel on a Retina screen but a whole pixel (1px a side)
|
|
2180
|
+
// on a 1x screen (user, 2026-11-22: an external 1080p screen). The surface is as wide as what the border leaves, so it
|
|
2181
|
+
// lies in the same place whichever edge it is anchored to while the window lays itself out.
|
|
2182
|
+
function rootBorder() {
|
|
2183
|
+
const style = getComputedStyle(root);
|
|
2184
|
+
return [parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth),
|
|
2185
|
+
parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth)].map((n) => n || 0);
|
|
1535
2186
|
}
|
|
1536
2187
|
|
|
1537
2188
|
let fitGeneration = 0, layoutQueue = Promise.resolve();
|
|
@@ -1543,11 +2194,11 @@ function fit(previous) {
|
|
|
1543
2194
|
const to = [Math.ceil(target.width), Math.ceil(target.height)];
|
|
1544
2195
|
const from = previous.width && previous.height ? [previous.width, previous.height] : to;
|
|
1545
2196
|
const expanded = root.classList.contains("card");
|
|
1546
|
-
const border =
|
|
2197
|
+
const border = rootBorder();
|
|
1547
2198
|
// Fix the content width before awaiting the native bridge. Otherwise an
|
|
1548
2199
|
// absolutely positioned surface shrink-wraps for a frame on every tick.
|
|
1549
|
-
root.firstElementChild.style.width = Math.max(0, to[0] - border) + "px";
|
|
1550
|
-
root.style.setProperty("--content-max-height", Math.max(0, to[1] - border) + "px");
|
|
2200
|
+
root.firstElementChild.style.width = Math.max(0, to[0] - border[0]) + "px";
|
|
2201
|
+
root.style.setProperty("--content-max-height", Math.max(0, to[1] - border[1]) + "px");
|
|
1551
2202
|
if (settledGeneration === generation - 1 && settledExpanded === expanded && settledSize
|
|
1552
2203
|
&& to.every((size, i) => size === settledSize[i] && Math.abs(size - from[i]) < 1)) {
|
|
1553
2204
|
// Elapsed time/countdowns update the text, not the window geometry.
|
|
@@ -1566,13 +2217,18 @@ async function animateFit(generation, expanded, from, to, pad) {
|
|
|
1566
2217
|
if (generation !== fitGeneration || dragging || closing) return;
|
|
1567
2218
|
const layout = await api().begin_layout(expanded, to[0] + pad, to[1] + pad, generation);
|
|
1568
2219
|
if (generation !== fitGeneration || dragging || closing || !layout.vertical) return;
|
|
1569
|
-
document.body.classList.remove("grow-up", "grow-down", "grow-left", "grow-right");
|
|
1570
|
-
document.body.classList.add("grow-" + layout.vertical, "grow-" + layout.horizontal);
|
|
1571
2220
|
from = [layout.from_width - pad, layout.from_height - pad];
|
|
1572
2221
|
to = [layout.width - pad, layout.height - pad];
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
2222
|
+
// Anchored to the edge that moves only along a side whose size changes: a layout that changes nothing (a size read
|
|
2223
|
+
// back a fraction of a pixel off on a 1x screen or at 125%/150% scaling) leaves the page where it lies, never a pixel
|
|
2224
|
+
// to one side for the length of the animation (user, 2026-11-22: it shook left and right there).
|
|
2225
|
+
document.body.classList.remove("grow-up", "grow-down", "grow-left", "grow-right");
|
|
2226
|
+
document.body.classList.add("grow-" + (Math.abs(to[1] - from[1]) >= 1 ? layout.vertical : "down"),
|
|
2227
|
+
"grow-" + (Math.abs(to[0] - from[0]) >= 1 ? layout.horizontal : "right"));
|
|
2228
|
+
const border = rootBorder();
|
|
2229
|
+
root.style.setProperty("--content-max-height", Math.max(0, to[1] - border[1]) + "px");
|
|
2230
|
+
root.firstElementChild.style.width = Math.max(0, to[0] - border[0]) + "px";
|
|
2231
|
+
keepSupportPlace(false);
|
|
1576
2232
|
const duration = matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 240;
|
|
1577
2233
|
const started = performance.now();
|
|
1578
2234
|
// One outstanding native resize at a time; a newer layout cancels this animation.
|
|
@@ -1592,6 +2248,7 @@ async function animateFit(generation, expanded, from, to, pad) {
|
|
|
1592
2248
|
if (generation === fitGeneration) {
|
|
1593
2249
|
root.classList.remove("animating");
|
|
1594
2250
|
settledGeneration = generation; settledSize = to; settledExpanded = expanded;
|
|
2251
|
+
keepSupportPlace(true);
|
|
1595
2252
|
}
|
|
1596
2253
|
}
|
|
1597
2254
|
observeHover();
|
|
@@ -1620,12 +2277,21 @@ function say(text) { flash = { text: text, until: Date.now() + 6000 }; render(tr
|
|
|
1620
2277
|
|
|
1621
2278
|
let inputActivation = Promise.resolve();
|
|
1622
2279
|
async function act(action, target) {
|
|
2280
|
+
if (action !== "login_menu") loginMenu = "";
|
|
1623
2281
|
const v = V;
|
|
1624
2282
|
switch (action) {
|
|
1625
2283
|
// Back as a capsule when restored, unless pinned: a pinned card comes back open (user, 2026-11-20:
|
|
1626
2284
|
// on Windows, minimized and restored, the pinned card had shrunk to the capsule).
|
|
1627
|
-
case "minimize":
|
|
1628
|
-
|
|
2285
|
+
case "minimize": {
|
|
2286
|
+
if (!pinned) open = false;
|
|
2287
|
+
panel = ""; minimizing = true;
|
|
2288
|
+
render(true);
|
|
2289
|
+
// Folded to the capsule before it goes into the Dock or the taskbar (user, 2026-11-21): minimized while it
|
|
2290
|
+
// still shrank, the window went at the card's size, and brought back showed the card a moment first.
|
|
2291
|
+
await layoutQueue;
|
|
2292
|
+
try { return await api().minimize(); } finally { setTimeout(() => { minimizing = false; }, 400); }
|
|
2293
|
+
}
|
|
2294
|
+
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
2295
|
case "folder": return api().open_folder();
|
|
1630
2296
|
case "expand": open = true; panel = ""; return render(true);
|
|
1631
2297
|
case "pin":
|
|
@@ -1677,14 +2343,19 @@ async function act(action, target) {
|
|
|
1677
2343
|
return say(said);
|
|
1678
2344
|
}
|
|
1679
2345
|
case "settings": return openSettings({ page: "home" });
|
|
2346
|
+
case "language_menu":
|
|
2347
|
+
languageOpen = !languageOpen;
|
|
2348
|
+
render(true);
|
|
2349
|
+
return root.querySelector(languageOpen ? ".lang-menu [aria-checked=true]" : ".lang-btn")?.focus();
|
|
1680
2350
|
case "language": {
|
|
2351
|
+
languageOpen = false;
|
|
1681
2352
|
const result = await api().set_language(target.dataset.lang);
|
|
1682
2353
|
if (result.ok) lang = result.language;
|
|
1683
2354
|
return render(true);
|
|
1684
2355
|
}
|
|
1685
2356
|
case "settings_page":
|
|
1686
|
-
settingsPage = target.dataset.page; settingsErrors = {}; settingsDraft = {}; settingsNote = ""; editing = ""; editValues = {};
|
|
1687
|
-
loginError = ""; loginDone = ""; confirmClear = ""; loginShown = false;
|
|
2357
|
+
settingsPage = pageNamed(target.dataset.page); settingsErrors = {}; settingsDraft = {}; settingsNote = ""; editing = ""; editValues = {};
|
|
2358
|
+
loginError = ""; loginDone = ""; confirmClear = ""; loginShown = false; languageOpen = false;
|
|
1688
2359
|
if (settingsPage === "login") {
|
|
1689
2360
|
// The default school open first; 添加学校 starts empty.
|
|
1690
2361
|
loginOpen = ((schoolLogin && schoolLogin.schools) || []).find((s) => s.current)?.key || "";
|
|
@@ -1692,12 +2363,18 @@ async function act(action, target) {
|
|
|
1692
2363
|
loginAdding = !loginOpen; // no school yet: straight to finding one
|
|
1693
2364
|
}
|
|
1694
2365
|
if (settingsPage === "login_schools") {
|
|
1695
|
-
supportFilter = ""; supportOpen = ""; supportList = null; render(true);
|
|
2366
|
+
supportFilter = ""; supportOpen = ""; supportRegions = new Set(); supportParts = new Set(); supportBack = 0; supportList = null; render(true);
|
|
1696
2367
|
try { supportList = await api().school_support_list(); } catch (error) { supportList = { ok: false, error: "读取失败" }; }
|
|
1697
2368
|
}
|
|
1698
2369
|
return render(true);
|
|
1699
2370
|
case "back":
|
|
1700
2371
|
if (panel !== "settings") { panel = ""; return render(true); }
|
|
2372
|
+
languageOpen = false;
|
|
2373
|
+
if (settingsPage === "login_schools" && supportOpen) {
|
|
2374
|
+
// From a country's page to the regions', where it was.
|
|
2375
|
+
supportOpen = ""; supportParts = new Set(); supportFilter = ""; pageScroll = supportBack || 0;
|
|
2376
|
+
return render(true);
|
|
2377
|
+
}
|
|
1701
2378
|
if (settingsPage === "home") return leaveSettings();
|
|
1702
2379
|
settingsPage = parentPage(settingsPage); editing = ""; editValues = {}; settingsErrors = {}; settingsDraft = {};
|
|
1703
2380
|
loginError = ""; confirmClear = ""; return render(true);
|
|
@@ -1719,15 +2396,22 @@ async function act(action, target) {
|
|
|
1719
2396
|
render(true);
|
|
1720
2397
|
return watchProInstall();
|
|
1721
2398
|
}
|
|
1722
|
-
case "
|
|
1723
|
-
|
|
1724
|
-
|
|
2399
|
+
case "activate_pro": {
|
|
2400
|
+
// 激活 (user, 2026-11-21): the code to the activation server, then the install.
|
|
2401
|
+
const code = proCode.trim();
|
|
2402
|
+
if (!code) { proCodeError = "请输入激活码"; render(true); return root.querySelector("#pro-code")?.focus(); }
|
|
2403
|
+
proCodeError = "";
|
|
2404
|
+
try { proInstall = (await api().install_pro(code)) || { state: "idle" }; }
|
|
2405
|
+
catch (error) { proInstall = { state: "failed", step: "activate", message: "激活出错" }; }
|
|
1725
2406
|
render(true);
|
|
1726
|
-
return
|
|
2407
|
+
return watchProInstall();
|
|
1727
2408
|
}
|
|
1728
2409
|
case "pro_sites":
|
|
1729
2410
|
proSitesOpen = !proSitesOpen;
|
|
1730
2411
|
return render(true);
|
|
2412
|
+
case "pro_merits":
|
|
2413
|
+
proMeritsOpen = !proMeritsOpen;
|
|
2414
|
+
return render(true);
|
|
1731
2415
|
case "pro_issue": {
|
|
1732
2416
|
const result = await api().open_issue();
|
|
1733
2417
|
if (!result.ok) { settingsNote = result.message; render(true); }
|
|
@@ -1770,8 +2454,83 @@ async function act(action, target) {
|
|
|
1770
2454
|
}
|
|
1771
2455
|
await loadLoginValues(); return render(true);
|
|
1772
2456
|
}
|
|
2457
|
+
case "school_test": {
|
|
2458
|
+
// The test uses the account as saved: fields changed since are saved first.
|
|
2459
|
+
loginError = ""; loginDone = "";
|
|
2460
|
+
if ((loginValues.username || "") !== (loginSavedValues.username || "") || (loginValues.password || "") !== (loginSavedValues.password || "")) {
|
|
2461
|
+
const saved = await api().save_school_login(loginValues.username || "", loginValues.password || "", true, loginOpen);
|
|
2462
|
+
if (!saved.ok) { loginError = saved.error || "保存失败"; return render(true); }
|
|
2463
|
+
schoolLogin = saved; loginSavedValues = { ...loginValues };
|
|
2464
|
+
}
|
|
2465
|
+
if (testEditing && testArticleText.trim()) {
|
|
2466
|
+
// An article typed and not yet taken: taken first, or why not said.
|
|
2467
|
+
await act("test_article_save");
|
|
2468
|
+
if (testEditing) return;
|
|
2469
|
+
}
|
|
2470
|
+
if (!testArticle || !testArticle.doi) {
|
|
2471
|
+
// None filled in: its box opened for one.
|
|
2472
|
+
testEditing = true; testArticleError = "先填测试文章"; render(true);
|
|
2473
|
+
return root.querySelector("#test-article")?.focus();
|
|
2474
|
+
}
|
|
2475
|
+
const started = await api().start_school_test(loginOpen, testArticle ? testArticle.doi : "");
|
|
2476
|
+
if (started.error) { loginError = started.error; return render(true); }
|
|
2477
|
+
schoolTest = started; watchSchoolTest();
|
|
2478
|
+
return render(true);
|
|
2479
|
+
}
|
|
2480
|
+
case "school_switch": {
|
|
2481
|
+
let answer;
|
|
2482
|
+
try { answer = await api().set_school_switch(!(schoolLogin && schoolLogin.switch !== false)); } catch (error) { answer = null; }
|
|
2483
|
+
if (answer && answer.ok) schoolLogin = answer;
|
|
2484
|
+
else { loginError = (answer && answer.error) || "保存失败"; }
|
|
2485
|
+
return render(true);
|
|
2486
|
+
}
|
|
2487
|
+
case "check_versions":
|
|
2488
|
+
versionCheck = { state: "running" }; render(true);
|
|
2489
|
+
return checkVersions(true);
|
|
2490
|
+
case "update_all": {
|
|
2491
|
+
let started;
|
|
2492
|
+
try { started = await api().update_all(); } catch (error) { started = { state: "idle", error: "更新出错" }; }
|
|
2493
|
+
if (started && started.error) { settingsNote = started.error; return render(true); }
|
|
2494
|
+
updateRun = started || { state: "idle" }; settingsNote = "";
|
|
2495
|
+
watchUpdate();
|
|
2496
|
+
return render(true);
|
|
2497
|
+
}
|
|
2498
|
+
case "release_notes": {
|
|
2499
|
+
const answer = await api().open_release_notes();
|
|
2500
|
+
if (answer && !answer.ok) say(answer.message);
|
|
2501
|
+
return;
|
|
2502
|
+
}
|
|
2503
|
+
case "reopen_window": {
|
|
2504
|
+
const answer = await api().reopen_window(settingsPage === "about" ? "about" : "home");
|
|
2505
|
+
if (answer && !answer.ok) { settingsNote = answer.message; render(true); }
|
|
2506
|
+
return;
|
|
2507
|
+
}
|
|
2508
|
+
case "school_test_stop":
|
|
2509
|
+
schoolTest = await api().stop_school_test();
|
|
2510
|
+
return render(true);
|
|
2511
|
+
case "test_article_edit":
|
|
2512
|
+
testEditing = true; testArticleError = ""; testArticleText = (testArticle && testArticle.doi) || "";
|
|
2513
|
+
render(true);
|
|
2514
|
+
return root.querySelector("#test-article")?.focus();
|
|
2515
|
+
case "test_article_save": {
|
|
2516
|
+
// By its DOI or its page's address, the DOI looked up (school_test.doi_of); emptied, none.
|
|
2517
|
+
testArticleSaving = true; testArticleError = ""; render(true);
|
|
2518
|
+
let answer;
|
|
2519
|
+
try { answer = await api().set_school_test_article(loginOpen, testArticleText); } catch (error) { answer = { ok: false, error: "保存失败" }; }
|
|
2520
|
+
testArticleSaving = false;
|
|
2521
|
+
if (answer && answer.ok) { testArticle = answer; testEditing = false; } else testArticleError = (answer && answer.error) || "保存失败";
|
|
2522
|
+
return render(true);
|
|
2523
|
+
}
|
|
2524
|
+
case "support_region": case "support_part": {
|
|
2525
|
+
// Its countries (a country's part: its schools) shown or hidden in place, the page where it was; the others left
|
|
2526
|
+
// as they are.
|
|
2527
|
+
const open = action === "support_region" ? supportRegions : supportParts, key = target.dataset.key;
|
|
2528
|
+
if (!open.delete(key)) open.add(key);
|
|
2529
|
+
return render(true);
|
|
2530
|
+
}
|
|
1773
2531
|
case "support_group":
|
|
1774
|
-
|
|
2532
|
+
// The country's page, at its top, its parts closed; where the regions' page was kept for coming back.
|
|
2533
|
+
supportBack = surfaceTop(); supportOpen = target.dataset.key; supportParts = new Set(); supportFilter = ""; pageScroll = 0;
|
|
1775
2534
|
return render(true);
|
|
1776
2535
|
case "login_add": {
|
|
1777
2536
|
loginAdding = !loginAdding; schoolFound = null; loginError = "";
|
|
@@ -1779,6 +2538,11 @@ async function act(action, target) {
|
|
|
1779
2538
|
if (loginAdding) root.querySelector("#school-query")?.focus();
|
|
1780
2539
|
return;
|
|
1781
2540
|
}
|
|
2541
|
+
case "login_menu":
|
|
2542
|
+
loginMenu = loginMenu === loginOpen ? "" : loginOpen; confirmClear = ""; confirmForget = "";
|
|
2543
|
+
return render(true);
|
|
2544
|
+
case "cancel_confirm":
|
|
2545
|
+
confirmClear = ""; confirmForget = ""; return render(true);
|
|
1782
2546
|
case "login_open": {
|
|
1783
2547
|
loginOpen = loginOpen === target.dataset.key ? "" : target.dataset.key;
|
|
1784
2548
|
loginError = ""; loginDone = ""; confirmClear = ""; confirmForget = ""; loginShown = false; loginSaved = false;
|
|
@@ -1892,8 +2656,9 @@ async function act(action, target) {
|
|
|
1892
2656
|
}
|
|
1893
2657
|
}
|
|
1894
2658
|
|
|
1895
|
-
// A paper list scrolls; pressing in it must not drag the window.
|
|
1896
|
-
|
|
2659
|
+
// A paper list scrolls; pressing in it must not drag the window. Nor in 支持的学校's list (user, 2026-11-21: a press
|
|
2660
|
+
// between its rows dragged, and the redraw after it went back to the top).
|
|
2661
|
+
const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list, .papers-scroll, .keys-scroll, #support-list');
|
|
1897
2662
|
// The dot's card: open while the pointer is on the dot or the card, a moment's grace between
|
|
1898
2663
|
// them. Told by where the pointer moves, not by its leaving: the card is redrawn every second
|
|
1899
2664
|
// and a dot redrawn under the pointer never says it was left.
|
|
@@ -1977,6 +2742,16 @@ root.addEventListener("input", (event) => {
|
|
|
1977
2742
|
else if (input.id === "login-user") loginValues.username = input.value;
|
|
1978
2743
|
else if (input.id === "login-password") loginValues.password = input.value;
|
|
1979
2744
|
else if (input.id === "school-query") schoolQuery = input.value;
|
|
2745
|
+
else if (input.id === "test-article") { testArticleText = input.value; testArticleError = ""; }
|
|
2746
|
+
else if (input.id === "pro-code") {
|
|
2747
|
+
proCode = input.value;
|
|
2748
|
+
// Typing again clears why the last code was not taken.
|
|
2749
|
+
if (proCodeError || (proInstall.state === "failed" && proActivating())) {
|
|
2750
|
+
proCodeError = "";
|
|
2751
|
+
if (proInstall.state === "failed") proInstall = { state: "idle" };
|
|
2752
|
+
root.querySelector(".pro-code-err")?.remove();
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
1980
2755
|
else if (input.id === "support-filter") {
|
|
1981
2756
|
supportFilter = input.value;
|
|
1982
2757
|
const box = root.querySelector("#support-list");
|
|
@@ -1987,6 +2762,26 @@ root.addEventListener("click", (event) => {
|
|
|
1987
2762
|
const target = event.target.closest("[data-act]");
|
|
1988
2763
|
if (target) { event.stopPropagation(); act(target.dataset.act, target); }
|
|
1989
2764
|
});
|
|
2765
|
+
// The language menu closes on a press anywhere else, taken off at once: a press on the card's background starts
|
|
2766
|
+
// the window's drag, while which the page is not drawn again.
|
|
2767
|
+
document.addEventListener("pointerdown", (event) => {
|
|
2768
|
+
if (languageOpen && !event.target.closest(".lang-wrap")) closeLanguageMenu();
|
|
2769
|
+
if (loginMenu && !event.target.closest(".ls-menu, .ls-dots")) {
|
|
2770
|
+
loginMenu = "";
|
|
2771
|
+
root.querySelector(".ls-menu")?.remove();
|
|
2772
|
+
root.querySelector(".ls-dots")?.setAttribute("aria-expanded", "false");
|
|
2773
|
+
}
|
|
2774
|
+
}, true);
|
|
2775
|
+
function closeLanguageMenu() {
|
|
2776
|
+
languageOpen = false;
|
|
2777
|
+
root.querySelector(".lang-menu")?.remove();
|
|
2778
|
+
const button = root.querySelector(".lang-btn");
|
|
2779
|
+
if (!button) return;
|
|
2780
|
+
button.setAttribute("aria-expanded", "false");
|
|
2781
|
+
button.lastElementChild.outerHTML = icon("down");
|
|
2782
|
+
}
|
|
2783
|
+
// While the card folds to go into the Dock, the pointer still on it does not open it again.
|
|
2784
|
+
let minimizing = false;
|
|
1990
2785
|
function setHover(inside, force = false) {
|
|
1991
2786
|
// Minimize/task transitions can fold the card while the pointer stays inside.
|
|
1992
2787
|
if (!force && hovering === inside && (!inside || open)) return;
|
|
@@ -1994,7 +2789,7 @@ function setHover(inside, force = false) {
|
|
|
1994
2789
|
clearTimeout(hoverTimer); clearTimeout(leaveTimer);
|
|
1995
2790
|
if (dragging || attentionPointer !== null) return;
|
|
1996
2791
|
if (inside) {
|
|
1997
|
-
hoverTimer = setTimeout(() => { if (!open) { open = true; render(true); } }, 100);
|
|
2792
|
+
hoverTimer = setTimeout(() => { if (!open && !minimizing) { open = true; render(true); } }, 100);
|
|
1998
2793
|
} else {
|
|
1999
2794
|
// Leave enough time to cross the edge; open menus and settings stay usable.
|
|
2000
2795
|
leaveTimer = setTimeout(() => { if (!panel && !pinned) { open = false; render(true); } }, 280);
|
|
@@ -2037,13 +2832,17 @@ window.addEventListener("pointercancel", endAttentionPress);
|
|
|
2037
2832
|
window.addEventListener("blur", endAttentionPress);
|
|
2038
2833
|
document.addEventListener("keydown", (event) => {
|
|
2039
2834
|
if (event.key === "Escape" && panel) {
|
|
2835
|
+
if (languageOpen) { closeLanguageMenu(); return root.querySelector(".lang-btn")?.focus(); }
|
|
2836
|
+
// Its box closed, the article as it was.
|
|
2837
|
+
if (testEditing && event.target.id === "test-article") { testEditing = false; testArticleError = ""; return render(true); }
|
|
2040
2838
|
if (panel !== "settings") { panel = ""; render(true); }
|
|
2041
2839
|
else act(editing ? "cancel_key" : "back");
|
|
2042
2840
|
}
|
|
2043
2841
|
if (event.key === "Enter" && panel === "settings" && event.target.tagName === "INPUT") {
|
|
2044
2842
|
if (settingsPage === "keys" && editing) act("save_key", { dataset: { service: editing }, textContent: "" });
|
|
2045
2843
|
else if (settingsPage === "download" || settingsPage === "wait") act("save");
|
|
2046
|
-
else if (settingsPage === "login") act(event.target.id === "school-query" ? "find_school" : "save_login", { dataset: {} });
|
|
2844
|
+
else if (settingsPage === "login") act(event.target.id === "school-query" ? "find_school" : event.target.id === "test-article" ? "test_article_save" : "save_login", { dataset: {} });
|
|
2845
|
+
else if (["about", "pro_activate"].includes(settingsPage) && event.target.id === "pro-code") act("activate_pro");
|
|
2047
2846
|
}
|
|
2048
2847
|
});
|
|
2049
2848
|
|
|
@@ -2052,6 +2851,8 @@ window.addEventListener("pywebviewready", async () => {
|
|
|
2052
2851
|
document.body.classList.add(platform === "darwin" ? "mac" : platform === "win32" ? "win" : "other");
|
|
2053
2852
|
await tick();
|
|
2054
2853
|
pollTimer = setInterval(tick, 500);
|
|
2854
|
+
setTimeout(() => checkVersions(), 3000);
|
|
2855
|
+
setInterval(() => checkVersions(), 6 * 3600 * 1000);
|
|
2055
2856
|
});
|
|
2056
2857
|
</script>
|
|
2057
2858
|
</body>
|