dsh-wtq-pool 1.0.3 → 1.0.5
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/CHANGELOG.md +100 -47
- package/README.en.md +76 -40
- package/README.md +79 -44
- package/cordis.patch.yml +6 -3
- package/lib/client.js +3 -1
- package/lib/index.d.ts +2 -12
- package/lib/index.js +2607 -886
- package/package.json +3 -2
- package/renderer/index.html +67 -16
- package/renderer/panel.css +123 -10
- package/renderer/panel.js +1381 -101
package/renderer/panel.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* The panel owns no data and makes no network request: everything it shows
|
|
7
7
|
* comes from the plugin's main process through `window.pluginBridge.invoke`,
|
|
8
|
-
* and every channel name matches a case in `onPanelInvoke` (
|
|
8
|
+
* and every channel name matches a case in `onPanelInvoke` (src/host.ts).
|
|
9
9
|
*
|
|
10
10
|
* All API-derived text is written with textContent / createElement, never
|
|
11
11
|
* innerHTML, so a model id or an upstream error can never inject markup.
|
|
@@ -28,6 +28,8 @@ var EN = {
|
|
|
28
28
|
"tab.pool": "Pool",
|
|
29
29
|
"tab.models": "Models",
|
|
30
30
|
"tab.check": "Connection check",
|
|
31
|
+
"tab.growth": "Growth centre",
|
|
32
|
+
"risk.note": "! A ban is possible. Use at your own discretion; no liability accepted !",
|
|
31
33
|
"host.missing": "The host has not registered {count} model group(s) from this plugin yet: reload the plugin so it re-reads the declaration.",
|
|
32
34
|
"btn.rescan": "Detect accounts again",
|
|
33
35
|
"btn.reset": "Clear all cooldowns",
|
|
@@ -53,7 +55,7 @@ var EN = {
|
|
|
53
55
|
"pool.healthy": "Rate limits automatically switch to another available account.",
|
|
54
56
|
"pool.allCooling": "Every account is rate-limited right now; requests pause until a cooldown lifts.",
|
|
55
57
|
"pool.checkinAll": "Check in every account",
|
|
56
|
-
"pool.checkinAllHint": "Collect every account's daily check-in. The streak bonus
|
|
58
|
+
"pool.checkinAllHint": "Collect every account's daily check-in. The streak bonus is collected with it.",
|
|
57
59
|
"pool.checkinAllBusy": "Checking in…",
|
|
58
60
|
"pool.checkinAllDone": "Checked in {count} account(s)",
|
|
59
61
|
"pool.checkinAllNone": "Every account is already checked in today",
|
|
@@ -61,12 +63,19 @@ var EN = {
|
|
|
61
63
|
"pool.emptyRegion": "No {region} account is signed in yet.",
|
|
62
64
|
"pool.emptyHint": "Sign in to that edition in the WorkBuddy desktop app, then press “Detect accounts again”.",
|
|
63
65
|
"pool.sourceOff": "The WorkBuddy source is switched off in plugin settings.",
|
|
66
|
+
"login.add": "Add account",
|
|
67
|
+
"login.addHint": "Sign in to WorkBuddy in your browser. The account joins the pool the moment the browser finishes.",
|
|
68
|
+
"login.openAgain": "Open the link again",
|
|
69
|
+
"login.waiting": "Finish the sign-in in your browser; this panel picks the account up by itself.",
|
|
70
|
+
"login.timeout": "The sign-in did not finish. Start again for a new link.",
|
|
71
|
+
"login.added": "Added {name}",
|
|
72
|
+
"login.addedNoName": "Account added",
|
|
64
73
|
"trae.title": "Trae",
|
|
65
74
|
"trae.gateway": "{region} gateway on port {port}",
|
|
66
75
|
"trae.models": "{count} model(s)",
|
|
67
76
|
"trae.noModels": "no models published yet",
|
|
68
77
|
"trae.off": "The Trae source is switched off in plugin settings.",
|
|
69
|
-
"trae.fallback": "
|
|
78
|
+
"trae.fallback": "preferred port {port} is taken; this session serves a spare port, which the provider row follows",
|
|
70
79
|
"qoder.title": "Qoder",
|
|
71
80
|
"qoder.gateway": "{region} gateway on port {port}",
|
|
72
81
|
"qoder.models": "{count} model(s)",
|
|
@@ -94,7 +103,7 @@ var EN = {
|
|
|
94
103
|
"source.campaignUnknown": "check-in state unavailable",
|
|
95
104
|
"source.claimableAt": "Can claim after {time}",
|
|
96
105
|
"source.deviceCheckedIn": "This device checked in today",
|
|
97
|
-
"qoder.fallback": "
|
|
106
|
+
"qoder.fallback": "preferred port {port} is taken; this session serves a spare port, which the provider row follows",
|
|
98
107
|
"badge.next": "next up",
|
|
99
108
|
"badge.cooling": "cooling",
|
|
100
109
|
"badge.healthy": "healthy",
|
|
@@ -110,15 +119,22 @@ var EN = {
|
|
|
110
119
|
"acct.automatic": "Automatic (follow account usage)",
|
|
111
120
|
"acct.choiceHint": "The picked account goes first; a rate limit switches account until the cooldown lifts. Automatic follows the usage mode.",
|
|
112
121
|
"acct.unavailable": "Selected account unavailable (automatic fallback)",
|
|
122
|
+
"acct.expired": "sign-in expired",
|
|
123
|
+
"acct.archivedHint": "The global client keeps one sign-in file, so switching accounts overwrites this one. The token was saved: the account keeps serving until it expires. Sign in again in WorkBuddy to renew it.",
|
|
113
124
|
"acct.choiceCredits": "{label} · {credits} credits",
|
|
114
125
|
"badge.preferred": "selected",
|
|
115
126
|
"acct.on": "Enabled",
|
|
116
127
|
"acct.off": "Switched off",
|
|
117
128
|
"acct.switchOn": "Use this account again",
|
|
129
|
+
"acct.inPool": "In the rotation",
|
|
118
130
|
"acct.switchOff": "Keep this account out of the pool for now",
|
|
119
131
|
"acct.offHint": "Switched off: requests never use this account until you switch it back on.",
|
|
120
132
|
"acct.remove": "Remove",
|
|
121
|
-
"acct.removeHint": "
|
|
133
|
+
"acct.removeHint": "Takes the account out of the pool. Restore it under “Removed accounts”.",
|
|
134
|
+
"acct.delete": "Delete",
|
|
135
|
+
"acct.deleteHint": "Deletes the sign-in file this plugin wrote. The account is gone for good and cannot be restored.",
|
|
136
|
+
"acct.deleteConfirm": "Delete {name}? The sign-in file is removed and the account cannot be brought back.",
|
|
137
|
+
"acct.deleteConfirmAgain": "Press delete again to confirm",
|
|
122
138
|
"acct.stateError": "Could not change this account: {message}",
|
|
123
139
|
"pool.switchedOff": "{count} switched off",
|
|
124
140
|
"removed.title": "Removed accounts",
|
|
@@ -126,7 +142,7 @@ var EN = {
|
|
|
126
142
|
"removed.restore": "Restore",
|
|
127
143
|
"acct.modelCool": "{model} cooling until {time}",
|
|
128
144
|
"credits.title": "Credits",
|
|
129
|
-
"credits.unavailable": "
|
|
145
|
+
"credits.unavailable": "Credits could not be read",
|
|
130
146
|
"credits.package": "{remain} / {size}",
|
|
131
147
|
"credits.monthly": "monthly",
|
|
132
148
|
"credits.refreshAt": "refreshes {time}",
|
|
@@ -170,6 +186,10 @@ var EN = {
|
|
|
170
186
|
"models.windowFollows": "Follows the catalog; editing pins your value.",
|
|
171
187
|
"models.maxOutput": "Max output",
|
|
172
188
|
"models.outputHelp": "The largest reply this model may produce.",
|
|
189
|
+
// The ceiling is the model's own figure. The host sizes its context budget and
|
|
190
|
+
// compaction threshold from the declared number, so a larger value made it
|
|
191
|
+
// wait for room the upstream never had.
|
|
192
|
+
"models.overCeiling": "This model takes at most {limit}; the larger value was not applied.",
|
|
173
193
|
"models.levels": "Thinking levels",
|
|
174
194
|
"models.defaultLevel": "Default thinking level",
|
|
175
195
|
"models.capabilities": "Attachments",
|
|
@@ -182,7 +202,6 @@ var EN = {
|
|
|
182
202
|
"models.dirty": "Unsaved changes",
|
|
183
203
|
"models.saving": "Saving…",
|
|
184
204
|
"models.saved": "Model selection saved",
|
|
185
|
-
"models.applyHint": "Saved. If the model picker does not follow, reload the plugin.",
|
|
186
205
|
"models.saveError": "Could not save: {message}",
|
|
187
206
|
"models.reload": "The model list changed. Reload the plugin to sync it.",
|
|
188
207
|
"models.addressDrift": "The published address differs from the one this run bound. Reload the plugin.",
|
|
@@ -217,9 +236,42 @@ var EN = {
|
|
|
217
236
|
"auto.rowQoder": "Qoder",
|
|
218
237
|
"auto.rowTrae": "Trae",
|
|
219
238
|
"auto.rowCounts": "{label}: {claimed} collected · {skipped} skipped · {failed} failed",
|
|
220
|
-
"auto.rowGrowth": "Streak
|
|
239
|
+
"auto.rowGrowth": "Streak: {streak} tier(s) · +{credit} credits · {failed} failed",
|
|
240
|
+
"auto.rowKeepAlive": "Token keep-alive {when}: {refreshed} refreshed · {fresh} already fresh · {failed} failed · {noToken} with no refresh token",
|
|
221
241
|
"auto.rowTravelCounts": "{label}: {departed} sent · {claimed} claimed · {adopted} adopted",
|
|
222
|
-
"auto.hint": "Claims the daily reward of all three sources (WorkBuddy / Trae / Qoder), the streak bonus
|
|
242
|
+
"auto.hint": "Claims the daily reward of all three sources (WorkBuddy / Trae / Qoder), the streak bonus of domestic WorkBuddy accounts, and runs the travel patrol in one pass. A slot already collected today is skipped. A slot missed earlier today is collected at the next start.",
|
|
243
|
+
"keepAlive.runNow": "Refresh now",
|
|
244
|
+
"keepAlive.running": "Refreshing…",
|
|
245
|
+
"keepAlive.label": "Token keep-alive",
|
|
246
|
+
"keepAlive.hint": "Renews sign-in tokens that are close to expiry, on demand. An account you rarely use then does not hit an expired token on the turn that needed it. Tokens with plenty of time left are left alone.",
|
|
247
|
+
"growth.title": "Growth centre",
|
|
248
|
+
"growth.ready": "WorkBuddy",
|
|
249
|
+
"growth.running": "Running…",
|
|
250
|
+
"growth.read": "Read state",
|
|
251
|
+
"growth.reading": "Reading…",
|
|
252
|
+
"growth.readHint": "Reads what the centre holds without claiming anything.",
|
|
253
|
+
"growth.run": "Run now",
|
|
254
|
+
"growth.runHint": "Runs the growth half of the scheduled check-in on its own, and reports each step.",
|
|
255
|
+
"growth.hint": "Four steps: the make-up card, the gift and compensation, the activity report, and the streak tiers with their draws. A run consumes the make-up card and the draws; the rest are idempotent and pay nothing a second time.",
|
|
256
|
+
"growth.stateNone": "No state read yet",
|
|
257
|
+
"growth.stateStale": "The last run made this stale; read the state again",
|
|
258
|
+
"growth.stateSummary": "{accounts} account(s) · {tiers} tier(s) to redeem · {cards} make-up card(s) · {chances} draw(s)",
|
|
259
|
+
"growth.groupCount": "{count} account(s)",
|
|
260
|
+
"growth.stateFailed": "{failed} account(s) could not be read",
|
|
261
|
+
"growth.rowSummary": "Streak {days} day(s) · next tier {tier}, {remaining} to go",
|
|
262
|
+
"growth.rowHold": "{tiers} to redeem · {cards} card(s) · {chances} draw(s)",
|
|
263
|
+
"growth.rowTiers": "Streak tiers",
|
|
264
|
+
"growth.rowTier": "{tier} · {days} day(s) · +{credit} credits +{energy} energy · {status}",
|
|
265
|
+
"growth.tierClaimed": "claimed",
|
|
266
|
+
"growth.tierUnlocked": "ready to redeem",
|
|
267
|
+
"growth.tierLocked": "locked",
|
|
268
|
+
"growth.rowNothing": "Nothing to collect here",
|
|
269
|
+
"growth.rowFailed": "This account could not be read",
|
|
270
|
+
"growth.onlyWorkbuddy": "The growth centre belongs to WorkBuddy.",
|
|
271
|
+
"growth.runNone": "Nothing to collect on this pass",
|
|
272
|
+
"growth.runLine": "{when}: make-up {makeup} · gift +{gift} · compensation +{compensation} · activity {activity} · tiers {streak} · draws {lottery} · +{credit} credits",
|
|
273
|
+
"growth.runFailed": "{when}: {failed} step(s) failed",
|
|
274
|
+
"growth.busy": "A check-in pass is already running; wait for it to finish",
|
|
223
275
|
"composer.title": "Composer credits",
|
|
224
276
|
"composer.on": "On",
|
|
225
277
|
"composer.off": "Off",
|
|
@@ -227,6 +279,13 @@ var EN = {
|
|
|
227
279
|
"composer.hint": "When the selected model belongs to this plugin, its account's credits appear on the left of the composer. Click to switch accounts.",
|
|
228
280
|
"composer.show": "Show credits",
|
|
229
281
|
"composer.hide": "Hide credits",
|
|
282
|
+
"rewrite.title": "Client name",
|
|
283
|
+
"rewrite.on": "On",
|
|
284
|
+
"rewrite.off": "Off",
|
|
285
|
+
"rewrite.label": "Rename the client in the prompt the domestic host receives",
|
|
286
|
+
"rewrite.hint": "The domestic WorkBuddy host refuses a request whose prompt names DeepSeek Harness as the client (channel check 11128). Turned on, every occurrence of that name is sent as DeepSeek; turned off, the original wording is sent.",
|
|
287
|
+
"rewrite.show": "Rename client",
|
|
288
|
+
"rewrite.hide": "Stop renaming",
|
|
230
289
|
"check.title": "Connection check",
|
|
231
290
|
"check.empty": "Run the check to see whether a chat can reach WorkBuddy, Trae or Qoder.",
|
|
232
291
|
"check.pass": "PASS",
|
|
@@ -255,6 +314,8 @@ var ZH = {
|
|
|
255
314
|
"tab.pool": "账号池",
|
|
256
315
|
"tab.models": "模型",
|
|
257
316
|
"tab.check": "连接检查",
|
|
317
|
+
"tab.growth": "成长中心",
|
|
318
|
+
"risk.note": "!可能有封号风险,请斟酌使用,概不负责 !",
|
|
258
319
|
"host.missing": "宿主还没有注册本插件的 {count} 个模型组:重新加载插件让它重读声明。",
|
|
259
320
|
"btn.rescan": "重新检测账号",
|
|
260
321
|
"btn.reset": "清除所有冷却",
|
|
@@ -280,7 +341,7 @@ var ZH = {
|
|
|
280
341
|
"pool.healthy": "限流时会自动切换到其他可用账号。",
|
|
281
342
|
"pool.allCooling": "所有账号当前都被限流,请求会等到有账号冷却结束。",
|
|
282
343
|
"pool.checkinAll": "全部签到",
|
|
283
|
-
"pool.checkinAllHint": "
|
|
344
|
+
"pool.checkinAllHint": "一次领完所有账号今天的签到,连登奖励也随这一轮领取。",
|
|
284
345
|
"pool.checkinAllBusy": "签到中…",
|
|
285
346
|
"pool.checkinAllDone": "已签到 {count} 个账号",
|
|
286
347
|
"pool.checkinAllNone": "所有账号今天都已签到",
|
|
@@ -288,12 +349,19 @@ var ZH = {
|
|
|
288
349
|
"pool.emptyRegion": "{region}这一侧还没有登录的账号。",
|
|
289
350
|
"pool.emptyHint": "请在该版本的 WorkBuddy 桌面 App 里登录,再点「重新检测账号」。",
|
|
290
351
|
"pool.sourceOff": "WorkBuddy 来源已在插件设置里关闭。",
|
|
352
|
+
"login.add": "添加账号",
|
|
353
|
+
"login.addHint": "在浏览器里登录 WorkBuddy。浏览器登完,这个账号就进池子了。",
|
|
354
|
+
"login.openAgain": "再打开一次链接",
|
|
355
|
+
"login.waiting": "在浏览器里完成登录即可,面板会自己把这个账号收进来。",
|
|
356
|
+
"login.timeout": "登录没有完成。重新开始一次拿新链接。",
|
|
357
|
+
"login.added": "已添加 {name}",
|
|
358
|
+
"login.addedNoName": "账号已添加",
|
|
291
359
|
"trae.title": "Trae",
|
|
292
360
|
"trae.gateway": "{region}网关,端口 {port}",
|
|
293
361
|
"trae.models": "{count} 个模型",
|
|
294
362
|
"trae.noModels": "还没有发布模型",
|
|
295
363
|
"trae.off": "Trae 来源已在插件设置里关闭。",
|
|
296
|
-
"trae.fallback": "
|
|
364
|
+
"trae.fallback": "首选端口 {port} 被占用,本次改听备用端口,供应商行跟随本次地址",
|
|
297
365
|
"qoder.title": "Qoder",
|
|
298
366
|
"qoder.gateway": "{region}网关,端口 {port}",
|
|
299
367
|
"qoder.models": "{count} 个模型",
|
|
@@ -320,7 +388,7 @@ var ZH = {
|
|
|
320
388
|
"source.noCampaign": "该账号无签到活动",
|
|
321
389
|
"source.campaignUnknown": "签到状态读取失败",
|
|
322
390
|
"source.deviceCheckedIn": "本机今日已签到",
|
|
323
|
-
"qoder.fallback": "
|
|
391
|
+
"qoder.fallback": "首选端口 {port} 被占用,本次改听备用端口,供应商行跟随本次地址",
|
|
324
392
|
"badge.next": "下一个",
|
|
325
393
|
"source.claimableAt": "{time} 后可签到",
|
|
326
394
|
"badge.cooling": "冷却中",
|
|
@@ -337,15 +405,22 @@ var ZH = {
|
|
|
337
405
|
"acct.automatic": "自动选择(按使用方式)",
|
|
338
406
|
"acct.choiceHint": "优先用所选账号,限流时临时换号;自动选择则按使用方式分配。",
|
|
339
407
|
"acct.unavailable": "所选账号暂不可用(自动换号)",
|
|
408
|
+
"acct.expired": "登录已过期",
|
|
409
|
+
"acct.archivedHint": "国际版只保留一个登录文件,切号时本账号的登录被覆盖。令牌已留存,账号可用到令牌到期。在 WorkBuddy 里重新登录可续期。",
|
|
340
410
|
"acct.choiceCredits": "{label} · {credits} 积分",
|
|
341
411
|
"badge.preferred": "已选",
|
|
342
412
|
"acct.on": "启用中",
|
|
343
413
|
"acct.off": "已停用",
|
|
344
414
|
"acct.switchOn": "重新使用该账号",
|
|
415
|
+
"acct.inPool": "参与轮换",
|
|
345
416
|
"acct.switchOff": "暂时不使用该账号",
|
|
346
417
|
"acct.offHint": "已停用:在重新启用之前,请求不会使用该账号。",
|
|
347
418
|
"acct.remove": "移除",
|
|
348
|
-
"acct.removeHint": "
|
|
419
|
+
"acct.removeHint": "把账号移出账号池;可在「已移除的账号」里恢复。",
|
|
420
|
+
"acct.delete": "删除",
|
|
421
|
+
"acct.deleteHint": "删掉这个插件自己写下的登录文件。账号就此没有了,不能恢复。",
|
|
422
|
+
"acct.deleteConfirm": "要删除 {name} 吗?登录文件会被删掉,这个账号再也回不来。",
|
|
423
|
+
"acct.deleteConfirmAgain": "再按一次确认删除",
|
|
349
424
|
"acct.stateError": "账号设置失败:{message}",
|
|
350
425
|
"pool.switchedOff": "{count} 个已停用",
|
|
351
426
|
"removed.title": "已移除的账号",
|
|
@@ -397,6 +472,7 @@ var ZH = {
|
|
|
397
472
|
"models.windowFollows": "跟随目录;手动修改后会固定为你的值。",
|
|
398
473
|
"models.maxOutput": "最大输出",
|
|
399
474
|
"models.outputHelp": "该模型单次回复的最大长度。",
|
|
475
|
+
"models.overCeiling": "该模型最多只接受 {limit},更大的数值没有生效。",
|
|
400
476
|
"models.levels": "思考等级",
|
|
401
477
|
"models.defaultLevel": "默认思考等级",
|
|
402
478
|
"models.capabilities": "附件",
|
|
@@ -409,7 +485,6 @@ var ZH = {
|
|
|
409
485
|
"models.dirty": "有未保存的修改",
|
|
410
486
|
"models.saving": "保存中…",
|
|
411
487
|
"models.saved": "模型选择已保存",
|
|
412
|
-
"models.applyHint": "已保存。模型选择器没同步时,重新加载插件。",
|
|
413
488
|
"models.saveError": "保存失败:{message}",
|
|
414
489
|
"models.reload": "模型列表有变化。重新加载插件后同步。",
|
|
415
490
|
"models.addressDrift": "对外公布的地址与本次运行的地址不一致。重新加载插件。",
|
|
@@ -435,6 +510,41 @@ var ZH = {
|
|
|
435
510
|
"composer.hint": "开启后,选中本插件的模型时,输入框左侧显示正在使用的账号积分。点开可以换号。",
|
|
436
511
|
"composer.show": "显示积分",
|
|
437
512
|
"composer.hide": "隐藏积分",
|
|
513
|
+
"rewrite.title": "客户端名称",
|
|
514
|
+
"rewrite.on": "已开启",
|
|
515
|
+
"rewrite.off": "已关闭",
|
|
516
|
+
"rewrite.label": "改写发往国内版的提示词里的客户端名称",
|
|
517
|
+
"rewrite.hint": "WorkBuddy 国内版会拒绝提示词里把自己称作 DeepSeek Harness 的对话请求(渠道校验 11128)。开启后,提示词里这个名称的每一处都改为 DeepSeek;关闭后恢复原名。",
|
|
518
|
+
"rewrite.show": "改写名称",
|
|
519
|
+
"rewrite.hide": "恢复原名",
|
|
520
|
+
"growth.title": "成长中心",
|
|
521
|
+
"growth.ready": "WorkBuddy",
|
|
522
|
+
"growth.running": "运行中…",
|
|
523
|
+
"growth.read": "读取状态",
|
|
524
|
+
"growth.reading": "读取中…",
|
|
525
|
+
"growth.readHint": "只读成长中心现在有什么,不领。",
|
|
526
|
+
"growth.run": "立即执行",
|
|
527
|
+
"growth.runHint": "单独执行定时签到里那段成长链路,并按步骤报告结果。",
|
|
528
|
+
"growth.hint": "四项:补签卡、礼包与补偿、活跃上报、连登档位与抽奖。补签卡与抽奖次数在执行后扣减,其余分项可重复执行,不会二次到账。",
|
|
529
|
+
"growth.stateNone": "还没有读过状态",
|
|
530
|
+
"growth.stateStale": "跑过一趟之后状态就旧了,点「读取状态」更新",
|
|
531
|
+
"growth.stateSummary": "{accounts} 个账号 · 可兑换 {tiers} 档 · 补签卡 {cards} 张 · 抽奖 {chances} 次",
|
|
532
|
+
"growth.groupCount": "{count} 个账号",
|
|
533
|
+
"growth.stateFailed": "{failed} 个账号读不出来",
|
|
534
|
+
"growth.rowSummary": "连登 {days} 天 · 下一档 {tier},还差 {remaining} 天",
|
|
535
|
+
"growth.rowHold": "可兑换 {tiers} 档 · 补签卡 {cards} 张 · 抽奖 {chances} 次",
|
|
536
|
+
"growth.rowTiers": "连登档位",
|
|
537
|
+
"growth.rowTier": "{tier} · {days} 天 · +{credit} 积分 +{energy} 能量 · {status}",
|
|
538
|
+
"growth.tierClaimed": "已领取",
|
|
539
|
+
"growth.tierUnlocked": "可兑换",
|
|
540
|
+
"growth.tierLocked": "未解锁",
|
|
541
|
+
"growth.rowNothing": "这里没有可领的",
|
|
542
|
+
"growth.rowFailed": "这个账号读不出来",
|
|
543
|
+
"growth.onlyWorkbuddy": "成长中心只跟 WorkBuddy 有关。",
|
|
544
|
+
"growth.runNone": "这一趟没有可领的",
|
|
545
|
+
"growth.runLine": "{when}:补签 {makeup} · 礼包 +{gift} · 补偿 +{compensation} · 活跃上报 {activity} · 档位 {streak} · 抽奖 {lottery} · 共 +{credit} 积分",
|
|
546
|
+
"growth.runFailed": "{when}:{failed} 个步骤失败",
|
|
547
|
+
"growth.busy": "签到正在跑,等它跑完",
|
|
438
548
|
"auto.hours": "时间",
|
|
439
549
|
"auto.hoursHint": "按北京时间(UTC+8),如 9 或 9,21",
|
|
440
550
|
"auto.hoursSave": "保存时间",
|
|
@@ -450,9 +560,14 @@ var ZH = {
|
|
|
450
560
|
"auto.rowQoder": "Qoder",
|
|
451
561
|
"auto.rowTrae": "Trae",
|
|
452
562
|
"auto.rowCounts": "{label}:领取 {claimed} · 跳过 {skipped} · 失败 {failed}",
|
|
453
|
-
"auto.rowGrowth": "
|
|
563
|
+
"auto.rowGrowth": "连登:{streak} 档 · +{credit} 积分 · 失败 {failed}",
|
|
564
|
+
"auto.rowKeepAlive": "令牌保活 {when}:刷新 {refreshed} 个 · 无需处理 {fresh} 个 · 失败 {failed} 个 · 无刷新令牌 {noToken} 个",
|
|
454
565
|
"auto.rowTravelCounts": "{label}:派出 {departed} · 领奖 {claimed} · 领养 {adopted}",
|
|
455
|
-
"auto.hint": "时间到后一次性领取三家(WorkBuddy / Trae / Qoder)的签到奖励、WorkBuddy
|
|
566
|
+
"auto.hint": "时间到后一次性领取三家(WorkBuddy / Trae / Qoder)的签到奖励、WorkBuddy 国内账号的连登奖励,并顺带完成猫猫旅行;今天已领过的时段跳过。当天错过的时段在下次启动时补领。",
|
|
567
|
+
"keepAlive.runNow": "立即刷新",
|
|
568
|
+
"keepAlive.running": "刷新中…",
|
|
569
|
+
"keepAlive.label": "登录令牌保活",
|
|
570
|
+
"keepAlive.hint": "按需续上快到期的登录令牌,久未使用的账号因此不会在下一趟对话上撞到已过期的令牌。有效期还长的令牌不发请求。",
|
|
456
571
|
"auto.badHours": "时间请填 0–23 的整数小时,例如 9 或 9,21。",
|
|
457
572
|
"check.title": "连接检查",
|
|
458
573
|
"check.empty": "运行检查可以看到对话能否连上 WorkBuddy、Trae 或 Qoder。",
|
|
@@ -591,7 +706,9 @@ function tagOf(model) {
|
|
|
591
706
|
function clockHour(hour) {
|
|
592
707
|
var value = Math.round(Number(hour));
|
|
593
708
|
if (!Number.isFinite(value)) return "";
|
|
594
|
-
|
|
709
|
+
// 24 is a real edge: the promo module reports it for "free until the end of
|
|
710
|
+
// the day". Clamping it to 23 told the user the discount stops an hour early.
|
|
711
|
+
value = Math.max(0, Math.min(24, value));
|
|
595
712
|
return (value < 10 ? "0" : "") + value + ":00";
|
|
596
713
|
}
|
|
597
714
|
|
|
@@ -644,10 +761,57 @@ function setActiveRegion(source, region) {
|
|
|
644
761
|
* Unsaved model edits, one per page (source + region).
|
|
645
762
|
*
|
|
646
763
|
* A single slot threw the edits away the moment the user looked at another page:
|
|
647
|
-
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
764
|
+
/**
|
|
765
|
+
* The growth centre's last read, and whether one is in flight.
|
|
766
|
+
*
|
|
767
|
+
* The host keeps the result and hands it back with the status document, so a
|
|
768
|
+
* repaint or a fresh panel paints the figures it already has; a *read* is only
|
|
769
|
+
* issued when those figures are gone or old. Holding the read only here meant
|
|
770
|
+
* every panel reload asked the user to go press a button to see what had just
|
|
771
|
+
* been on screen.
|
|
772
|
+
*/
|
|
773
|
+
var growthState = null;
|
|
774
|
+
var growthReading = false;
|
|
775
|
+
/** The account whose delete button is armed, and the timer that disarms it. */
|
|
776
|
+
var pendingDelete = null;
|
|
777
|
+
var deleteTimer = 0;
|
|
778
|
+
/**
|
|
779
|
+
* How many times the host has dropped the read, so a read already in flight can
|
|
780
|
+
* tell that its own answer is about a pool that no longer exists.
|
|
781
|
+
*/
|
|
782
|
+
var growthDropped = 0;
|
|
783
|
+
/** How long a read stays current before entering the page refreshes it. */
|
|
784
|
+
var GROWTH_STALE_MS = 2 * 60 * 1000;
|
|
785
|
+
|
|
786
|
+
/** True when the figures on this card are gone, old, or older than the last run. */
|
|
787
|
+
function growthStale() {
|
|
788
|
+
if (growthState === null) return true;
|
|
789
|
+
var readAt = typeof growthState.readAt === "number" ? growthState.readAt : null;
|
|
790
|
+
if (readAt === null) return true;
|
|
791
|
+
// A run since the read spent what the rows describe, so they are stale even
|
|
792
|
+
// when they are only a moment old. The scheduled pass records its growth half
|
|
793
|
+
// inside `autoCheckin.last.growth`, so the run time comes from the same place
|
|
794
|
+
// the log line does - reading only `growth.last` missed it and kept showing
|
|
795
|
+
// the figures from before the pass that just spent them.
|
|
796
|
+
var last = growthLastRun();
|
|
797
|
+
var ranAt = last ? Date.parse(last.at) : NaN;
|
|
798
|
+
if (Number.isFinite(ranAt) && ranAt > readAt) return true;
|
|
799
|
+
// A read stamped in the future is a clock that moved, not a fresh read: it
|
|
800
|
+
// would otherwise never age, and the card would keep a stale figure forever.
|
|
801
|
+
if (readAt > Date.now() + GROWTH_STALE_MS) return true;
|
|
802
|
+
return Date.now() - readAt > GROWTH_STALE_MS;
|
|
803
|
+
}
|
|
804
|
+
/** Which growth rows are expanded, keyed by account id. */
|
|
805
|
+
var openGrowth = {};
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* The model sheet's draft: the edits of the models ticked on the roster.
|
|
809
|
+
*
|
|
810
|
+
* Held in a slot rather than in one object, because the draft is rebuilt from
|
|
811
|
+
* the saved selection whenever the key changes, so the ticks were gone on the
|
|
812
|
+
* way back and nothing said so. Inside a slot the key is still the id set the
|
|
813
|
+
* draft was built from, so a catalog that gains or loses a model rebuilds it
|
|
814
|
+
* rather than reusing a shape it knows nothing about.
|
|
651
815
|
*/
|
|
652
816
|
var drafts = {};
|
|
653
817
|
/** model id -> { enabled, alias, window, output, images, levels, defaultLevel, open } */
|
|
@@ -656,7 +820,15 @@ var draft = null;
|
|
|
656
820
|
var draftSlot = null;
|
|
657
821
|
var busy = null; // id of the control awaiting a response
|
|
658
822
|
var checkinBusy = null;
|
|
823
|
+
/** Set while a panel login is waiting on the browser, so its button reads as busy. */
|
|
824
|
+
var loginBusy = false;
|
|
825
|
+
/** The URL of the login in flight, so the button can offer it again. */
|
|
826
|
+
var loginUrl = "";
|
|
827
|
+
/** Timer id of the poll loop; cleared when a login ends or the page goes away. */
|
|
828
|
+
var loginTimer = 0;
|
|
659
829
|
var doctorResult = null;
|
|
830
|
+
/** Hours text typed but not yet saved, so a poll cannot overwrite it. */
|
|
831
|
+
var autoHoursDraft = null;
|
|
660
832
|
/** Account ids whose credit package list the user opened. Absent = collapsed. */
|
|
661
833
|
var openCredits = {};
|
|
662
834
|
/** The warning the header banner is currently showing, so it can be cleared. */
|
|
@@ -736,6 +908,8 @@ function sourceOn(source) {
|
|
|
736
908
|
}
|
|
737
909
|
/** The selected source: the top-level tab, one page of every view at a time. */
|
|
738
910
|
var activeSource = "workbuddy";
|
|
911
|
+
/** Which view page is on screen; the growth tab is hidden off WorkBuddy. */
|
|
912
|
+
var activeTab = "pool";
|
|
739
913
|
|
|
740
914
|
/**
|
|
741
915
|
* Mirror the source tabs onto everything that is per source: the pool's three
|
|
@@ -759,6 +933,11 @@ function renderSourceTabs() {
|
|
|
759
933
|
renderModelRegionTabs();
|
|
760
934
|
renderModels();
|
|
761
935
|
renderFooter();
|
|
936
|
+
// The growth page is WorkBuddy's, so leaving that source has to take its tab
|
|
937
|
+
// with it and drop back to the pool rather than leave a selected tab whose
|
|
938
|
+
// view is the one just hidden.
|
|
939
|
+
labelTabs();
|
|
940
|
+
if (activeSource !== "workbuddy" && activeTab === "growth") selectTab("pool");
|
|
762
941
|
}
|
|
763
942
|
|
|
764
943
|
/**
|
|
@@ -800,9 +979,15 @@ function regionToggle(source, region) {
|
|
|
800
979
|
return button;
|
|
801
980
|
}
|
|
802
981
|
|
|
803
|
-
/**
|
|
804
|
-
|
|
805
|
-
|
|
982
|
+
/**
|
|
983
|
+
* A parked region's notice and its switch.
|
|
984
|
+
*
|
|
985
|
+
* The tag is a parameter rather than fixed because this block lands in two kinds
|
|
986
|
+
* of container: the accounts column is a `div`, while the model roster is a
|
|
987
|
+
* `ul` and only accepts list items.
|
|
988
|
+
*/
|
|
989
|
+
function parkedRegionBlock(source, region, tag) {
|
|
990
|
+
var block = el(tag || "div", "empty");
|
|
806
991
|
block.appendChild(el("p", null, t("region.parked", { region: sourceRegionLabel(region) })));
|
|
807
992
|
block.appendChild(regionToggle(source, region));
|
|
808
993
|
return block;
|
|
@@ -839,6 +1024,9 @@ function fillRegionNav(nav, source, regions, accounts, active) {
|
|
|
839
1024
|
button.type = "button";
|
|
840
1025
|
button.disabled = busy !== null;
|
|
841
1026
|
button.setAttribute("role", "tab");
|
|
1027
|
+
// A `tab` without `aria-selected` is invalid ARIA, and it is what a screen
|
|
1028
|
+
// reader reads to say which one is current.
|
|
1029
|
+
button.setAttribute("aria-selected", on ? "true" : "false");
|
|
842
1030
|
button.textContent = sourceRegionLabel(region);
|
|
843
1031
|
if (regionParked(source, region)) button.appendChild(el("span", "muted", " " + t("region.parkedShort")));
|
|
844
1032
|
var count = accounts.filter(function (account) { return account.region === region; }).length;
|
|
@@ -878,6 +1066,12 @@ function sourcePreferredPicker(source, region, accounts) {
|
|
|
878
1066
|
accounts.forEach(function (account) {
|
|
879
1067
|
var option = el("option", null, account.label);
|
|
880
1068
|
option.value = account.label;
|
|
1069
|
+
// Listed but not selectable: the host refuses an expired account as the
|
|
1070
|
+
// preferred one, so offering it turned a click into an error.
|
|
1071
|
+
if (account.expired === true) {
|
|
1072
|
+
option.disabled = true;
|
|
1073
|
+
option.textContent = account.label + " · " + t("acct.expired");
|
|
1074
|
+
}
|
|
881
1075
|
picker.appendChild(option);
|
|
882
1076
|
});
|
|
883
1077
|
var preferred = ((state[source] || {}).preferred || {})[region] || "";
|
|
@@ -954,6 +1148,21 @@ function renderWorkbuddyHead() {
|
|
|
954
1148
|
allButton.addEventListener("click", claimAllCheckins);
|
|
955
1149
|
host.appendChild(allButton);
|
|
956
1150
|
|
|
1151
|
+
// Adding an account from here, rather than only from the desktop app: a user
|
|
1152
|
+
// with no WorkBuddy install on this machine had no way into the pool at all.
|
|
1153
|
+
// It sits beside the check-in button because it is the other action that
|
|
1154
|
+
// concerns every account rather than one. While a login is waiting it offers
|
|
1155
|
+
// the link again — the browser tab is the easiest thing to lose, and a login
|
|
1156
|
+
// whose URL is gone looks broken rather than unfinished.
|
|
1157
|
+
var addButton = el("button", "ghost small ic-plus" + (loginBusy ? " is-busy" : ""),
|
|
1158
|
+
loginBusy ? t("login.openAgain") : t("login.add"));
|
|
1159
|
+
addButton.type = "button";
|
|
1160
|
+
addButton.id = "loginAddBtn";
|
|
1161
|
+
addButton.title = t("login.addHint");
|
|
1162
|
+
addButton.disabled = busy !== null || checkinBusy !== null;
|
|
1163
|
+
addButton.addEventListener("click", loginBusy ? reopenLogin : startLogin);
|
|
1164
|
+
host.appendChild(addButton);
|
|
1165
|
+
|
|
957
1166
|
if (off > 0) host.appendChild(el("span", "muted", t("pool.switchedOff", { count: off })));
|
|
958
1167
|
}
|
|
959
1168
|
|
|
@@ -962,7 +1171,7 @@ function renderPoolStrip() {
|
|
|
962
1171
|
var strip = $("poolStrip");
|
|
963
1172
|
clear(strip);
|
|
964
1173
|
var accounts = accountsOf(activeRegion);
|
|
965
|
-
var cooling = accounts.filter(function (a) { return a.cooling; }).length;
|
|
1174
|
+
var cooling = accounts.filter(function (a) { return a.disabled !== true && a.cooling; }).length;
|
|
966
1175
|
var off = accounts.filter(function (a) { return a.disabled === true; }).length;
|
|
967
1176
|
// Only the accounts that can serve are counted: a switched-off account is not
|
|
968
1177
|
// rate-limited, so counting it here would read "every account is rate-limited"
|
|
@@ -1250,7 +1459,7 @@ function renderSourceStrip(source) {
|
|
|
1250
1459
|
shown.forEach(function (gateway) {
|
|
1251
1460
|
var parts = [t(section.gateway, { region: sourceRegionLabel(gateway.region), port: gateway.port }),
|
|
1252
1461
|
gateway.models > 0 ? t(section.models, { count: gateway.models }) : t(section.noModels)];
|
|
1253
|
-
if (gateway.portFallback) parts.push(t(section.fallback, { port: gateway.port }));
|
|
1462
|
+
if (gateway.portFallback) parts.push(t(section.fallback, { port: gateway.preferredPort || gateway.port }));
|
|
1254
1463
|
if (gateway.lastError) parts.push(gateway.lastError);
|
|
1255
1464
|
foot.appendChild(el("span", "muted", parts.join(" · ")));
|
|
1256
1465
|
});
|
|
@@ -1273,7 +1482,7 @@ function claimSourceCheckins(source) {
|
|
|
1273
1482
|
render();
|
|
1274
1483
|
if (payload && payload.running === true) {
|
|
1275
1484
|
// The pass outlived the plugin's answer and is still collecting: the
|
|
1276
|
-
//
|
|
1485
|
+
// the panel reports it when it lands.
|
|
1277
1486
|
announce(t("pool.checkinAllBusy"));
|
|
1278
1487
|
return;
|
|
1279
1488
|
}
|
|
@@ -1295,6 +1504,88 @@ function claimSourceCheckins(source) {
|
|
|
1295
1504
|
});
|
|
1296
1505
|
}
|
|
1297
1506
|
|
|
1507
|
+
/** How often a started login is polled while the browser has not finished. */
|
|
1508
|
+
var LOGIN_POLL_MS = 3000;
|
|
1509
|
+
/** How long the panel keeps polling before it tells the user to start again. */
|
|
1510
|
+
var LOGIN_GIVE_UP_MS = 15 * 60 * 1000;
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Add a WorkBuddy account by signing in through the browser.
|
|
1514
|
+
*
|
|
1515
|
+
* The region is the one on screen: the pool is split by gateway, so an account
|
|
1516
|
+
* added here belongs to the region the user is looking at rather than to
|
|
1517
|
+
* whichever one the login page happens to default to.
|
|
1518
|
+
*/
|
|
1519
|
+
function startLogin() {
|
|
1520
|
+
if (busy !== null || checkinBusy !== null || loginBusy) return;
|
|
1521
|
+
var realm = activeRegion === "global" ? "global" : "cn";
|
|
1522
|
+
loginBusy = true;
|
|
1523
|
+
render();
|
|
1524
|
+
invoke("xd.startLogin", { realm: realm }).then(function (answer) {
|
|
1525
|
+
loginUrl = answer && typeof answer.authUrl === "string" ? answer.authUrl : "";
|
|
1526
|
+
if (loginUrl === "") throw new Error("the plugin did not return a login link");
|
|
1527
|
+
// This page is a real browser tab, so the link opens the way its own footer
|
|
1528
|
+
// links do: a new tab, leaving the panel where it is.
|
|
1529
|
+
window.open(loginUrl, "_blank", "noopener,noreferrer");
|
|
1530
|
+
}).then(function () {
|
|
1531
|
+
note(t("login.waiting"));
|
|
1532
|
+
pollLogin(realm, Date.now() + LOGIN_GIVE_UP_MS);
|
|
1533
|
+
}).catch(function (error) {
|
|
1534
|
+
loginBusy = false;
|
|
1535
|
+
note(String(error && error.message ? error.message : error));
|
|
1536
|
+
render();
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Ask the plugin whether the browser has finished, and again shortly if not.
|
|
1542
|
+
*
|
|
1543
|
+
* The loop is the panel's own: the plugin holds no timer, so a page that is
|
|
1544
|
+
* closed stops asking instead of leaving a poll running against a state nobody
|
|
1545
|
+
* is watching.
|
|
1546
|
+
*/
|
|
1547
|
+
function pollLogin(realm, giveUpAt) {
|
|
1548
|
+
window.clearTimeout(loginTimer);
|
|
1549
|
+
loginTimer = window.setTimeout(function () {
|
|
1550
|
+
if (!loginBusy) return;
|
|
1551
|
+
if (Date.now() > giveUpAt) {
|
|
1552
|
+
loginBusy = false;
|
|
1553
|
+
note(t("login.timeout"));
|
|
1554
|
+
render();
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
invoke("xd.pollLogin", { realm: realm }).then(function (answer) {
|
|
1558
|
+
if (!loginBusy) return;
|
|
1559
|
+
if (answer && answer.status === "ok") {
|
|
1560
|
+
loginBusy = false;
|
|
1561
|
+
note(null);
|
|
1562
|
+
adopt(answer.state);
|
|
1563
|
+
render();
|
|
1564
|
+
announce(answer.nickname
|
|
1565
|
+
? t("login.added", { name: answer.nickname })
|
|
1566
|
+
: t("login.addedNoName"));
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
pollLogin(realm, giveUpAt);
|
|
1570
|
+
}).catch(function (error) {
|
|
1571
|
+
loginBusy = false;
|
|
1572
|
+
note(String(error && error.message ? error.message : error));
|
|
1573
|
+
render();
|
|
1574
|
+
});
|
|
1575
|
+
}, LOGIN_POLL_MS);
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Offer the login link again.
|
|
1580
|
+
*
|
|
1581
|
+
* The browser tab is the easiest thing to lose — closed, or the click never
|
|
1582
|
+
* landed — and a login whose URL is gone looks broken rather than unfinished.
|
|
1583
|
+
*/
|
|
1584
|
+
function reopenLogin() {
|
|
1585
|
+
if (loginUrl === "") return;
|
|
1586
|
+
window.open(loginUrl, "_blank", "noopener,noreferrer");
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1298
1589
|
/**
|
|
1299
1590
|
* What to say when a check-in round reports failures.
|
|
1300
1591
|
*
|
|
@@ -1418,7 +1709,9 @@ function renderAutoCheckin() {
|
|
|
1418
1709
|
$("autoHoursLabel").textContent = t("auto.hours");
|
|
1419
1710
|
var input = $("autoHours");
|
|
1420
1711
|
input.placeholder = t("auto.hoursHint");
|
|
1421
|
-
if (document.activeElement !== input)
|
|
1712
|
+
if (document.activeElement !== input) {
|
|
1713
|
+
input.value = autoHoursDraft !== null ? autoHoursDraft : (auto.hours || []).join(",");
|
|
1714
|
+
}
|
|
1422
1715
|
var save = $("autoHoursSave");
|
|
1423
1716
|
save.textContent = t("auto.hoursSave");
|
|
1424
1717
|
save.disabled = busy !== null;
|
|
@@ -1430,8 +1723,18 @@ function renderAutoCheckin() {
|
|
|
1430
1723
|
run.textContent = busy === "checkin" ? t("auto.running") : t("auto.runNow");
|
|
1431
1724
|
run.title = t("auto.runNowHint");
|
|
1432
1725
|
run.disabled = busy !== null;
|
|
1726
|
+
|
|
1727
|
+
// The keep-alive row: one button, run by hand. It is a static node, so the
|
|
1728
|
+
// handler lives in `bind`.
|
|
1729
|
+
var keepAliveRun = $("tokenKeepAliveRun");
|
|
1730
|
+
keepAliveRun.textContent = busy === "keepAlive" ? t("keepAlive.running") : t("keepAlive.runNow");
|
|
1731
|
+
keepAliveRun.disabled = busy !== null;
|
|
1732
|
+
$("keepAliveText").textContent = t("keepAlive.label");
|
|
1733
|
+
$("keepAliveHint").textContent = t("keepAlive.hint");
|
|
1433
1734
|
$("autoHint").textContent = t("auto.hint");
|
|
1434
|
-
|
|
1735
|
+
// The keep-alive is a sibling of the schedule in the document rather than a
|
|
1736
|
+
// field of it, so the log's reader is handed the two halves it needs.
|
|
1737
|
+
paintAutoNote($("autoNote"), { last: auto.last, keepAlive: state && state.keepAlive });
|
|
1435
1738
|
}
|
|
1436
1739
|
|
|
1437
1740
|
/**
|
|
@@ -1458,6 +1761,26 @@ function renderComposerPoints() {
|
|
|
1458
1761
|
$("composerPointsHint").textContent = t("composer.hint");
|
|
1459
1762
|
}
|
|
1460
1763
|
|
|
1764
|
+
/**
|
|
1765
|
+
* The client-name switch.
|
|
1766
|
+
*
|
|
1767
|
+
* Same shape as the credits switch above, and for the same reason: the label says
|
|
1768
|
+
* what pressing it will do and which way it currently stands. Off by default -
|
|
1769
|
+
* turning it on is the user's decision, because it changes what the prompt tells
|
|
1770
|
+
* the upstream about the client.
|
|
1771
|
+
*/
|
|
1772
|
+
function renderRewriteClientName() {
|
|
1773
|
+
var renamed = state !== null && typeof state.replacedClientName === "string";
|
|
1774
|
+
$("rewriteTitle").textContent = t("rewrite.title");
|
|
1775
|
+
$("rewriteState").textContent = renamed ? t("rewrite.on") : t("rewrite.off");
|
|
1776
|
+
var button = $("rewriteClientName");
|
|
1777
|
+
button.textContent = t(renamed ? "rewrite.hide" : "rewrite.show");
|
|
1778
|
+
button.className = "small" + (renamed ? " on" : "");
|
|
1779
|
+
button.disabled = busy !== null;
|
|
1780
|
+
$("rewriteText").textContent = t("rewrite.label");
|
|
1781
|
+
$("rewriteHint").textContent = t("rewrite.hint");
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1461
1784
|
/**
|
|
1462
1785
|
* The check-in log: one row per source, each with a state dot.
|
|
1463
1786
|
*
|
|
@@ -1471,19 +1794,48 @@ function renderComposerPoints() {
|
|
|
1471
1794
|
*/
|
|
1472
1795
|
function autoNoteRows(auto) {
|
|
1473
1796
|
var last = auto.last;
|
|
1474
|
-
|
|
1797
|
+
// The keep-alive is a duty of its own rather than a stage of the pass, so it
|
|
1798
|
+
// reports on its own line and says when it last ran - on every path, including
|
|
1799
|
+
// the ones that have nothing to say about a check-in pass. Its record is the
|
|
1800
|
+
// only proof the button did anything, and a restart clears the pass log without
|
|
1801
|
+
// touching it.
|
|
1802
|
+
var keepAliveRow = null;
|
|
1803
|
+
if (auto.keepAlive) {
|
|
1804
|
+
keepAliveRow = {
|
|
1805
|
+
text: t("auto.rowKeepAlive", {
|
|
1806
|
+
when: formatStamp(auto.keepAlive.at),
|
|
1807
|
+
refreshed: Number(auto.keepAlive.refreshed) || 0,
|
|
1808
|
+
fresh: Number(auto.keepAlive.fresh) || 0,
|
|
1809
|
+
failed: Number(auto.keepAlive.failed) || 0,
|
|
1810
|
+
noToken: Number(auto.keepAlive.noToken) || 0,
|
|
1811
|
+
}),
|
|
1812
|
+
tone: Number(auto.keepAlive.failed) > 0 || Number(auto.keepAlive.noToken) > 0 ? "fail"
|
|
1813
|
+
: Number(auto.keepAlive.refreshed) > 0 ? "ok" : "",
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
// What the pass log has to say, with the keep-alive line kept on the end.
|
|
1817
|
+
var finish = function (rows) {
|
|
1818
|
+
if (keepAliveRow !== null) rows.push(keepAliveRow);
|
|
1819
|
+
return rows;
|
|
1820
|
+
};
|
|
1821
|
+
if (!last) return finish([{ text: t("auto.neverRun"), tone: "" }]);
|
|
1475
1822
|
// Opening stub: sources have not answered yet. A finished "0 accounts" row
|
|
1476
1823
|
// here is what "run now" painted and then never replaced.
|
|
1477
1824
|
if (last.pending === true && last.travel == null && last.qoder == null && last.trae == null) {
|
|
1478
|
-
return [{ text: t("auto.running"), tone: "" }];
|
|
1825
|
+
return finish([{ text: t("auto.running"), tone: "" }]);
|
|
1479
1826
|
}
|
|
1480
1827
|
var slot = String(last.slot).replace("T", " ");
|
|
1481
|
-
if (last.error) return [{ text: t("auto.lastFailedAt", { slot: slot, message: last.error }), tone: "fail" }];
|
|
1828
|
+
if (last.error) return finish([{ text: t("auto.lastFailedAt", { slot: slot, message: last.error }), tone: "fail" }]);
|
|
1482
1829
|
var rows = [];
|
|
1483
1830
|
if (last.pending === true) rows.push({ text: t("auto.running"), tone: "" });
|
|
1831
|
+
// The head count is every source's claimed accounts, matching the rows
|
|
1832
|
+
// below; `last.claimed` alone is WorkBuddy's share and read as a total.
|
|
1833
|
+
var claimedTotal = (Number(last.claimed) || 0)
|
|
1834
|
+
+ (last.qoder ? Number(last.qoder.claimed) || 0 : 0)
|
|
1835
|
+
+ (last.trae ? Number(last.trae.claimed) || 0 : 0);
|
|
1484
1836
|
rows.push({
|
|
1485
1837
|
text: t(last.manual === true ? "auto.lastManual" : "auto.lastAuto",
|
|
1486
|
-
{ slot: slot, count:
|
|
1838
|
+
{ slot: slot, count: claimedTotal }),
|
|
1487
1839
|
tone: last.pending === true ? "" : "ok",
|
|
1488
1840
|
});
|
|
1489
1841
|
var push = function (label, counts) {
|
|
@@ -1520,24 +1872,27 @@ function autoNoteRows(auto) {
|
|
|
1520
1872
|
if (last.growth) {
|
|
1521
1873
|
var growth = last.growth;
|
|
1522
1874
|
var streakTiers = Number(growth.streak) || 0;
|
|
1523
|
-
var taskCount = Number(growth.tasks) || 0;
|
|
1524
1875
|
rows.push({
|
|
1525
1876
|
text: t("auto.rowGrowth", {
|
|
1526
1877
|
streak: streakTiers,
|
|
1527
|
-
tasks: taskCount,
|
|
1528
1878
|
credit: Number(growth.credit) || 0,
|
|
1529
1879
|
failed: Number(growth.failed) || 0,
|
|
1530
1880
|
}),
|
|
1531
|
-
tone: Number(growth.failed) > 0 ? "fail" : streakTiers > 0
|
|
1881
|
+
tone: Number(growth.failed) > 0 ? "fail" : streakTiers > 0 ? "ok" : "",
|
|
1532
1882
|
});
|
|
1533
1883
|
}
|
|
1534
1884
|
push(t("auto.rowQoder"), last.qoder);
|
|
1535
1885
|
push(t("auto.rowTrae"), last.trae);
|
|
1536
|
-
return rows;
|
|
1886
|
+
return finish(rows);
|
|
1537
1887
|
}
|
|
1538
1888
|
|
|
1539
1889
|
/** Paint the check-in log as rows, so the caller does not build markup inline. */
|
|
1540
1890
|
function paintAutoNote(host, auto) {
|
|
1891
|
+
// A user who scrolled up to read an older line must not be pulled back to the
|
|
1892
|
+
// bottom by every 2 s poll; only a new pass (row count change) or a box that
|
|
1893
|
+
// was already at the bottom follows the tail.
|
|
1894
|
+
var atBottom = host.scrollTop + host.clientHeight >= host.scrollHeight - 4;
|
|
1895
|
+
var rowCount = host.childElementCount;
|
|
1541
1896
|
clear(host);
|
|
1542
1897
|
autoNoteRows(auto).forEach(function (row) {
|
|
1543
1898
|
var line = el("div", "log-line" + (row.tone ? " " + row.tone : ""));
|
|
@@ -1545,10 +1900,287 @@ function paintAutoNote(host, auto) {
|
|
|
1545
1900
|
line.appendChild(el("span", "log-text", row.text));
|
|
1546
1901
|
host.appendChild(line);
|
|
1547
1902
|
});
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1903
|
+
if (host.childElementCount !== rowCount || atBottom) host.scrollTop = host.scrollHeight;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
/** The tier status word, from the flat field the upstream reports it in. */
|
|
1907
|
+
var STATUS_KEY = { unlocked: "growth.tierUnlocked", claimed: "growth.tierClaimed", locked: "growth.tierLocked" };
|
|
1908
|
+
|
|
1909
|
+
/**
|
|
1910
|
+
* The growth centre, on its own page beside the pool and the models.
|
|
1911
|
+
*
|
|
1912
|
+
* Two buttons, because the two halves answer different questions: what the
|
|
1913
|
+
* centre holds right now (a read, safe to press any time) and what a pass
|
|
1914
|
+
* would collect (which spends a make-up card and a draw). Collapsing them into
|
|
1915
|
+
* one button would spend those two without showing them first.
|
|
1916
|
+
*/
|
|
1917
|
+
function renderGrowth() {
|
|
1918
|
+
$("growthTitle").textContent = t("growth.title");
|
|
1919
|
+
var growth = (state && state.growth) || {};
|
|
1920
|
+
var running = growth.running === true;
|
|
1921
|
+
$("growthState").textContent = running ? t("growth.running") : t("growth.ready");
|
|
1922
|
+
var read = $("growthRead");
|
|
1923
|
+
read.textContent = growthReading ? t("growth.reading") : t("growth.read");
|
|
1924
|
+
read.title = t("growth.readHint");
|
|
1925
|
+
read.disabled = busy !== null || running || growthReading;
|
|
1926
|
+
var run = $("growthRun");
|
|
1927
|
+
run.textContent = busy === "growth" ? t("growth.running") : t("growth.run");
|
|
1928
|
+
run.title = t("growth.runHint");
|
|
1929
|
+
run.disabled = busy !== null || running;
|
|
1930
|
+
$("growthText").textContent = growthStateText();
|
|
1931
|
+
paintGrowthAccounts($("growthAccounts"));
|
|
1932
|
+
$("growthHint").textContent = t("growth.hint");
|
|
1933
|
+
paintGrowthNote($("growthNote"));
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
/** The totals line above the rows, summed from the rows the read returned. */
|
|
1937
|
+
function growthStateText() {
|
|
1938
|
+
// A run since the last read leaves the rows holding figures from before it, so
|
|
1939
|
+
// the stale wording names what to do rather than claiming nothing was read.
|
|
1940
|
+
if (growthState === null) {
|
|
1941
|
+
var last = state && state.growth ? state.growth.last : null;
|
|
1942
|
+
return t(last ? "growth.stateStale" : "growth.stateNone");
|
|
1943
|
+
}
|
|
1944
|
+
// The scheduled pass records its growth half inside the pass it belongs to, so
|
|
1945
|
+
// the run time comes from the same place the log line does. Requiring
|
|
1946
|
+
// `state.growth.last` as well kept the stale wording off exactly that case: a
|
|
1947
|
+
// scheduled pass leaves no `growth.last` behind, so the card kept presenting
|
|
1948
|
+
// figures the pass had already spent as current.
|
|
1949
|
+
if (growthStale() && growthLastRun() !== null) return t("growth.stateStale");
|
|
1950
|
+
var rows = (growthState.rows || []).filter(function (row) { return row.failed !== true; });
|
|
1951
|
+
var sum = function (key) {
|
|
1952
|
+
return rows.reduce(function (total, row) { return total + num(row[key], 0); }, 0);
|
|
1953
|
+
};
|
|
1954
|
+
var parts = [t("growth.stateSummary", {
|
|
1955
|
+
accounts: num(growthState.accounts, 0),
|
|
1956
|
+
tiers: sum("tiers"),
|
|
1957
|
+
cards: sum("makeupCards"),
|
|
1958
|
+
chances: sum("lottery"),
|
|
1959
|
+
})];
|
|
1960
|
+
if (num(growthState.failed, 0) > 0) {
|
|
1961
|
+
parts.push(t("growth.stateFailed", { failed: num(growthState.failed, 0) }));
|
|
1962
|
+
}
|
|
1963
|
+
return parts.join(" · ");
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* One account's row: a head carrying the account's own state and what it
|
|
1967
|
+
* holds, and a body with the tiers a run would collect.
|
|
1968
|
+
*
|
|
1969
|
+
* The expand/collapse is the credits block's own shape, reused rather than
|
|
1970
|
+
* restyled: a head button, a caret, and a body shown in place. Toggling in
|
|
1971
|
+
* place matters here too — a rebuild would drop the button that was clicked
|
|
1972
|
+
* and forget where the page was scrolled to.
|
|
1973
|
+
*/
|
|
1974
|
+
function growthRow(row) {
|
|
1975
|
+
var key = "growth:" + row.id;
|
|
1976
|
+
var open = openGrowth[key] === true;
|
|
1977
|
+
var wrap = el("div", "credits" + (open ? " open" : ""));
|
|
1978
|
+
|
|
1979
|
+
var head = el("button", "credits-head");
|
|
1980
|
+
head.type = "button";
|
|
1981
|
+
head.setAttribute("aria-expanded", open ? "true" : "false");
|
|
1982
|
+
head.title = open ? t("credits.collapse") : t("credits.expand");
|
|
1983
|
+
// The realm is the group heading above the row, so the head opens with the
|
|
1984
|
+
// account's own state instead: unread, holding something a run would
|
|
1985
|
+
// collect, or holding nothing left.
|
|
1986
|
+
head.appendChild(el("span", "growth-dot" + growthRowTone(row)));
|
|
1987
|
+
head.appendChild(el("span", "card-title", row.label));
|
|
1988
|
+
head.appendChild(el("span", "count-chip", t("growth.rowHold", {
|
|
1989
|
+
tiers: num(row.tiers, 0),
|
|
1990
|
+
cards: num(row.makeupCards, 0),
|
|
1991
|
+
chances: num(row.lottery, 0),
|
|
1992
|
+
})));
|
|
1993
|
+
head.appendChild(el("span", "caret", "›"));
|
|
1994
|
+
wrap.appendChild(head);
|
|
1995
|
+
|
|
1996
|
+
var body = el("div", "credits-body");
|
|
1997
|
+
body.hidden = !open;
|
|
1998
|
+
if (row.failed === true) {
|
|
1999
|
+
body.appendChild(el("p", "hint warn", t("growth.rowFailed")));
|
|
2000
|
+
} else {
|
|
2001
|
+
if (num(row.days, 0) > 0 || row.nextTier) {
|
|
2002
|
+
body.appendChild(el("p", "hint", t("growth.rowSummary", {
|
|
2003
|
+
days: num(row.days, 0),
|
|
2004
|
+
tier: row.nextTier || "-",
|
|
2005
|
+
remaining: num(row.nextTierRemaining, 0),
|
|
2006
|
+
})));
|
|
2007
|
+
}
|
|
2008
|
+
body.appendChild(el("p", "field-label", t("growth.rowTiers")));
|
|
2009
|
+
var tiers = row.tierList || [];
|
|
2010
|
+
if (tiers.length === 0) {
|
|
2011
|
+
body.appendChild(el("p", "hint", t("growth.rowNothing")));
|
|
2012
|
+
}
|
|
2013
|
+
tiers.forEach(function (tier) {
|
|
2014
|
+
// A tier that can be redeemed now is the one line worth reading at a
|
|
2015
|
+
// glance, so it takes the log line's own dot and full-strength text.
|
|
2016
|
+
var ready = tier.status === "unlocked";
|
|
2017
|
+
var line = el("p", "log-line" + (ready ? " ok" : ""));
|
|
2018
|
+
line.appendChild(el("span", "growth-dot" + (ready ? " ok" : "")));
|
|
2019
|
+
line.appendChild(el("span", "log-text", t("growth.rowTier", {
|
|
2020
|
+
tier: tier.tier,
|
|
2021
|
+
days: num(tier.days, 0),
|
|
2022
|
+
credit: num(tier.credit, 0),
|
|
2023
|
+
energy: num(tier.energy, 0),
|
|
2024
|
+
status: t(STATUS_KEY[tier.status] || "growth.tierLocked"),
|
|
2025
|
+
})));
|
|
2026
|
+
body.appendChild(line);
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
wrap.appendChild(body);
|
|
2030
|
+
|
|
2031
|
+
head.addEventListener("click", function () {
|
|
2032
|
+
var shown = openGrowth[key] !== true;
|
|
2033
|
+
openGrowth[key] = shown;
|
|
2034
|
+
wrap.className = "credits" + (shown ? " open" : "");
|
|
2035
|
+
head.setAttribute("aria-expanded", shown ? "true" : "false");
|
|
2036
|
+
head.title = shown ? t("credits.collapse") : t("credits.expand");
|
|
2037
|
+
body.hidden = !shown;
|
|
2038
|
+
});
|
|
2039
|
+
return wrap;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
/**
|
|
2043
|
+
* The row head's state, as a class suffix: a read that failed, a holding a
|
|
2044
|
+
* run would collect something from, or nothing left to collect.
|
|
2045
|
+
*/
|
|
2046
|
+
function growthRowTone(row) {
|
|
2047
|
+
if (row.failed === true) return " fail";
|
|
2048
|
+
var held = num(row.tiers, 0) + num(row.makeupCards, 0) + num(row.lottery, 0);
|
|
2049
|
+
return held > 0 ? " ok" : "";
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* The account rows, grouped by realm, or the note that says the centre is not
|
|
2054
|
+
* this source's.
|
|
2055
|
+
*
|
|
2056
|
+
* The two editions claim on different schedules and hold different cards, so
|
|
2057
|
+
* they are split under their own heading rather than mixed into one list
|
|
2058
|
+
* where the realm was a badge on each row.
|
|
2059
|
+
*/
|
|
2060
|
+
function paintGrowthAccounts(host) {
|
|
2061
|
+
clear(host);
|
|
2062
|
+
if (activeSource !== "workbuddy") {
|
|
2063
|
+
host.appendChild(el("p", "hint", t("growth.onlyWorkbuddy")));
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
if (growthState === null) return;
|
|
2067
|
+
var rows = growthState.rows || [];
|
|
2068
|
+
if (rows.length === 0) {
|
|
2069
|
+
host.appendChild(el("p", "hint", t("source.noAccounts")));
|
|
2070
|
+
return;
|
|
2071
|
+
}
|
|
2072
|
+
var order = SOURCE_REGIONS.workbuddy.slice();
|
|
2073
|
+
rows.forEach(function (row) {
|
|
2074
|
+
if (order.indexOf(row.region) < 0) order.push(row.region);
|
|
2075
|
+
});
|
|
2076
|
+
order.forEach(function (region) {
|
|
2077
|
+
var group = rows.filter(function (row) { return row.region === region; });
|
|
2078
|
+
if (group.length === 0) return;
|
|
2079
|
+
var head = el("p", "growth-group", regionLabel(region));
|
|
2080
|
+
head.appendChild(el("span", "muted", t("growth.groupCount", { count: group.length })));
|
|
2081
|
+
host.appendChild(head);
|
|
2082
|
+
group.forEach(function (row) { host.appendChild(growthRow(row)); });
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
/** The last growth run, whichever entry point started it. */
|
|
2087
|
+
function growthLastRun() {
|
|
2088
|
+
var growth = (state && state.growth) || {};
|
|
2089
|
+
if (growth.last) return growth.last;
|
|
2090
|
+
var auto = (state && state.autoCheckin) || {};
|
|
2091
|
+
if (auto.last && auto.last.growth) {
|
|
2092
|
+
// The scheduled pass records its growth half inside the pass it belongs to,
|
|
2093
|
+
// so the time to show is the pass's own.
|
|
2094
|
+
return { at: auto.last.at, ...auto.last.growth };
|
|
2095
|
+
}
|
|
2096
|
+
return null;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
/** Paint the growth log as rows, the way the check-in log above it is painted. */
|
|
2100
|
+
function paintGrowthNote(host) {
|
|
2101
|
+
var atBottom = host.scrollTop + host.clientHeight >= host.scrollHeight - 4;
|
|
2102
|
+
var rowCount = host.childElementCount;
|
|
2103
|
+
clear(host);
|
|
2104
|
+
var run = growthLastRun();
|
|
2105
|
+
if (run === null) return;
|
|
2106
|
+
var detail = run.detail || {};
|
|
2107
|
+
var when = formatStamp(run.at);
|
|
2108
|
+
var anything = num(detail.makeup, 0) + num(detail.gift, 0) + num(detail.compensation, 0)
|
|
2109
|
+
+ num(detail.activity, 0) + num(detail.streak, 0) + num(detail.lottery, 0) > 0;
|
|
2110
|
+
var rows = [{
|
|
2111
|
+
text: anything
|
|
2112
|
+
? t("growth.runLine", {
|
|
2113
|
+
when: when,
|
|
2114
|
+
makeup: num(detail.makeup, 0),
|
|
2115
|
+
gift: num(detail.gift, 0),
|
|
2116
|
+
compensation: num(detail.compensation, 0),
|
|
2117
|
+
activity: num(detail.activity, 0),
|
|
2118
|
+
streak: num(detail.streak, 0),
|
|
2119
|
+
lottery: num(detail.lottery, 0),
|
|
2120
|
+
credit: num(run.credit, 0),
|
|
2121
|
+
})
|
|
2122
|
+
: t("growth.runNone"),
|
|
2123
|
+
tone: anything ? "ok" : "",
|
|
2124
|
+
}];
|
|
2125
|
+
var failed = num(detail.failed, 0) > 0 ? num(detail.failed, 0) : num(run.failed, 0);
|
|
2126
|
+
if (failed > 0) {
|
|
2127
|
+
rows.push({ text: t("growth.runFailed", { when: when, failed: failed }), tone: "fail" });
|
|
2128
|
+
}
|
|
2129
|
+
rows.forEach(function (row) {
|
|
2130
|
+
var line = el("div", "log-line" + (row.tone ? " " + row.tone : ""));
|
|
2131
|
+
line.appendChild(el("span", "log-dot"));
|
|
2132
|
+
line.appendChild(el("span", "log-text", row.text));
|
|
2133
|
+
host.appendChild(line);
|
|
2134
|
+
});
|
|
2135
|
+
if (host.childElementCount !== rowCount || atBottom) host.scrollTop = host.scrollHeight;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
/** Ask the host what the growth centre holds, claiming nothing. */
|
|
2139
|
+
function readGrowth() {
|
|
2140
|
+
// `growthReading` alone, not the panel-wide `busy`: a finished run re-reads
|
|
2141
|
+
// its own rows from inside `runBusy`, while `busy` still says "growth".
|
|
2142
|
+
if (growthReading) return Promise.resolve();
|
|
2143
|
+
growthReading = true;
|
|
2144
|
+
var epoch = growthDropped;
|
|
2145
|
+
render();
|
|
2146
|
+
return invoke("xd.growthState").then(function (answer) {
|
|
2147
|
+
growthReading = false;
|
|
2148
|
+
// Dropped while this read ran: what came back describes the pool as it was,
|
|
2149
|
+
// and adopting it would put the dropped rows back with a stamp that says they
|
|
2150
|
+
// are fresh.
|
|
2151
|
+
growthState = epoch === growthDropped && answer && answer.growth ? answer.growth : null;
|
|
2152
|
+
render();
|
|
2153
|
+
}).catch(function (error) {
|
|
2154
|
+
growthReading = false;
|
|
2155
|
+
note(String(error && error.message ? error.message : error));
|
|
2156
|
+
render();
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
/** Run the growth centre on its own. */
|
|
2161
|
+
function runGrowth() {
|
|
2162
|
+
if (busy !== null) return Promise.resolve();
|
|
2163
|
+
return runBusy("growth", function () {
|
|
2164
|
+
return invoke("xd.growthRun").then(function (payload) {
|
|
2165
|
+
// The run answers with the document beside its own counts, and this card
|
|
2166
|
+
// is its only reader: `runBusy` adopts a bare document, which this answer
|
|
2167
|
+
// is not. Adopting it here keeps the pool, the models and the check-in
|
|
2168
|
+
// card following the pass like every other run.
|
|
2169
|
+
if (payload && payload.state) adopt(payload.state);
|
|
2170
|
+
if (payload && payload.running === true) {
|
|
2171
|
+
// The pass outran the answer and is still going: the card follows it
|
|
2172
|
+
// through the document, exactly like the check-in pass.
|
|
2173
|
+
announce(t("growth.running"));
|
|
2174
|
+
return payload;
|
|
2175
|
+
}
|
|
2176
|
+
// The pass just spent whatever the state line was describing, so the
|
|
2177
|
+
// rows are read again rather than left showing what is now collected.
|
|
2178
|
+
return readGrowth();
|
|
2179
|
+
});
|
|
2180
|
+
}).catch(function (error) {
|
|
2181
|
+
var message = String(error && error.message ? error.message : error);
|
|
2182
|
+
note(/BUSY/.test(message) ? t("growth.busy") : message);
|
|
2183
|
+
});
|
|
1552
2184
|
}
|
|
1553
2185
|
function renderAccounts() {
|
|
1554
2186
|
var host = $("accounts");
|
|
@@ -1563,7 +2195,13 @@ function renderAccounts() {
|
|
|
1563
2195
|
|
|
1564
2196
|
function paintAccounts(host) {
|
|
1565
2197
|
clear(host);
|
|
1566
|
-
|
|
2198
|
+
// The first paint has no document yet. Answering with nothing left the column
|
|
2199
|
+
// blank below the header, which read the same as a source with no accounts.
|
|
2200
|
+
if (state === null) {
|
|
2201
|
+
host.appendChild(el("div", "empty", t("state.loading")));
|
|
2202
|
+
host.firstChild.setAttribute("aria-busy", "true");
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
1567
2205
|
var accounts = accountsOf(activeRegion);
|
|
1568
2206
|
// A parked region has no accounts to show: it says so, and offers its switch.
|
|
1569
2207
|
if (activeRegion !== "" && regionParked("workbuddy", activeRegion)) {
|
|
@@ -1659,6 +2297,10 @@ function renderRemoved(host) {
|
|
|
1659
2297
|
|
|
1660
2298
|
function accountCard(account) {
|
|
1661
2299
|
var off = account.disabled === true;
|
|
2300
|
+
|
|
2301
|
+
// Listed but out of rotation: the app overwrote this account's sign-in with
|
|
2302
|
+
// the next one, so the card stays readable but says why it is not picked.
|
|
2303
|
+
var archived = account.archived === true;
|
|
1662
2304
|
var card = el("div", "card account" + (off ? " card-off" : ""));
|
|
1663
2305
|
|
|
1664
2306
|
var head = el("div", "card-head");
|
|
@@ -1668,32 +2310,111 @@ function accountCard(account) {
|
|
|
1668
2310
|
head.appendChild(el("span", "badge next", t("badge.next")));
|
|
1669
2311
|
}
|
|
1670
2312
|
if (account.preferred) head.appendChild(el("span", "badge next", t("badge.preferred")));
|
|
2313
|
+
// An archived account keeps serving, so its badge reports the same health as
|
|
2314
|
+
// any other; the note below the head says where its sign-in now comes from.
|
|
1671
2315
|
head.appendChild(el("span", "badge " + (off ? "off" : account.cooling ? "cool" : "ok"),
|
|
1672
2316
|
off ? t("acct.off") : account.cooling ? t("badge.cooling") : t("badge.healthy")));
|
|
1673
2317
|
|
|
1674
2318
|
// "Not right now" and "not mine any more" are different decisions, so they
|
|
1675
2319
|
// stay separate controls: a switch the user flips, and a plain remove button.
|
|
1676
2320
|
var controls = el("div", "acct-controls");
|
|
2321
|
+
// Greys only while an action is actually touching an account. These used to
|
|
2322
|
+
// follow the whole-panel `busy`, so a refresh or a doctor pass greyed every
|
|
2323
|
+
// row and dropped the labels to a contrast the muted text could not carry.
|
|
2324
|
+
// Any action in flight, not just the account ones: `setAccountState` answers a
|
|
2325
|
+
// press made while another control is busy with "nothing" - it returns without
|
|
2326
|
+
// even raising the busy banner - so a row that stayed enabled was a press that
|
|
2327
|
+
// did nothing and said nothing, on the delete button of all places.
|
|
2328
|
+
var rowBusy = busy !== null;
|
|
2329
|
+
// A row control carries its own id because the focus hand-back has nothing else
|
|
2330
|
+
// to go on: the labels are the same on every row ("remove" four times over),
|
|
2331
|
+
// and the fallback that matches by label put the ring on the first row's button
|
|
2332
|
+
// when the user had pressed the fifth. See `locateControl`.
|
|
2333
|
+
var rowKey = "acct-" + account.id;
|
|
1677
2334
|
var toggle = el("button", "acct-toggle" + (off ? "" : " on"));
|
|
2335
|
+
toggle.id = rowKey + "-toggle";
|
|
1678
2336
|
toggle.type = "button";
|
|
1679
2337
|
toggle.setAttribute("role", "switch");
|
|
1680
2338
|
toggle.setAttribute("aria-checked", off ? "false" : "true");
|
|
2339
|
+
// The name a switch carries is the property it controls and does not change
|
|
2340
|
+
// with its state; the visible label already says which state it is in.
|
|
2341
|
+
toggle.setAttribute("aria-label", t("acct.inPool"));
|
|
1681
2342
|
toggle.title = off ? t("acct.switchOn") : t("acct.switchOff");
|
|
1682
|
-
toggle.disabled =
|
|
2343
|
+
toggle.disabled = rowBusy;
|
|
1683
2344
|
toggle.appendChild(el("span", "acct-toggle-dot"));
|
|
1684
2345
|
toggle.appendChild(el("span", null, off ? t("acct.off") : t("acct.on")));
|
|
1685
2346
|
toggle.addEventListener("click", function () { setAccountState(account.id, off ? "enabled" : "disabled"); });
|
|
1686
2347
|
controls.appendChild(toggle);
|
|
1687
2348
|
|
|
1688
2349
|
var removeBtn = el("button", "acct-remove", t("acct.remove"));
|
|
2350
|
+
removeBtn.id = rowKey + "-remove";
|
|
1689
2351
|
removeBtn.type = "button";
|
|
1690
2352
|
removeBtn.title = t("acct.removeHint");
|
|
1691
|
-
removeBtn.disabled =
|
|
2353
|
+
removeBtn.disabled = rowBusy;
|
|
1692
2354
|
removeBtn.addEventListener("click", function () { setAccountState(account.id, "removed"); });
|
|
1693
2355
|
controls.appendChild(removeBtn);
|
|
2356
|
+
// Only a sign-in this plugin wrote can be deleted. A desktop app's own file
|
|
2357
|
+
// is never offered this: removing it would sign the user out of that app, so
|
|
2358
|
+
// the pool-level "remove" above is as far as it goes.
|
|
2359
|
+
if (account.own === true) {
|
|
2360
|
+
// Irreversible, and unlike "remove" there is no list to restore from, so the
|
|
2361
|
+
// second press is what confirms it. `window.confirm` cannot be used here: the
|
|
2362
|
+
// panel runs in a sandboxed page, where Electron answers a script dialog by
|
|
2363
|
+
// returning false without showing anything - the button looked live and
|
|
2364
|
+
// deleted nothing, every time.
|
|
2365
|
+
//
|
|
2366
|
+
// The armed state lives here rather than on the button: a poll repaint rebuilds
|
|
2367
|
+
// the row every 1.2-2 s, and a flag written onto the node was gone before the
|
|
2368
|
+
// second press arrived, so every press re-armed instead of deleting.
|
|
2369
|
+
var armed = pendingDelete === account.id;
|
|
2370
|
+
var deleteBtn = el("button", armed ? "acct-delete confirming" : "acct-delete", t(armed ? "acct.deleteConfirmAgain" : "acct.delete"));
|
|
2371
|
+
deleteBtn.id = rowKey + "-delete";
|
|
2372
|
+
deleteBtn.type = "button";
|
|
2373
|
+
deleteBtn.title = t("acct.deleteHint");
|
|
2374
|
+
deleteBtn.disabled = rowBusy;
|
|
2375
|
+
deleteBtn.setAttribute("aria-pressed", armed ? "true" : "false");
|
|
2376
|
+
deleteBtn.addEventListener("click", function () {
|
|
2377
|
+
if (pendingDelete !== account.id) {
|
|
2378
|
+
pendingDelete = account.id;
|
|
2379
|
+
note(t("acct.deleteConfirm", { name: account.label }), "warn");
|
|
2380
|
+
// Repaint the list, not just the account picker: the label has to change
|
|
2381
|
+
// to say what the next press does, or the second press looks like the
|
|
2382
|
+
// first one failing.
|
|
2383
|
+
renderAccounts();
|
|
2384
|
+
// A press that is never followed up must not arm the row forever.
|
|
2385
|
+
if (deleteTimer !== 0) clearTimeout(deleteTimer);
|
|
2386
|
+
deleteTimer = setTimeout(function () {
|
|
2387
|
+
deleteTimer = 0;
|
|
2388
|
+
if (pendingDelete !== account.id) return;
|
|
2389
|
+
pendingDelete = null;
|
|
2390
|
+
// The banner still names the account that is no longer armed, so it
|
|
2391
|
+
// reads as "the next press deletes this" beside a button that has gone
|
|
2392
|
+
// back to its first-press label. Cleared only while it is still that
|
|
2393
|
+
// prompt: anything the user has done since is not this timer's to erase.
|
|
2394
|
+
if (bannerText === t("acct.deleteConfirm", { name: account.label })) note("");
|
|
2395
|
+
renderAccounts();
|
|
2396
|
+
}, 8000);
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
// Checked before the arming is consumed: `setAccountState` answers a busy
|
|
2400
|
+
// panel by returning without a word, so clearing the arming first would turn
|
|
2401
|
+
// this press into "did nothing, said nothing" - the exact symptom the two-press
|
|
2402
|
+
// shape exists to remove. The row is disabled while busy anyway; this is the
|
|
2403
|
+
// press that slips in between the click and the repaint.
|
|
2404
|
+
if (busy !== null) {
|
|
2405
|
+
note(t("err.busy"), "warn");
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
if (deleteTimer !== 0) { clearTimeout(deleteTimer); deleteTimer = 0; }
|
|
2409
|
+
pendingDelete = null;
|
|
2410
|
+
setAccountState(account.id, "deleted");
|
|
2411
|
+
});
|
|
2412
|
+
controls.appendChild(deleteBtn);
|
|
2413
|
+
}
|
|
1694
2414
|
head.appendChild(controls);
|
|
1695
2415
|
card.appendChild(head);
|
|
1696
2416
|
|
|
2417
|
+
if (archived) card.appendChild(el("div", "hint muted", t("acct.archivedHint")));
|
|
1697
2418
|
if (off) card.appendChild(el("div", "hint muted", t("acct.offHint")));
|
|
1698
2419
|
|
|
1699
2420
|
var meta = el("div", "model-meta");
|
|
@@ -1716,7 +2437,7 @@ function accountCard(account) {
|
|
|
1716
2437
|
if (account.probePending === true) {
|
|
1717
2438
|
card.appendChild(el("div", "hint muted", t("probe.pending")));
|
|
1718
2439
|
} else if (account.creditsError) {
|
|
1719
|
-
card.appendChild(el("div", "hint finding-fail", t("credits.unavailable") + "
|
|
2440
|
+
card.appendChild(el("div", "hint finding-fail", t("credits.unavailable") + ": " + account.creditsError));
|
|
1720
2441
|
} else if (account.credits) {
|
|
1721
2442
|
card.appendChild(creditsBlock(account.credits, account.id, { floor: account }));
|
|
1722
2443
|
}
|
|
@@ -2093,17 +2814,37 @@ function renderModels() {
|
|
|
2093
2814
|
var key = page.source + "\u0000" + page.key + "\u0000"
|
|
2094
2815
|
+ list.map(function (model) { return model.id; }).sort().join("\u0000");
|
|
2095
2816
|
var slot = page.source + "\u0000" + page.key;
|
|
2096
|
-
if (drafts[slot] === undefined
|
|
2817
|
+
if (drafts[slot] === undefined) {
|
|
2097
2818
|
drafts[slot] = { key: key, draft: draftFor(list, page.selection) };
|
|
2819
|
+
} else if (drafts[slot].key !== key) {
|
|
2820
|
+
// The roster changed under an open draft (a catalog refresh, a fetch): keep
|
|
2821
|
+
// the user's unsaved ticks and overrides for every id that survived, and
|
|
2822
|
+
// start newly listed ids from the saved selection. Replacing the whole
|
|
2823
|
+
// draft silently discarded edits the savebar was still offering to save.
|
|
2824
|
+
var fresh = draftFor(list, page.selection);
|
|
2825
|
+
Object.keys(fresh).forEach(function (id) {
|
|
2826
|
+
if (Object.prototype.hasOwnProperty.call(drafts[slot].draft, id)) fresh[id] = drafts[slot].draft[id];
|
|
2827
|
+
});
|
|
2828
|
+
drafts[slot] = { key: key, draft: fresh };
|
|
2098
2829
|
}
|
|
2099
2830
|
draft = drafts[slot].draft;
|
|
2100
2831
|
draftSlot = slot;
|
|
2832
|
+
// Every render, not only a key change: the ceilings can shrink while the model
|
|
2833
|
+
// ids stay the same - one directory function failing is enough - and a draft is
|
|
2834
|
+
// allowed to outlive that. Idempotent, and it keeps what the field shows equal to
|
|
2835
|
+
// what the host would accept.
|
|
2836
|
+
list.forEach(function (model) {
|
|
2837
|
+
if (draft[model.id] !== undefined) reclampEntry(draft[model.id], model);
|
|
2838
|
+
});
|
|
2101
2839
|
|
|
2102
2840
|
$("modelListTitle").textContent = page.label;
|
|
2103
2841
|
show($("modelFetchBtn"), page.source === "workbuddy");
|
|
2104
2842
|
$("modelFetchBtn").textContent = busy === "fetch" ? t("models.modelsLoading") : t("models.fetchModelList");
|
|
2105
2843
|
$("modelFetchBtn").disabled = busy !== null;
|
|
2106
2844
|
$("modelSearch").placeholder = t("models.searchModel");
|
|
2845
|
+
// A placeholder is not an accessible name: it disappears as soon as the box
|
|
2846
|
+
// has text in it, so the field announced itself as an unlabelled search.
|
|
2847
|
+
$("modelSearch").setAttribute("aria-label", t("models.searchModel"));
|
|
2107
2848
|
var filter = $("modelSearch").value.trim().toLowerCase();
|
|
2108
2849
|
var host = $("models");
|
|
2109
2850
|
var keep = placeOf(host);
|
|
@@ -2112,9 +2853,12 @@ function renderModels() {
|
|
|
2112
2853
|
paintPageHint(page, published);
|
|
2113
2854
|
|
|
2114
2855
|
if (list.length === 0) {
|
|
2856
|
+
// A <ul> whose only child is a <div> is an empty list to a screen reader,
|
|
2857
|
+
// and the empty state sits 40px in because the list indentation applies to
|
|
2858
|
+
// it too. The roster's own rows are list items, so this is one as well.
|
|
2115
2859
|
host.appendChild(regionParked(page.source, page.region)
|
|
2116
|
-
? parkedRegionBlock(page.source, page.region)
|
|
2117
|
-
: el("
|
|
2860
|
+
? parkedRegionBlock(page.source, page.region, "li")
|
|
2861
|
+
: el("li", "empty", state === null ? t("state.loading") : emptyRosterText(page)));
|
|
2118
2862
|
$("modelSelectAll").checked = false;
|
|
2119
2863
|
$("modelSelectAll").indeterminate = false;
|
|
2120
2864
|
$("modelSelectAll").disabled = true;
|
|
@@ -2129,7 +2873,7 @@ function renderModels() {
|
|
|
2129
2873
|
|| String(model.name).toLowerCase().indexOf(filter) >= 0
|
|
2130
2874
|
|| String(model.alias || "").toLowerCase().indexOf(filter) >= 0;
|
|
2131
2875
|
});
|
|
2132
|
-
if (shown.length === 0) host.appendChild(el("
|
|
2876
|
+
if (shown.length === 0) host.appendChild(el("li", "empty", t("models.noMatch")));
|
|
2133
2877
|
|
|
2134
2878
|
// The header box reflects the visible rows, matching the host: clearing the
|
|
2135
2879
|
// search and ticking the box selects everything, filtering narrows it.
|
|
@@ -2194,6 +2938,14 @@ function publishedModels(list, cap) {
|
|
|
2194
2938
|
function modelListRow(model, published) {
|
|
2195
2939
|
var entry = draft[model.id];
|
|
2196
2940
|
var row = el("li", "row");
|
|
2941
|
+
// The sheet opens on the right-hand column, and nothing on the roster said
|
|
2942
|
+
// which model it belonged to: the row washes only for "ticked", so the one
|
|
2943
|
+
// being edited looked like every other. The marker reads the same `entry.open`
|
|
2944
|
+
// the right column expands on, so the two cannot disagree. This paints it on
|
|
2945
|
+
// the rebuild; `paintEditingRow` repaints it in place when the sheet is toggled
|
|
2946
|
+
// from the right column, which needs the id on the element.
|
|
2947
|
+
row.setAttribute("data-model-id", model.id);
|
|
2948
|
+
if (entry && entry.open === true) row.classList.add("is-editing");
|
|
2197
2949
|
var label = el("label", "row-label");
|
|
2198
2950
|
|
|
2199
2951
|
var box = document.createElement("input");
|
|
@@ -2203,6 +2955,11 @@ function modelListRow(model, published) {
|
|
|
2203
2955
|
box.disabled = busy !== null;
|
|
2204
2956
|
box.addEventListener("change", function () {
|
|
2205
2957
|
entry.enabled = box.checked;
|
|
2958
|
+
// An unticked model has no sheet, so the open state goes with the tick, the
|
|
2959
|
+
// way the × control drops both: left behind, the roster kept marking a row
|
|
2960
|
+
// that had nothing open, and a rebuild put the sheet back on a model the user
|
|
2961
|
+
// had just taken out of the selection.
|
|
2962
|
+
if (!entry.enabled) closeSheetOf(model.id);
|
|
2206
2963
|
renderModels();
|
|
2207
2964
|
});
|
|
2208
2965
|
label.appendChild(box);
|
|
@@ -2236,7 +2993,6 @@ function modelListRow(model, published) {
|
|
|
2236
2993
|
// Only an enabled model has a sheet to open, which is what the second view is.
|
|
2237
2994
|
if (entry.enabled) {
|
|
2238
2995
|
label.appendChild(el("span", "row-open-hint", "›"));
|
|
2239
|
-
label.classList.add("is-openable");
|
|
2240
2996
|
label.addEventListener("click", function (event) {
|
|
2241
2997
|
if (event.target instanceof HTMLInputElement) return;
|
|
2242
2998
|
// The row is a <label>, whose default activation would also flip the
|
|
@@ -2250,6 +3006,68 @@ function modelListRow(model, published) {
|
|
|
2250
3006
|
return row;
|
|
2251
3007
|
}
|
|
2252
3008
|
|
|
3009
|
+
/**
|
|
3010
|
+
* Take one model out of the open state, leaving any other sheet alone.
|
|
3011
|
+
*
|
|
3012
|
+
* The roster's mark is read from `entry.open` and the record a rebuilt draft
|
|
3013
|
+
* restores from is `selectedSheet`, so the two are always written together: a
|
|
3014
|
+
* gesture that cleared one and not the other left a row marked as being edited
|
|
3015
|
+
* while its sheet was already gone.
|
|
3016
|
+
*/
|
|
3017
|
+
function closeSheetOf(id) {
|
|
3018
|
+
var entry = draft[id];
|
|
3019
|
+
if (!entry) return;
|
|
3020
|
+
entry.open = false;
|
|
3021
|
+
if (sheetIsOpen(id)) selectedSheet = null;
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
/**
|
|
3025
|
+
* Open one model's sheet and close the rest.
|
|
3026
|
+
*
|
|
3027
|
+
* One at a time: the roster's mark means "this is the model whose editor is open",
|
|
3028
|
+
* and two marked rows cannot both be that.
|
|
3029
|
+
*/
|
|
3030
|
+
function openSheetOf(id) {
|
|
3031
|
+
var entry = draft[id];
|
|
3032
|
+
if (!entry) return;
|
|
3033
|
+
Object.keys(draft).forEach(closeSheetOf);
|
|
3034
|
+
entry.open = true;
|
|
3035
|
+
selectedSheet = { key: currentModelKey(), id: id };
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
/**
|
|
3039
|
+
* Open or close one model's sheet from the right-hand column.
|
|
3040
|
+
*
|
|
3041
|
+
* The roster marker is repainted in place rather than by rebuilding the list: a
|
|
3042
|
+
* rebuild is what `openModelSheet` costs from the left, and doing that here would
|
|
3043
|
+
* throw away the roster's scroll offset and the focus inside the sheet every time
|
|
3044
|
+
* the sheet is collapsed.
|
|
3045
|
+
*/
|
|
3046
|
+
function toggleModelSheet(id) {
|
|
3047
|
+
var entry = draft[id];
|
|
3048
|
+
if (!entry) return;
|
|
3049
|
+
if (entry.open === true) closeSheetOf(id);
|
|
3050
|
+
else openSheetOf(id);
|
|
3051
|
+
renderChosen();
|
|
3052
|
+
paintEditingRow();
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
/**
|
|
3056
|
+
* Bring the roster's editing marker in step with the draft.
|
|
3057
|
+
*
|
|
3058
|
+
* One model has a sheet open, and that id can change from either column, so the
|
|
3059
|
+
* mark is repainted for every row rather than added to one: a row left marked
|
|
3060
|
+
* after the sheet moved read as the model being edited when it was not.
|
|
3061
|
+
*/
|
|
3062
|
+
function paintEditingRow() {
|
|
3063
|
+
var rows = $("models").querySelectorAll("[data-model-id]");
|
|
3064
|
+
for (var index = 0; index < rows.length; index += 1) {
|
|
3065
|
+
var entry = draft[rows[index].getAttribute("data-model-id")];
|
|
3066
|
+
if (entry && entry.open === true) rows[index].classList.add("is-editing");
|
|
3067
|
+
else rows[index].classList.remove("is-editing");
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
|
|
2253
3071
|
/**
|
|
2254
3072
|
* Open one model's sheet.
|
|
2255
3073
|
*
|
|
@@ -2259,17 +3077,27 @@ function modelListRow(model, published) {
|
|
|
2259
3077
|
function openModelSheet(id) {
|
|
2260
3078
|
var entry = draft[id];
|
|
2261
3079
|
if (!entry || !entry.enabled) return;
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
3080
|
+
openSheetOf(id);
|
|
3081
|
+
// Both columns: the left one is what draws the editing marker.
|
|
3082
|
+
renderModels();
|
|
3083
|
+
// The expanded row, not `#chosen`: that element is the scroller itself, and
|
|
3084
|
+
// `scrollIntoView` on it moves its ancestors, so a sheet below the fold opened
|
|
3085
|
+
// without coming into view. The rows sit inside the list, and are matched
|
|
3086
|
+
// through the attribute rather than a selector because a model id is not a CSS
|
|
3087
|
+
// identifier.
|
|
3088
|
+
var rows = $("chosen").querySelectorAll("[data-model-id]");
|
|
3089
|
+
for (var index = 0; index < rows.length; index += 1) {
|
|
3090
|
+
if (rows[index].getAttribute("data-model-id") !== id) continue;
|
|
3091
|
+
if (rows[index].scrollIntoView) rows[index].scrollIntoView({ block: "nearest" });
|
|
3092
|
+
break;
|
|
3093
|
+
}
|
|
2267
3094
|
}
|
|
2268
3095
|
|
|
2269
3096
|
/** The sheet view: every enabled model's editor, the selected one expanded. */
|
|
2270
3097
|
function renderChosen() {
|
|
2271
3098
|
$("modelEditTitle").textContent = t("models.modelConfigurations");
|
|
2272
3099
|
$("chosenSearch").placeholder = t("models.searchChosen");
|
|
3100
|
+
$("chosenSearch").setAttribute("aria-label", t("models.searchChosen"));
|
|
2273
3101
|
|
|
2274
3102
|
var page = modelPage();
|
|
2275
3103
|
var list = page.list;
|
|
@@ -2318,6 +3146,7 @@ function modelSheetRow(model) {
|
|
|
2318
3146
|
var entry = draft[model.id];
|
|
2319
3147
|
var expanded = entry.open === true;
|
|
2320
3148
|
var row = el("li", "chosen-row");
|
|
3149
|
+
row.setAttribute("data-model-id", model.id);
|
|
2321
3150
|
|
|
2322
3151
|
var head = el("div", "chosen-head");
|
|
2323
3152
|
// The name, the same as the roster row: the id it is filed under is not shown
|
|
@@ -2333,8 +3162,7 @@ function modelSheetRow(model) {
|
|
|
2333
3162
|
advanced.type = "button";
|
|
2334
3163
|
advanced.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
2335
3164
|
advanced.addEventListener("click", function () {
|
|
2336
|
-
|
|
2337
|
-
renderChosen();
|
|
3165
|
+
toggleModelSheet(model.id);
|
|
2338
3166
|
});
|
|
2339
3167
|
head.appendChild(advanced);
|
|
2340
3168
|
|
|
@@ -2344,9 +3172,8 @@ function modelSheetRow(model) {
|
|
|
2344
3172
|
remove.setAttribute("aria-label", t("models.removeModel"));
|
|
2345
3173
|
remove.addEventListener("click", function () {
|
|
2346
3174
|
entry.enabled = false;
|
|
2347
|
-
entry.open = false;
|
|
2348
3175
|
// Removing the model being edited returns to the roster.
|
|
2349
|
-
|
|
3176
|
+
closeSheetOf(model.id);
|
|
2350
3177
|
renderModels();
|
|
2351
3178
|
});
|
|
2352
3179
|
head.appendChild(remove);
|
|
@@ -2357,8 +3184,24 @@ function modelSheetRow(model) {
|
|
|
2357
3184
|
return row;
|
|
2358
3185
|
}
|
|
2359
3186
|
|
|
2360
|
-
/**
|
|
2361
|
-
|
|
3187
|
+
/**
|
|
3188
|
+
* The open model sheet: the gateway key it belongs to and the model id.
|
|
3189
|
+
*
|
|
3190
|
+
* Both, because model ids repeat across providers - `deepseek-v4.1-flash` is in
|
|
3191
|
+
* all three rosters - so an id alone carried the open sheet from WorkBuddy into
|
|
3192
|
+
* Trae's roster of the same name, pre-expanding a model the user never opened.
|
|
3193
|
+
*/
|
|
3194
|
+
var selectedSheet = null;
|
|
3195
|
+
|
|
3196
|
+
/** Whether the sheet for this gateway key and model id is the open one. */
|
|
3197
|
+
function sheetIsOpen(modelId) {
|
|
3198
|
+
return selectedSheet !== null && selectedSheet.key === currentModelKey() && selectedSheet.id === modelId;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
/** The gateway a model edit applies to: the source and the region it is showing. */
|
|
3202
|
+
function currentModelKey() {
|
|
3203
|
+
return activeSource + ":" + activeRegionOf(activeSource);
|
|
3204
|
+
}
|
|
2362
3205
|
|
|
2363
3206
|
/**
|
|
2364
3207
|
* The presets the host's own model editor offers, so a value picked here lands
|
|
@@ -2381,6 +3224,23 @@ var MAX_OUTPUT_PRESETS = [
|
|
|
2381
3224
|
/** Every level the host's reasoning menu can carry, in its own order. */
|
|
2382
3225
|
var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
2383
3226
|
|
|
3227
|
+
/** A fresh editable draft built from the server's document for one region. */
|
|
3228
|
+
/**
|
|
3229
|
+
* A saved limit, kept inside the ceiling the row shows.
|
|
3230
|
+
*
|
|
3231
|
+
* The host sizes its budget from what the declaration says, and `src/host.ts`
|
|
3232
|
+
* clamps an override to the catalog's figure before publishing — so an override
|
|
3233
|
+
* stored above it (the catalog shrank after it was saved) is not what the model
|
|
3234
|
+
* runs at. Showing it verbatim put a number in the field that the field's own
|
|
3235
|
+
* `max` then refused to accept, and the panel read as if the model had more room
|
|
3236
|
+
* than it has.
|
|
3237
|
+
*/
|
|
3238
|
+
function withinCeiling(saved, ceiling) {
|
|
3239
|
+
if (typeof saved !== "number") return null;
|
|
3240
|
+
if (typeof ceiling !== "number" || ceiling <= 0) return saved;
|
|
3241
|
+
return Math.min(saved, ceiling);
|
|
3242
|
+
}
|
|
3243
|
+
|
|
2384
3244
|
/** A fresh editable draft built from the server's document for one region. */
|
|
2385
3245
|
function draftFor(list, selection) {
|
|
2386
3246
|
var enabled = selection.enabledModelIds;
|
|
@@ -2393,25 +3253,143 @@ function draftFor(list, selection) {
|
|
|
2393
3253
|
// An absent field means "follow the catalog", which the editor shows as
|
|
2394
3254
|
// the untouched state rather than a value of its own.
|
|
2395
3255
|
alias: typeof saved.alias === "string" ? saved.alias : "",
|
|
2396
|
-
window:
|
|
2397
|
-
output:
|
|
3256
|
+
window: withinCeiling(saved.contextWindow, windowCeiling(model)),
|
|
3257
|
+
output: withinCeiling(saved.maxOutputTokens, outputCeilingFor(model, withinCeiling(saved.contextWindow, windowCeiling(model)))),
|
|
3258
|
+
// Nothing is on hold in a draft built from what is stored: the stored figure
|
|
3259
|
+
// is already the ceiling the host kept, so there is no wider number to
|
|
3260
|
+
// replay.
|
|
3261
|
+
windowHeld: null,
|
|
3262
|
+
outputHeld: null,
|
|
2398
3263
|
images: typeof saved.supportsImages === "boolean" ? saved.supportsImages : null,
|
|
2399
3264
|
levels: Array.isArray(saved.thinkingLevels) ? saved.thinkingLevels.slice() : null,
|
|
2400
3265
|
defaultLevel: typeof saved.defaultThinkingLevel === "string" ? saved.defaultThinkingLevel : null,
|
|
2401
3266
|
open: false,
|
|
2402
3267
|
};
|
|
2403
3268
|
});
|
|
2404
|
-
// The sheet reopens on whatever it was showing, when that model still exists
|
|
2405
|
-
|
|
3269
|
+
// The sheet reopens on whatever it was showing, when that model still exists
|
|
3270
|
+
// and still belongs to this gateway.
|
|
3271
|
+
if (selectedSheet !== null && selectedSheet.key === currentModelKey() && out[selectedSheet.id]) {
|
|
3272
|
+
out[selectedSheet.id].open = true;
|
|
3273
|
+
}
|
|
2406
3274
|
return out;
|
|
2407
3275
|
}
|
|
2408
3276
|
|
|
3277
|
+
/**
|
|
3278
|
+
* Bring one draft entry back inside the ceilings its model states now.
|
|
3279
|
+
*
|
|
3280
|
+
* A draft outlives a roster refresh, and a refresh is allowed to lose a Max tier:
|
|
3281
|
+
* a window that was legal when the user typed it is then above the field's own
|
|
3282
|
+
* `max`, which reads as an edit nobody made and lights the save bar.
|
|
3283
|
+
*/
|
|
3284
|
+
function reclampEntry(entry, model) {
|
|
3285
|
+
var ceiling = windowCeiling(model);
|
|
3286
|
+
// A window the ceiling no longer reaches is set aside rather than dropped, for
|
|
3287
|
+
// the same reason `clampOutput` holds the output: a directory read that loses a
|
|
3288
|
+
// Max tier is ordinary, and the window coming back must not need the user to
|
|
3289
|
+
// retype it. The held figure is only replayed while the ceiling still allows it.
|
|
3290
|
+
var windowBefore = entry.window;
|
|
3291
|
+
entry.window = withinCeiling(entry.window, ceiling);
|
|
3292
|
+
if (entry.window !== windowBefore) {
|
|
3293
|
+
if (typeof entry.windowHeld !== "number") entry.windowHeld = windowBefore;
|
|
3294
|
+
} else if (typeof entry.windowHeld === "number" && entry.windowHeld <= ceiling) {
|
|
3295
|
+
entry.window = entry.windowHeld;
|
|
3296
|
+
entry.windowHeld = null;
|
|
3297
|
+
}
|
|
3298
|
+
// `null` means "follow the catalog", which is the model's DEFAULT window - not
|
|
3299
|
+
// the ceiling. Handing the ceiling over would clamp the output to the Max tier's
|
|
3300
|
+
// smaller budget while the field is still showing the default window.
|
|
3301
|
+
//
|
|
3302
|
+
// Through `clampOutput` rather than a bare `withinCeiling`, so the output is held
|
|
3303
|
+
// the same way: a refresh that lowers the ceiling used to cut the draft's budget
|
|
3304
|
+
// with no user action, which then read as an unsaved edit against the stored
|
|
3305
|
+
// figure and let one unrelated save write the smaller number down.
|
|
3306
|
+
clampOutput(model, entry);
|
|
3307
|
+
// Half-typed text does not survive a ceiling that no longer admits it. Left in
|
|
3308
|
+
// place it became the field's value beside a `max` that now refuses it - the one
|
|
3309
|
+
// state the clamp above exists to prevent.
|
|
3310
|
+
var outputLimit = outputCeilingFor(model, entry.window);
|
|
3311
|
+
if (entry.windowText != null && !(Number(entry.windowText) > 0 && Number(entry.windowText) <= ceiling)) entry.windowText = null;
|
|
3312
|
+
if (entry.outputText != null && !(Number(entry.outputText) > 0 && Number(entry.outputText) <= outputLimit)) entry.outputText = null;
|
|
3313
|
+
return entry;
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
/** Say why a token figure was refused, naming the ceiling that applied. */
|
|
3317
|
+
function overCeilingNotice(limit) {
|
|
3318
|
+
note(t("models.overCeiling", { limit: String(limit) }));
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
/**
|
|
3322
|
+
* The highest window a model accepts.
|
|
3323
|
+
*
|
|
3324
|
+
* Trae sells Max as a second, larger tier, so a model's default window is not its
|
|
3325
|
+
* ceiling. The Max figure is published beside the default; a model without one has
|
|
3326
|
+
* only the default, which is then its ceiling.
|
|
3327
|
+
*/
|
|
3328
|
+
function windowCeiling(model) {
|
|
3329
|
+
var max = model.maxContextWindow;
|
|
3330
|
+
var dev = model.nativeContextWindow;
|
|
3331
|
+
return typeof max === "number" && max > 0 && (typeof dev !== "number" || max > dev) ? max : dev;
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3334
|
+
/** The highest output budget the model grants at the window the draft is using. */
|
|
3335
|
+
function outputCeilingFor(model, window) {
|
|
3336
|
+
// A model that states a smaller budget through the function serving its Max
|
|
3337
|
+
// tier only grants it there, so a draft reaching above the default window has
|
|
3338
|
+
// to measure against that one instead of the default tier's figure.
|
|
3339
|
+
var at = model.maxOutputAtCeiling;
|
|
3340
|
+
var dev = model.nativeContextWindow;
|
|
3341
|
+
var ceiling = windowCeiling(model);
|
|
3342
|
+
var wanted = typeof window === "number" ? window : dev;
|
|
3343
|
+
if (typeof at === "number" && at > 0 && typeof dev === "number" && typeof ceiling === "number" && wanted > dev) {
|
|
3344
|
+
return Math.min(at, model.nativeMaxOutputTokens);
|
|
3345
|
+
}
|
|
3346
|
+
return model.nativeMaxOutputTokens;
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
function outputCeiling(model, entry) {
|
|
3350
|
+
return outputCeilingFor(model, effectiveWindow(model, entry));
|
|
3351
|
+
}
|
|
3352
|
+
|
|
3353
|
+
/**
|
|
3354
|
+
* Keep the draft's output inside the ceiling its window allows.
|
|
3355
|
+
*
|
|
3356
|
+
* A window change can lower that ceiling (the Max-tier function states a smaller
|
|
3357
|
+
* budget), and a field left holding a bigger number would show a value its own
|
|
3358
|
+
* `max` refuses - the declaration would then be clamped silently instead of the
|
|
3359
|
+
* editor saying so.
|
|
3360
|
+
*
|
|
3361
|
+
* The figure the clamp replaced is held rather than dropped. Reaching for the Max
|
|
3362
|
+
* tier and coming back is one gesture each way, and without the hold the return
|
|
3363
|
+
* leg kept the narrower figure: saving then wrote it down, permanently cutting the
|
|
3364
|
+
* model's default budget in half over a trip the user had undone. `outputHeld` is
|
|
3365
|
+
* cleared the moment the user states an output of their own, which is what makes
|
|
3366
|
+
* the restore safe - it only ever replays a number the user chose at a window that
|
|
3367
|
+
* still grants it.
|
|
3368
|
+
*/
|
|
3369
|
+
function clampOutput(model, entry) {
|
|
3370
|
+
var ceiling = outputCeilingFor(model, entry.window === null ? model.nativeContextWindow : entry.window);
|
|
3371
|
+
if (typeof entry.output === "number") {
|
|
3372
|
+
if (entry.output > ceiling) {
|
|
3373
|
+
if (typeof entry.outputHeld !== "number") entry.outputHeld = entry.output;
|
|
3374
|
+
entry.output = ceiling;
|
|
3375
|
+
} else if (typeof entry.outputHeld === "number" && entry.outputHeld <= ceiling) {
|
|
3376
|
+
entry.output = entry.outputHeld;
|
|
3377
|
+
entry.outputHeld = null;
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
return ceiling;
|
|
3381
|
+
}
|
|
3382
|
+
|
|
2409
3383
|
/** The window a model currently advertises, override first. */
|
|
2410
3384
|
function effectiveWindow(model, entry) {
|
|
2411
3385
|
return entry.window === null ? model.nativeContextWindow : entry.window;
|
|
2412
3386
|
}
|
|
2413
3387
|
function effectiveOutput(model, entry) {
|
|
2414
|
-
|
|
3388
|
+
// Never above the ceiling the chosen window allows: a model whose Max-tier
|
|
3389
|
+
// function states a smaller budget must not show the default tier's figure in
|
|
3390
|
+
// a field whose own `max` is already that smaller one.
|
|
3391
|
+
var value = entry.output === null ? model.nativeMaxOutputTokens : entry.output;
|
|
3392
|
+
return Math.min(value, outputCeilingFor(model, effectiveWindow(model, entry)));
|
|
2415
3393
|
}
|
|
2416
3394
|
function effectiveImages(model, entry) {
|
|
2417
3395
|
return entry.images === null ? model.nativeSupportsImages === true : entry.images;
|
|
@@ -2433,8 +3411,11 @@ function isDirty(list, selection) {
|
|
|
2433
3411
|
if (entry.enabled !== (enabled === undefined || enabled.indexOf(model.id) >= 0)) return true;
|
|
2434
3412
|
var saved = overrides[model.id] || {};
|
|
2435
3413
|
if (entry.alias !== (typeof saved.alias === "string" ? saved.alias : "")) return true;
|
|
2436
|
-
|
|
2437
|
-
|
|
3414
|
+
// Compared through the same clamp the draft was built with: a stored figure
|
|
3415
|
+
// above the catalog's is not something the editor can show, so it must not
|
|
3416
|
+
// read as an edit waiting to be saved either.
|
|
3417
|
+
if (entry.window !== withinCeiling(saved.contextWindow, windowCeiling(model))) return true;
|
|
3418
|
+
if (entry.output !== withinCeiling(saved.maxOutputTokens, outputCeilingFor(model, entry.window === null ? model.nativeContextWindow : entry.window))) return true;
|
|
2438
3419
|
if (entry.images !== (typeof saved.supportsImages === "boolean" ? saved.supportsImages : null)) return true;
|
|
2439
3420
|
if ((entry.levels === null ? null : entry.levels.join(","))
|
|
2440
3421
|
!== (Array.isArray(saved.thinkingLevels) ? saved.thinkingLevels.join(",") : null)) return true;
|
|
@@ -2443,10 +3424,30 @@ function isDirty(list, selection) {
|
|
|
2443
3424
|
return false;
|
|
2444
3425
|
}
|
|
2445
3426
|
|
|
2446
|
-
/**
|
|
2447
|
-
|
|
3427
|
+
/**
|
|
3428
|
+
* A preset chip row: the chip matching the current value is highlighted.
|
|
3429
|
+
*
|
|
3430
|
+
* `ceiling` drops the presets the model cannot take, so a chip can never offer a
|
|
3431
|
+
* figure the input beside it would reject. `defaultWindow` is the model's own
|
|
3432
|
+
* default tier, added alongside the ceiling: the fixed ladder has no rung at 200k
|
|
3433
|
+
* or 116k, so without these a model whose window sits between two rungs showed a
|
|
3434
|
+
* single chip well under what it accepts, which read as the pool holding the
|
|
3435
|
+
* model back. Both of a Max-capable model's windows end up offered.
|
|
3436
|
+
*/
|
|
3437
|
+
function presetRow(presets, value, onPick, ceiling, defaultWindow) {
|
|
2448
3438
|
var wrap = el("div", "preset-row");
|
|
2449
|
-
|
|
3439
|
+
var limit = typeof ceiling === "number" && ceiling > 0 ? ceiling : Infinity;
|
|
3440
|
+
var chips = presets.filter(function (preset) { return preset.tokens <= limit; });
|
|
3441
|
+
var has = function (tokens) { return chips.some(function (chip) { return chip.tokens === tokens; }); };
|
|
3442
|
+
// Lowercase the K to sit with the ladder's own labels; the M stays as is.
|
|
3443
|
+
var label = function (tokens) { return formatTokens(tokens).replace(/K$/, "k"); };
|
|
3444
|
+
// The model's own windows come first: its default tier, then its Max tier.
|
|
3445
|
+
[defaultWindow, limit].forEach(function (tokens) {
|
|
3446
|
+
if (!Number.isFinite(tokens) || tokens <= 0 || has(tokens)) return;
|
|
3447
|
+
chips.push({ label: label(tokens), tokens: tokens });
|
|
3448
|
+
});
|
|
3449
|
+
chips.sort(function (a, b) { return a.tokens - b.tokens; });
|
|
3450
|
+
chips.forEach(function (preset) {
|
|
2450
3451
|
var chip = el("button", preset.tokens === value ? "preset active" : "preset", preset.label);
|
|
2451
3452
|
chip.type = "button";
|
|
2452
3453
|
chip.setAttribute("aria-pressed", preset.tokens === value ? "true" : "false");
|
|
@@ -2514,27 +3515,65 @@ function modelSheetBody(model, entry) {
|
|
|
2514
3515
|
body.appendChild(field("models.alias", "models.aliasHelp", aliasInput));
|
|
2515
3516
|
|
|
2516
3517
|
// Context window and max output, side by side on a wide enough panel.
|
|
2517
|
-
|
|
3518
|
+
// The ceiling is the model's own figure: the host sizes its context budget
|
|
3519
|
+
// from whatever is declared, so a larger window claimed room the upstream does
|
|
3520
|
+
// not have and the reply was compacted early.
|
|
3521
|
+
var windowInput = numberInput(entry.windowText == null ? effectiveWindow(model, entry) : entry.windowText, function (next) {
|
|
2518
3522
|
// A value equal to the catalog's is stored as "no override", so the row
|
|
2519
3523
|
// keeps following the catalog instead of pinning today's number.
|
|
2520
3524
|
entry.window = next === model.nativeContextWindow ? null : next;
|
|
3525
|
+
entry.windowText = null;
|
|
3526
|
+
// The hold is what a clamp set aside; a number the user typed is the choice to
|
|
3527
|
+
// keep, so replaying the hold on the next catalog refresh would replace it.
|
|
3528
|
+
entry.windowHeld = null;
|
|
3529
|
+
// Reaching for a wider window can lower the output ceiling, so a half-typed
|
|
3530
|
+
// output is dropped rather than left showing a figure the new window refuses.
|
|
3531
|
+
entry.outputText = null;
|
|
3532
|
+
clampOutput(model, entry);
|
|
2521
3533
|
renderChosen();
|
|
2522
|
-
});
|
|
3534
|
+
}, windowCeiling(model), overCeilingNotice, function (text) { entry.windowText = text; }, effectiveWindow(model, entry));
|
|
2523
3535
|
var windowCol = field("models.window", "models.windowFollows", windowInput);
|
|
2524
|
-
windowCol.insertBefore(presetRow(
|
|
2525
|
-
|
|
3536
|
+
windowCol.insertBefore(presetRow(
|
|
3537
|
+
CONTEXT_WINDOW_PRESETS,
|
|
3538
|
+
effectiveWindow(model, entry),
|
|
3539
|
+
function (tokens) {
|
|
3540
|
+
entry.window = tokens === model.nativeContextWindow ? null : tokens;
|
|
3541
|
+
entry.windowText = null;
|
|
3542
|
+
entry.outputText = null;
|
|
3543
|
+
// A number the user picked is the one to keep: replaying a hold from an
|
|
3544
|
+
// earlier clamp would replace it on the next catalog refresh.
|
|
3545
|
+
entry.windowHeld = null;
|
|
3546
|
+
clampOutput(model, entry);
|
|
3547
|
+
renderChosen();
|
|
3548
|
+
},
|
|
3549
|
+
windowCeiling(model),
|
|
3550
|
+
model.nativeContextWindow,
|
|
3551
|
+
), windowInput);
|
|
3552
|
+
|
|
3553
|
+
// The output field's ceiling follows the window this draft asks for: a model
|
|
3554
|
+
// whose Max function states a smaller budget only grants it above the default.
|
|
3555
|
+
var outputCap = outputCeiling(model, entry);
|
|
3556
|
+
var outputInput = numberInput(entry.outputText == null ? effectiveOutput(model, entry) : entry.outputText, function (next) {
|
|
3557
|
+
// Matching the ceiling at this window is stored as "no override", the same
|
|
3558
|
+
// rule the window field follows, so the row keeps tracking the catalog. A
|
|
3559
|
+
// number of the user's own also ends any hold from an earlier clamp: this is
|
|
3560
|
+
// the choice to replay, not the one the clamp set aside.
|
|
3561
|
+
entry.outputHeld = null;
|
|
3562
|
+
entry.output = next === outputCap ? null : next;
|
|
2526
3563
|
renderChosen();
|
|
2527
|
-
}),
|
|
2528
|
-
|
|
2529
|
-
var outputInput = numberInput(effectiveOutput(model, entry), function (next) {
|
|
2530
|
-
entry.output = next === model.nativeMaxOutputTokens ? null : next;
|
|
2531
|
-
renderChosen();
|
|
2532
|
-
});
|
|
3564
|
+
}, outputCap, overCeilingNotice, function (text) { entry.outputText = text; }, effectiveOutput(model, entry));
|
|
2533
3565
|
var outputCol = field("models.maxOutput", "models.outputHelp", outputInput);
|
|
2534
|
-
outputCol.insertBefore(presetRow(
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
3566
|
+
outputCol.insertBefore(presetRow(
|
|
3567
|
+
MAX_OUTPUT_PRESETS,
|
|
3568
|
+
effectiveOutput(model, entry),
|
|
3569
|
+
function (tokens) {
|
|
3570
|
+
entry.outputHeld = null;
|
|
3571
|
+
entry.outputText = null;
|
|
3572
|
+
entry.output = tokens === outputCap ? null : tokens;
|
|
3573
|
+
renderChosen();
|
|
3574
|
+
},
|
|
3575
|
+
outputCap,
|
|
3576
|
+
), outputInput);
|
|
2538
3577
|
|
|
2539
3578
|
var pair = el("div", "field-pair");
|
|
2540
3579
|
pair.appendChild(windowCol);
|
|
@@ -2625,18 +3664,64 @@ function modelSheetBody(model, entry) {
|
|
|
2625
3664
|
* bound in the browser means the field itself refuses the value.
|
|
2626
3665
|
*/
|
|
2627
3666
|
var MAX_TOKEN_BUDGET = 0xffffffff;
|
|
2628
|
-
|
|
3667
|
+
/**
|
|
3668
|
+
* A token-budget field, capped at `ceiling` when the caller has one.
|
|
3669
|
+
*
|
|
3670
|
+
* `MAX_TOKEN_BUDGET` is the host's own limit on any token figure: a number past
|
|
3671
|
+
* it makes the whole selection payload invalid there, so the save would drop
|
|
3672
|
+
* every edit in this pass rather than clamp one field. `ceiling` is narrower:
|
|
3673
|
+
* it is what the model really accepts, and the host sizes its context budget and
|
|
3674
|
+
* compaction threshold from whatever is declared, so a larger figure made it
|
|
3675
|
+
* believe there was room the upstream does not have.
|
|
3676
|
+
*
|
|
3677
|
+
* A refused value goes back to `committed` - the number the draft actually holds -
|
|
3678
|
+
* rather than to `value`, which may be a half-typed string. Restoring the string
|
|
3679
|
+
* left the field showing neither the stored figure nor what the user meant: type
|
|
3680
|
+
* `500000` past a `200000` ceiling and the box was refilled with the `50000` that
|
|
3681
|
+
* happened to be there when the last repaint rebuilt it, so pressing enter again
|
|
3682
|
+
* saved a number nobody had ever typed. `onRefused` says why, and the field itself
|
|
3683
|
+
* stays free of the banner: the same control is driven without one in the tests,
|
|
3684
|
+
* and a silent snap-back read as the field ignoring the edit.
|
|
3685
|
+
*/
|
|
3686
|
+
function numberInput(value, onChange, ceiling, onRefused, onText, committed) {
|
|
3687
|
+
var limit = typeof ceiling === "number" && ceiling > 0
|
|
3688
|
+
? Math.min(Math.round(ceiling), MAX_TOKEN_BUDGET)
|
|
3689
|
+
: MAX_TOKEN_BUDGET;
|
|
3690
|
+
var stored = typeof committed === "number" ? committed : value;
|
|
2629
3691
|
var input = document.createElement("input");
|
|
2630
3692
|
input.type = "number";
|
|
2631
3693
|
input.className = "num-input";
|
|
2632
|
-
input.max = String(
|
|
3694
|
+
input.max = String(limit);
|
|
2633
3695
|
input.min = "1";
|
|
2634
3696
|
input.step = "1000";
|
|
2635
3697
|
input.value = String(value);
|
|
3698
|
+
// The whole sheet is rebuilt on every repaint, and a repaint really does land
|
|
3699
|
+
// between two keystrokes: the panel polls every 1.2 s while a refresh runs and
|
|
3700
|
+
// every 2 s for the check-in log. Only the committed value used to survive, so
|
|
3701
|
+
// a half-typed number was replaced mid-entry and the edit was silently lost.
|
|
3702
|
+
// Holding the raw text lets the rebuilt field show what the user is typing.
|
|
3703
|
+
input.addEventListener("input", function () {
|
|
3704
|
+
if (typeof onText === "function") onText(input.value);
|
|
3705
|
+
});
|
|
2636
3706
|
input.addEventListener("change", function () {
|
|
3707
|
+
if (typeof onText === "function") onText(null);
|
|
3708
|
+
// Cleared means "follow the catalog": both call sites read an absent value as
|
|
3709
|
+
// the row tracking the directory again, and the sheet's own comment promises
|
|
3710
|
+
// exactly that. Reading the empty string as a number turned it into 0, which
|
|
3711
|
+
// the guard below then refused, so the field snapped back and the only way
|
|
3712
|
+
// back to the catalog was to type the directory's number by hand.
|
|
3713
|
+
if (input.value.trim() === "") {
|
|
3714
|
+
onChange(null);
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
2637
3717
|
var next = Number(input.value);
|
|
2638
|
-
if (!Number.isFinite(next) || next <= 0
|
|
2639
|
-
input.value = String(
|
|
3718
|
+
if (!Number.isFinite(next) || next <= 0) {
|
|
3719
|
+
input.value = String(stored);
|
|
3720
|
+
return;
|
|
3721
|
+
}
|
|
3722
|
+
if (next > limit) {
|
|
3723
|
+
input.value = String(stored);
|
|
3724
|
+
if (typeof onRefused === "function") onRefused(limit);
|
|
2640
3725
|
return;
|
|
2641
3726
|
}
|
|
2642
3727
|
onChange(Math.round(next));
|
|
@@ -2787,7 +3872,9 @@ function render() {
|
|
|
2787
3872
|
var keep = placeOf(document.body);
|
|
2788
3873
|
renderHeader();
|
|
2789
3874
|
renderAutoCheckin();
|
|
3875
|
+
renderGrowth();
|
|
2790
3876
|
renderComposerPoints();
|
|
3877
|
+
renderRewriteClientName();
|
|
2791
3878
|
renderHostHint();
|
|
2792
3879
|
renderRegionTabs();
|
|
2793
3880
|
renderModelRegionTabs();
|
|
@@ -2814,6 +3901,12 @@ function render() {
|
|
|
2814
3901
|
lastPressed = null;
|
|
2815
3902
|
}
|
|
2816
3903
|
}
|
|
3904
|
+
// A pending pass whose poll was stopped (or never started) gets its watcher
|
|
3905
|
+
// back here: every state adoption ends in this render, and the log row is the
|
|
3906
|
+
// only thing that reports the pass as running.
|
|
3907
|
+
if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
|
|
3908
|
+
pollCheckinLog(checkinPollAttempts);
|
|
3909
|
+
}
|
|
2817
3910
|
}
|
|
2818
3911
|
|
|
2819
3912
|
// ---------------------------------------------------------------- actions
|
|
@@ -2824,6 +3917,32 @@ function adopt(next) {
|
|
|
2824
3917
|
if (next && typeof next === "object") {
|
|
2825
3918
|
state = next;
|
|
2826
3919
|
stateRevision += 1;
|
|
3920
|
+
// The host keeps the growth centre's last read, so a panel reload paints the
|
|
3921
|
+
// figures instead of claiming nothing was read. A result the panel already
|
|
3922
|
+
// holds is newer than the one the document carries, so it is not replaced.
|
|
3923
|
+
//
|
|
3924
|
+
// The host is also the one that decides a read no longer describes the pool:
|
|
3925
|
+
// parking a region, switching the source off, or dropping an account all
|
|
3926
|
+
// invalidate it there. Without the `else` that drop never reached the panel,
|
|
3927
|
+
// which kept painting rows for accounts the user had just switched off.
|
|
3928
|
+
//
|
|
3929
|
+
// `read: null` is that drop. The key is always published, so its absence means
|
|
3930
|
+
// this document says nothing about the growth centre and the rows on screen
|
|
3931
|
+
// stay - a pass in flight publishes no read on purpose, and clearing on
|
|
3932
|
+
// absence took away the figures the user was watching.
|
|
3933
|
+
if (next.growth && Object.prototype.hasOwnProperty.call(next.growth, "read")) {
|
|
3934
|
+
if (next.growth.read) {
|
|
3935
|
+
if (growthState === null) growthState = next.growth.read;
|
|
3936
|
+
} else {
|
|
3937
|
+
// Taken even while a read is in flight. The read that is running was
|
|
3938
|
+
// computed against the pool as it was, so its answer describes rows the
|
|
3939
|
+
// host has just dropped - and the answer carries a fresh timestamp, which
|
|
3940
|
+
// would then read as current for the whole throttle window and never be
|
|
3941
|
+
// refreshed. `growthDropped` is what tells that read to discard itself.
|
|
3942
|
+
growthState = null;
|
|
3943
|
+
growthDropped += 1;
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
2827
3946
|
}
|
|
2828
3947
|
}
|
|
2829
3948
|
|
|
@@ -2893,6 +4012,9 @@ function adoptAndMaybePoll(next, attempts) {
|
|
|
2893
4012
|
stopPolling();
|
|
2894
4013
|
refreshPoll = window.setTimeout(function () {
|
|
2895
4014
|
refreshPoll = null;
|
|
4015
|
+
// Hidden pages keep no watch: the pass behind this poll belongs to the
|
|
4016
|
+
// plugin, and a page nobody is looking at does not need the document.
|
|
4017
|
+
if (!pageIsVisible()) { stopPolling(); return; }
|
|
2896
4018
|
var revision = stateRevision;
|
|
2897
4019
|
invoke("xd.state").then(function (again) {
|
|
2898
4020
|
if (revision !== stateRevision) {
|
|
@@ -2900,13 +4022,36 @@ function adoptAndMaybePoll(next, attempts) {
|
|
|
2900
4022
|
return;
|
|
2901
4023
|
}
|
|
2902
4024
|
adoptAndMaybePoll(again, attempts + 1);
|
|
2903
|
-
}).catch(function () {
|
|
4025
|
+
}).catch(function () {
|
|
4026
|
+
// The document's own flag is what these two loops watch, and a failing
|
|
4027
|
+
// channel leaves it set: stopping the timer here alone left the header
|
|
4028
|
+
// saying "detecting…" for good, with nothing left to clear it. The same
|
|
4029
|
+
// repair the check-in watch does, one line up.
|
|
4030
|
+
stopPolling();
|
|
4031
|
+
if (!state) return;
|
|
4032
|
+
adopt(Object.assign({}, state, { refreshing: false }));
|
|
4033
|
+
render();
|
|
4034
|
+
});
|
|
2904
4035
|
}, REFRESH_POLL_MS);
|
|
2905
4036
|
}
|
|
2906
4037
|
|
|
2907
4038
|
var checkinPoll = null;
|
|
2908
4039
|
var CHECKIN_POLL_MS = 2000;
|
|
2909
4040
|
var CHECKIN_POLL_LIMIT = 90;
|
|
4041
|
+
var CHECKIN_POLL_SLOW_MS = 10000;
|
|
4042
|
+
/**
|
|
4043
|
+
* How many intermittent polls in a row may fail before the watch gives up.
|
|
4044
|
+
*
|
|
4045
|
+
* The watch exists to keep a long pass's row from reading "running" all day,
|
|
4046
|
+
* but it re-armed itself on every failure without ever clearing the flag it was
|
|
4047
|
+
* watching, so a plugin that had stopped answering left a 10 s poll running for
|
|
4048
|
+
* the life of the page. Three failures in a row is a dead channel, not a slow
|
|
4049
|
+
* pass.
|
|
4050
|
+
*/
|
|
4051
|
+
var CHECKIN_POLL_MAX_FAILURES = 3;
|
|
4052
|
+
var checkinPollAttempts = 0;
|
|
4053
|
+
var checkinPollAt = null;
|
|
4054
|
+
var checkinPollFailures = 0;
|
|
2910
4055
|
|
|
2911
4056
|
function stopCheckinPoll() {
|
|
2912
4057
|
if (checkinPoll !== null) {
|
|
@@ -2915,24 +4060,66 @@ function stopCheckinPoll() {
|
|
|
2915
4060
|
}
|
|
2916
4061
|
}
|
|
2917
4062
|
|
|
4063
|
+
/**
|
|
4064
|
+
* Whether this page is worth polling for.
|
|
4065
|
+
*
|
|
4066
|
+
* The panel is a page in the host's window, not a background service: when it is
|
|
4067
|
+
* hidden nobody is watching what a poll would bring back, so both loops stop and
|
|
4068
|
+
* the next render re-arms whatever is still running.
|
|
4069
|
+
*/
|
|
4070
|
+
function pageIsVisible() {
|
|
4071
|
+
return document.hidden !== true;
|
|
4072
|
+
}
|
|
4073
|
+
|
|
2918
4074
|
/** Keep reading the log while a check-in pass is still marked pending. */
|
|
2919
4075
|
function pollCheckinLog(attempts) {
|
|
2920
4076
|
var last = state && state.autoCheckin && state.autoCheckin.last;
|
|
2921
|
-
if (!last || last.pending !== true) { stopCheckinPoll(); return; }
|
|
4077
|
+
if (!last || last.pending !== true || !pageIsVisible()) { stopCheckinPoll(); return; }
|
|
4078
|
+
// Progress is counted per pass: a new `at` starts a fresh fast window, and a
|
|
4079
|
+
// failure count from the previous pass would otherwise cut the new one short.
|
|
4080
|
+
var stamp = typeof last.at === "string" ? last.at : "";
|
|
4081
|
+
if (stamp !== checkinPollAt) { checkinPollAt = stamp; attempts = 0; checkinPollFailures = 0; }
|
|
4082
|
+
checkinPollAttempts = attempts;
|
|
4083
|
+
// A pass running beside another action is not a reason to stop watching it,
|
|
4084
|
+
// but the poll must not run while that action re-renders. `runBusy` calls
|
|
4085
|
+
// back here when it finishes, so dropping the timer now is safe.
|
|
2922
4086
|
if (busy !== null && busy !== "checkin") { stopCheckinPoll(); return; }
|
|
2923
|
-
if (attempts >= CHECKIN_POLL_LIMIT) { stopCheckinPoll(); return; }
|
|
2924
4087
|
if (checkinPoll !== null) return;
|
|
4088
|
+
// Past the fast window the pass is either long or wedged; keep a slow watch
|
|
4089
|
+
// instead of giving up, or the row reads "running" for the rest of the day.
|
|
4090
|
+
var delay = attempts >= CHECKIN_POLL_LIMIT ? CHECKIN_POLL_SLOW_MS : CHECKIN_POLL_MS;
|
|
2925
4091
|
checkinPoll = window.setTimeout(function () {
|
|
2926
4092
|
checkinPoll = null;
|
|
2927
4093
|
var revision = stateRevision;
|
|
2928
4094
|
invoke("xd.state").then(function (again) {
|
|
2929
4095
|
if (revision !== stateRevision) { pollCheckinLog(attempts + 1); return; }
|
|
2930
|
-
|
|
4096
|
+
// Another action adopted the state; its own render re-arms the watch.
|
|
4097
|
+
if (busy !== null && busy !== "checkin") { stopCheckinPoll(); return; }
|
|
2931
4098
|
adopt(again);
|
|
4099
|
+
// Set before `render()`: its tail re-arms this loop with whatever
|
|
4100
|
+
// `checkinPollAttempts` holds, and `checkinPoll !== null` from there made
|
|
4101
|
+
// the recursive call below return without doing anything - so the count
|
|
4102
|
+
// never advanced and the slow window was never reached.
|
|
4103
|
+
checkinPollAttempts = attempts + 1;
|
|
4104
|
+
checkinPollFailures = 0;
|
|
2932
4105
|
render();
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
4106
|
+
}).catch(function () {
|
|
4107
|
+
// A failing channel leaves the flag set, so re-arming here without a bound
|
|
4108
|
+
// polled forever. The watch gives up and clears what it was watching, the
|
|
4109
|
+
// same way `adoptAndMaybePoll` does.
|
|
4110
|
+
checkinPollFailures += 1;
|
|
4111
|
+
if (checkinPollFailures < CHECKIN_POLL_MAX_FAILURES) { pollCheckinLog(attempts + 1); return; }
|
|
4112
|
+
stopCheckinPoll();
|
|
4113
|
+
if (state && state.autoCheckin && state.autoCheckin.last) {
|
|
4114
|
+
adopt(Object.assign({}, state, {
|
|
4115
|
+
autoCheckin: Object.assign({}, state.autoCheckin, {
|
|
4116
|
+
last: Object.assign({}, state.autoCheckin.last, { pending: false }),
|
|
4117
|
+
}),
|
|
4118
|
+
}));
|
|
4119
|
+
render();
|
|
4120
|
+
}
|
|
4121
|
+
});
|
|
4122
|
+
}, delay);
|
|
2936
4123
|
}
|
|
2937
4124
|
|
|
2938
4125
|
function refresh() {
|
|
@@ -3006,6 +4193,12 @@ function setComposerPoints(enabled) {
|
|
|
3006
4193
|
}).catch(function () {});
|
|
3007
4194
|
}
|
|
3008
4195
|
|
|
4196
|
+
function setRewriteClientName(enabled) {
|
|
4197
|
+
return runBusy("rewrite", function () {
|
|
4198
|
+
return invoke("xd.setRewriteClientName", { enabled: enabled === true });
|
|
4199
|
+
}).catch(function () {});
|
|
4200
|
+
}
|
|
4201
|
+
|
|
3009
4202
|
/** Switch one source (workbuddy / trae / qoder) on or off; the answer is the refreshed document. */
|
|
3010
4203
|
function setSource(source, enabled) {
|
|
3011
4204
|
return runBusy("source", function () {
|
|
@@ -3047,8 +4240,21 @@ function setAutoCheckin(enabled, hours) {
|
|
|
3047
4240
|
}
|
|
3048
4241
|
return runBusy("autoCheckin", function () {
|
|
3049
4242
|
return invoke("xd.setAutoCheckin", { enabled: enabled === true, hours: hours });
|
|
4243
|
+
}).then(function (result) {
|
|
4244
|
+
// Saved: the field now follows the host's value again.
|
|
4245
|
+
autoHoursDraft = null;
|
|
4246
|
+
render();
|
|
4247
|
+
return result;
|
|
3050
4248
|
}).catch(function () {});
|
|
3051
4249
|
}
|
|
4250
|
+
|
|
4251
|
+
/** Run one keep-alive pass by hand. */
|
|
4252
|
+
function runKeepAliveNow() {
|
|
4253
|
+
return runBusy("keepAlive", function () {
|
|
4254
|
+
return invoke("xd.keepAlive", {});
|
|
4255
|
+
}).catch(function () {});
|
|
4256
|
+
}
|
|
4257
|
+
|
|
3052
4258
|
function claimCheckin(accountId) {
|
|
3053
4259
|
// The same guard the other three claim paths carry: a claim started on top of
|
|
3054
4260
|
// a rescan or a refresh is two passes writing the same document.
|
|
@@ -3114,7 +4320,11 @@ function toggleAllVisible() {
|
|
|
3114
4320
|
if (!hit) return;
|
|
3115
4321
|
}
|
|
3116
4322
|
var entry = draft[model.id];
|
|
3117
|
-
if (entry)
|
|
4323
|
+
if (!entry) return;
|
|
4324
|
+
entry.enabled = wanted;
|
|
4325
|
+
// Unticking through the header drops the sheet exactly as the row's own tick
|
|
4326
|
+
// does, or the roster keeps marking a model the header just took out.
|
|
4327
|
+
if (!wanted) closeSheetOf(model.id);
|
|
3118
4328
|
});
|
|
3119
4329
|
renderModels();
|
|
3120
4330
|
}
|
|
@@ -3149,7 +4359,12 @@ function requestModelRoster() {
|
|
|
3149
4359
|
modelRosterRequested = true;
|
|
3150
4360
|
invoke("xd.fetchModels").then(function (next) {
|
|
3151
4361
|
adoptAndMaybePoll(next, 0);
|
|
3152
|
-
}).catch(function () {
|
|
4362
|
+
}).catch(function (error) {
|
|
4363
|
+
// A failed read must not latch the panel onto the static fallback for the
|
|
4364
|
+
// rest of its life: release the guard so the next visit tries again.
|
|
4365
|
+
modelRosterRequested = false;
|
|
4366
|
+
note(String(error && error.message ? error.message : error), "warn");
|
|
4367
|
+
});
|
|
3153
4368
|
}
|
|
3154
4369
|
function discardDraft() {
|
|
3155
4370
|
// Only the page in view: another page's unsaved edits are not this button's to
|
|
@@ -3157,6 +4372,10 @@ function discardDraft() {
|
|
|
3157
4372
|
if (draftSlot !== null) delete drafts[draftSlot];
|
|
3158
4373
|
draft = null;
|
|
3159
4374
|
draftSlot = null;
|
|
4375
|
+
// The session this page's sheet belonged to is over, so it does not reopen on
|
|
4376
|
+
// the rebuild below and the roster stops marking the row. Another page's record
|
|
4377
|
+
// is not this button's to throw away either.
|
|
4378
|
+
if (selectedSheet !== null && selectedSheet.key === currentModelKey()) selectedSheet = null;
|
|
3160
4379
|
renderModels();
|
|
3161
4380
|
note(null);
|
|
3162
4381
|
}
|
|
@@ -3201,6 +4420,9 @@ function saveModels() {
|
|
|
3201
4420
|
if (submittedSlot !== null) delete drafts[submittedSlot];
|
|
3202
4421
|
draft = null;
|
|
3203
4422
|
draftSlot = null;
|
|
4423
|
+
// The edit is done: the sheet collapses with the draft it belonged to
|
|
4424
|
+
// instead of reopening on the rebuild and leaving the row marked as edited.
|
|
4425
|
+
if (selectedSheet !== null && selectedSheet.key === currentModelKey()) selectedSheet = null;
|
|
3204
4426
|
render();
|
|
3205
4427
|
announce(t("models.saved"));
|
|
3206
4428
|
}).catch(function (error) {
|
|
@@ -3262,7 +4484,8 @@ function copyReport() {
|
|
|
3262
4484
|
// -------------------------------------------------------------------- tabs
|
|
3263
4485
|
|
|
3264
4486
|
function selectTab(name) {
|
|
3265
|
-
|
|
4487
|
+
activeTab = name;
|
|
4488
|
+
var views = { pool: "poolView", models: "modelsView", check: "checkView", growth: "growthView" };
|
|
3266
4489
|
Object.keys(views).forEach(function (key) {
|
|
3267
4490
|
show($(views[key]), key === name);
|
|
3268
4491
|
});
|
|
@@ -3272,10 +4495,24 @@ function selectTab(name) {
|
|
|
3272
4495
|
tabs[i].className = isActive ? "subtab active" : "subtab";
|
|
3273
4496
|
tabs[i].setAttribute("aria-selected", isActive ? "true" : "false");
|
|
3274
4497
|
}
|
|
3275
|
-
|
|
4498
|
+
// Each page starts at its own top. Carrying the previous page's offset over
|
|
4499
|
+
// landed the user mid-roster after leaving the pool scrolled to its third
|
|
4500
|
+
// account.
|
|
4501
|
+
pageScrollTo(0);
|
|
4502
|
+
// Entering the tab while another action runs would raise the busy banner and
|
|
4503
|
+
// silently skip the doctor; the next entry retries.
|
|
4504
|
+
if (name === "check" && doctorResult === null && busy === null) runDoctor();
|
|
3276
4505
|
// The model page shows a roster, so entering it is the moment to make sure
|
|
3277
4506
|
// that roster is the vendor's and not this plugin's own fallback.
|
|
3278
4507
|
if (name === "models") requestModelRoster();
|
|
4508
|
+
// Entering the growth page is a refresh, not a prompt to go press a button: the
|
|
4509
|
+
// figures the card shows are read on entry, and the cached ones are shown while
|
|
4510
|
+
// that read is in flight. A read costs one request per account and claims
|
|
4511
|
+
// nothing, so the throttle is what keeps tab-hopping from becoming a burst.
|
|
4512
|
+
// A pass already walking those accounts is waited out: a check-in pass runs the
|
|
4513
|
+
// growth half itself, and a read beside it would double the requests.
|
|
4514
|
+
if (name === "growth" && busy === null && !growthReading && growthStale()
|
|
4515
|
+
&& !(state && state.growth && state.growth.running === true)) readGrowth();
|
|
3279
4516
|
}
|
|
3280
4517
|
|
|
3281
4518
|
function labelTabs() {
|
|
@@ -3283,7 +4520,12 @@ function labelTabs() {
|
|
|
3283
4520
|
for (var i = 0; i < tabs.length; i += 1) {
|
|
3284
4521
|
var key = tabs[i].getAttribute("data-tab");
|
|
3285
4522
|
tabs[i].textContent = t("tab." + key);
|
|
4523
|
+
// The growth centre is WorkBuddy's alone: a tab that leads to a page
|
|
4524
|
+
// reading "not this source" is worse than no tab at all.
|
|
4525
|
+
tabs[i].hidden = key === "growth" && activeSource !== "workbuddy";
|
|
3286
4526
|
}
|
|
4527
|
+
// The risk note is static markup too, on the line with the source tabs.
|
|
4528
|
+
$("riskNote").textContent = t("risk.note");
|
|
3287
4529
|
// The footer links are static markup, so their labels follow the locale here
|
|
3288
4530
|
// rather than through the render pass.
|
|
3289
4531
|
var labels = document.querySelectorAll(".foot-links [data-foot-label]");
|
|
@@ -3295,6 +4537,16 @@ function labelTabs() {
|
|
|
3295
4537
|
// -------------------------------------------------------------------- init
|
|
3296
4538
|
|
|
3297
4539
|
function bind() {
|
|
4540
|
+
// A hidden page stops polling; showing it again re-arms whatever the current
|
|
4541
|
+
// document says is still running.
|
|
4542
|
+
document.addEventListener("visibilitychange", function () {
|
|
4543
|
+
if (!pageIsVisible()) { stopPolling(); stopCheckinPoll(); return; }
|
|
4544
|
+
if (state && state.refreshing === true) adoptAndMaybePoll(state, 0);
|
|
4545
|
+
else if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
|
|
4546
|
+
checkinPollFailures = 0;
|
|
4547
|
+
pollCheckinLog(0);
|
|
4548
|
+
}
|
|
4549
|
+
});
|
|
3298
4550
|
$("refreshBtn").addEventListener("click", refresh);
|
|
3299
4551
|
$("rescanBtn").addEventListener("click", rescan);
|
|
3300
4552
|
$("resetBtn").addEventListener("click", clearCooldowns);
|
|
@@ -3314,11 +4566,30 @@ function bind() {
|
|
|
3314
4566
|
setComposerPoints(state === null || state.showComposerPoints !== true);
|
|
3315
4567
|
});
|
|
3316
4568
|
}
|
|
4569
|
+
// Same shape: a static node, so the listener is bound once and the state is
|
|
4570
|
+
// read at click time rather than captured from the render that drew the label.
|
|
4571
|
+
var rewriteToggle = $("rewriteClientName");
|
|
4572
|
+
if (rewriteToggle) {
|
|
4573
|
+
rewriteToggle.addEventListener("click", function () {
|
|
4574
|
+
setRewriteClientName(state === null || typeof state.replacedClientName !== "string");
|
|
4575
|
+
});
|
|
4576
|
+
}
|
|
3317
4577
|
// Bound once, with the state read at click time: this is a static node, so the
|
|
3318
4578
|
// handler cannot live in the render pass that redraws it.
|
|
4579
|
+
$("autoHours").addEventListener("input", function () {
|
|
4580
|
+
autoHoursDraft = $("autoHours").value;
|
|
4581
|
+
});
|
|
3319
4582
|
$("autoHoursSave").addEventListener("click", function () {
|
|
3320
4583
|
var auto = (state && state.autoCheckin) || { enabled: false };
|
|
3321
|
-
|
|
4584
|
+
// Saving the box is explicit, so unreadable text is reported even while the
|
|
4585
|
+
// switch is off. Turning the switch off still ignores a bad box: that path
|
|
4586
|
+
// has to stop the timer.
|
|
4587
|
+
var hours = parseCheckinHours($("autoHours").value);
|
|
4588
|
+
if (hours === null) {
|
|
4589
|
+
note(t("auto.badHours"));
|
|
4590
|
+
return;
|
|
4591
|
+
}
|
|
4592
|
+
setAutoCheckin(auto.enabled === true, hours);
|
|
3322
4593
|
});
|
|
3323
4594
|
// The manual pass runs the same work the scheduled hour runs, so it is busy for
|
|
3324
4595
|
// as long as that takes — the button reports it rather than sitting idle.
|
|
@@ -3327,6 +4598,15 @@ function bind() {
|
|
|
3327
4598
|
.then(function () { pollCheckinLog(0); })
|
|
3328
4599
|
.catch(function () {});
|
|
3329
4600
|
});
|
|
4601
|
+
// The keep-alive's one control, bound once for the same reason. There is no
|
|
4602
|
+
// schedule behind it, so the button is the only thing that runs a pass.
|
|
4603
|
+
$("tokenKeepAliveRun").addEventListener("click", function () {
|
|
4604
|
+
runKeepAliveNow();
|
|
4605
|
+
});
|
|
4606
|
+
// Bound once, like the check-in button above: the render pass rebuilds most of
|
|
4607
|
+
// the panel, and a listener added per pass would fire one request per render.
|
|
4608
|
+
$("growthRead").addEventListener("click", function () { readGrowth(); });
|
|
4609
|
+
$("growthRun").addEventListener("click", function () { runGrowth(); });
|
|
3330
4610
|
|
|
3331
4611
|
// One listener for every control in the panel, rather than one per button: the
|
|
3332
4612
|
// render pass rebuilds most of them, so per-button listeners would have to be
|