poi-plugin-senka-ledger 0.1.2 → 0.2.0
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/README.ja-JP.md +38 -0
- package/README.ko-KR.md +38 -0
- package/README.md +34 -47
- package/README.zh-CN.md +82 -0
- package/README.zh-TW.md +38 -0
- package/assets/icon.svg +1 -0
- package/i18n/en-US.json +75 -0
- package/i18n/ja-JP.json +75 -0
- package/i18n/ko-KR.json +75 -0
- package/i18n/zh-CN.json +75 -1
- package/i18n/zh-TW.json +75 -1
- package/index.js +32 -4
- package/package.json +7 -6
- package/src/adapter.js +11 -2
- package/src/export.js +8 -6
- package/src/i18n.js +41 -0
- package/src/icon.js +10 -0
- package/src/layout.js +41 -0
- package/src/ledger.js +7 -4
- package/src/model.js +1 -0
- package/src/panel.js +80 -53
- package/src/ranking.js +58 -0
- package/src/styles.js +21 -0
package/i18n/zh-TW.json
CHANGED
|
@@ -1 +1,75 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"Senka Ledger": "戰果手帳",
|
|
3
|
+
"recording": "記錄中",
|
|
4
|
+
"waiting": "等待遊戲資料",
|
|
5
|
+
"storageError": "儲存異常",
|
|
6
|
+
"account": "帳號",
|
|
7
|
+
"month": "月份",
|
|
8
|
+
"timezone": "時區",
|
|
9
|
+
"japan": "日本 UTC+9",
|
|
10
|
+
"china": "中國 UTC+8",
|
|
11
|
+
"current": "目前",
|
|
12
|
+
"exportCSV": "匯出本月 CSV",
|
|
13
|
+
"backupJSON": "備份全部 JSON",
|
|
14
|
+
"back": "返回月覽",
|
|
15
|
+
"prevDay": "前一天",
|
|
16
|
+
"nextDay": "後一天",
|
|
17
|
+
"monthTotal": "本月戰果",
|
|
18
|
+
"dayTotal": "當日戰果",
|
|
19
|
+
"normal": "一般戰果",
|
|
20
|
+
"eo": "EO 戰果",
|
|
21
|
+
"quest": "任務戰果",
|
|
22
|
+
"daily": "每日一般戰果",
|
|
23
|
+
"hourly": "每小時一般戰果",
|
|
24
|
+
"dayDetail": "當日明細",
|
|
25
|
+
"hourDetail": "{{hour}} · 明細",
|
|
26
|
+
"viewAll": "檢視全天",
|
|
27
|
+
"time": "記錄時間",
|
|
28
|
+
"experience": "提督經驗",
|
|
29
|
+
"senka": "戰果",
|
|
30
|
+
"map": "海域",
|
|
31
|
+
"empty": "尚無記錄",
|
|
32
|
+
"unknown": "未在本機記錄的增量",
|
|
33
|
+
"interval": "可能發生區間",
|
|
34
|
+
"detected": "發現於",
|
|
35
|
+
"shown": "共 {{count}} 筆 · 顯示最新 {{limit}} 筆",
|
|
36
|
+
"rankTitle": "排名戰果",
|
|
37
|
+
"rankNo": "名次",
|
|
38
|
+
"rankScore": "戰果",
|
|
39
|
+
"rankGap": "與你的差額",
|
|
40
|
+
"rankReadAt": "讀取時間",
|
|
41
|
+
"rankSelf": "自己",
|
|
42
|
+
"rankWaiting": "在遊戲內開啟排名列表後讀取。",
|
|
43
|
+
"rankPending": "尚未讀取",
|
|
44
|
+
"weekdays": [
|
|
45
|
+
"一",
|
|
46
|
+
"二",
|
|
47
|
+
"三",
|
|
48
|
+
"四",
|
|
49
|
+
"五",
|
|
50
|
+
"六",
|
|
51
|
+
"日"
|
|
52
|
+
],
|
|
53
|
+
"node": "節點 {{node}}",
|
|
54
|
+
"unknownMap": "海域未知",
|
|
55
|
+
"local": "本機確認",
|
|
56
|
+
"unlocated": "未定位",
|
|
57
|
+
"source": "來源",
|
|
58
|
+
"kind": "種類",
|
|
59
|
+
"csvTime": "記錄或發現時間",
|
|
60
|
+
"from": "區間起點",
|
|
61
|
+
"to": "區間終點",
|
|
62
|
+
"invalidLock": "儲存鎖無效,請檢查 .writer-lock。",
|
|
63
|
+
"locked": "另一個 poi 執行個體正在記錄戰果,請先關閉。",
|
|
64
|
+
"invalidAccount": "帳號 ID 無效。",
|
|
65
|
+
"storageNotReady": "儲存尚未初始化。",
|
|
66
|
+
"corrupt": "記錄第 {{line}} 行損壞或未寫完,已保留原檔並暫停寫入。",
|
|
67
|
+
"saveFailed": "儲存失敗,已暫停寫入:{{message}}",
|
|
68
|
+
"official": "自己的排名戰果",
|
|
69
|
+
"ownRank": "自己的名次",
|
|
70
|
+
"readAt": "讀取於 {{time}}",
|
|
71
|
+
"preview": "模擬資料",
|
|
72
|
+
"normalKind": "一般",
|
|
73
|
+
"eoKind": "EO",
|
|
74
|
+
"questKind": "任務"
|
|
75
|
+
}
|
package/index.js
CHANGED
|
@@ -7,13 +7,25 @@ const { Journal } = require('./src/storage')
|
|
|
7
7
|
const { createAdapter, decode } = require('./src/adapter')
|
|
8
8
|
const { createPanel } = require('./src/panel')
|
|
9
9
|
const { toCSV } = require('./src/export')
|
|
10
|
+
const { register } = require('./src/icon')
|
|
11
|
+
const { RANKING_PATH } = require('./src/ranking')
|
|
12
|
+
const { resources, namespace } = require('./src/i18n')
|
|
13
|
+
// Register before poi re-reads the manifest and builds the menu icon.
|
|
14
|
+
try { register(require('@fortawesome/fontawesome-svg-core').library) } catch (e) { if (e.code !== 'MODULE_NOT_FOUND') throw e }
|
|
15
|
+
try {
|
|
16
|
+
const module = require('views/env-parts/i18next')
|
|
17
|
+
const i18n = module.default || module
|
|
18
|
+
if (i18n.addResourceBundle) for (const [language, data] of Object.entries(resources)) i18n.addResourceBundle(language, namespace, data, true, true)
|
|
19
|
+
} catch (e) { if (e.code !== 'MODULE_NOT_FOUND') throw e }
|
|
10
20
|
let journal = null
|
|
11
21
|
let adapter = createAdapter()
|
|
12
22
|
let error = null
|
|
13
23
|
let directory = ''
|
|
14
24
|
let loaded = false
|
|
25
|
+
let poiI18n = null
|
|
26
|
+
let onLanguageChanged = null
|
|
15
27
|
const subscribers = new Set()
|
|
16
|
-
const snapshot = () => ({ account: adapter.account, accounts: [...new Set([...(journal ? journal.list() : []), ...(adapter.account ? [adapter.account] : [])])], error, directory })
|
|
28
|
+
const snapshot = () => ({ account: adapter.account, accounts: [...new Set([...(journal ? journal.list() : []), ...(adapter.account ? [adapter.account] : [])])], error, directory, language: poiI18n?.language || 'en-US' })
|
|
17
29
|
const emit = () => { const value = snapshot(); for (const callback of subscribers) callback(value) }
|
|
18
30
|
function onResponse(event) {
|
|
19
31
|
try {
|
|
@@ -25,9 +37,21 @@ function onResponse(event) {
|
|
|
25
37
|
}
|
|
26
38
|
exports.pluginDidLoad = function pluginDidLoad() {
|
|
27
39
|
if (loaded) return
|
|
28
|
-
const { APPDATA_PATH, isMain } = require('views/env')
|
|
40
|
+
const { APPDATA_PATH, isMain, config } = require('views/env')
|
|
29
41
|
if (isMain === false) return
|
|
30
42
|
loaded = true
|
|
43
|
+
try {
|
|
44
|
+
const module = require('views/env-parts/i18next')
|
|
45
|
+
poiI18n = module.default || module
|
|
46
|
+
onLanguageChanged = () => emit()
|
|
47
|
+
poiI18n.on('languageChanged', onLanguageChanged)
|
|
48
|
+
} catch (e) { if (e.code !== 'MODULE_NOT_FOUND') throw e }
|
|
49
|
+
// Preserve window preferences when moving from the old short ID to poi's
|
|
50
|
+
// package-name ID, which is also used by the active plugin header.
|
|
51
|
+
if (config) for (const prefix of ['poi.plugin.windowmode', 'poi.plugin.pin', 'poi.plugin.favorite', 'plugin']) {
|
|
52
|
+
const old = config.get(`${prefix}.senka-ledger`)
|
|
53
|
+
if (old !== undefined && config.get(`${prefix}.poi-plugin-senka-ledger`) === undefined) config.set(`${prefix}.poi-plugin-senka-ledger`, old)
|
|
54
|
+
}
|
|
31
55
|
directory = path.join(APPDATA_PATH, 'senka-ledger')
|
|
32
56
|
try {
|
|
33
57
|
journal = new Journal(directory)
|
|
@@ -40,6 +64,9 @@ exports.pluginWillUnload = function pluginWillUnload() {
|
|
|
40
64
|
window.removeEventListener('game.response', onResponse)
|
|
41
65
|
window.removeEventListener('beforeunload', exports.pluginWillUnload)
|
|
42
66
|
if (journal) journal.close()
|
|
67
|
+
if (poiI18n && onLanguageChanged) poiI18n.off('languageChanged', onLanguageChanged)
|
|
68
|
+
poiI18n = null
|
|
69
|
+
onLanguageChanged = null
|
|
43
70
|
journal = null
|
|
44
71
|
adapter = createAdapter()
|
|
45
72
|
error = null
|
|
@@ -57,10 +84,10 @@ const service = {
|
|
|
57
84
|
if (!journal || !account) return null
|
|
58
85
|
try { return journal.load(account) } catch (e) { return { error: e.message } }
|
|
59
86
|
},
|
|
60
|
-
export(account, month, zone, type) {
|
|
87
|
+
export(account, month, zone, type, language) {
|
|
61
88
|
if (!journal) throw new Error('存储尚未初始化')
|
|
62
89
|
const entry = journal.load(account)
|
|
63
|
-
const data = type === 'json' ? JSON.stringify({ format: 'poi-senka-ledger', version: 1, account, journal: fs.readFileSync(entry.file, 'utf8') }, null, 2) : toCSV(entry.state, month, zone)
|
|
90
|
+
const data = type === 'json' ? JSON.stringify({ format: 'poi-senka-ledger', version: 1, account, journal: fs.readFileSync(entry.file, 'utf8') }, null, 2) : toCSV(entry.state, month, zone, language)
|
|
64
91
|
const blob = new Blob([data], { type: type === 'json' ? 'application/json;charset=utf-8' : 'text/csv;charset=utf-8' })
|
|
65
92
|
const url = URL.createObjectURL(blob)
|
|
66
93
|
const a = document.createElement('a')
|
|
@@ -71,3 +98,4 @@ const service = {
|
|
|
71
98
|
}
|
|
72
99
|
}
|
|
73
100
|
exports.reactClass = createPanel(React, service)
|
|
101
|
+
exports.switchPluginPath = [RANKING_PATH]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poi-plugin-senka-ledger",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A local senka ledger for poi with daily history, hourly details and ranking snapshots.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "asparagusThief",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public",
|
|
19
19
|
"registry": "https://registry.npmjs.org/"
|
|
20
20
|
},
|
|
21
|
-
"files": ["index.js", "src", "i18n", "README
|
|
21
|
+
"files": ["index.js", "src", "assets", "i18n", "README*.md", "LICENSE"],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "node --test test/*.test.js",
|
|
24
24
|
"check": "node scripts/check.js",
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"poiPlugin": {
|
|
28
28
|
"name": "Senka Ledger",
|
|
29
|
-
"id": "senka-ledger",
|
|
30
|
-
"
|
|
29
|
+
"id": "poi-plugin-senka-ledger",
|
|
30
|
+
"title": "Senka Ledger",
|
|
31
|
+
"description": "A local senka ledger for poi with daily history, hourly details and ranking snapshots.",
|
|
31
32
|
"i18nDir": "i18n",
|
|
32
|
-
"icon": "
|
|
33
|
+
"icon": ["fas", "senka-ledger"],
|
|
33
34
|
"earliestCompatibleMain": "12.0.1",
|
|
34
35
|
"priority": 98
|
|
35
36
|
}
|
package/src/adapter.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const { EO, QUESTS } = require('./ledger')
|
|
4
4
|
const { parts } = require('./time')
|
|
5
|
+
const { RANKING_PATH, createRankingReader, readRanking } = require('./ranking')
|
|
5
6
|
const number = value => {
|
|
6
7
|
if (value === null || value === undefined || value === '' || typeof value === 'boolean') return null
|
|
7
8
|
const n = Number(value)
|
|
@@ -9,7 +10,7 @@ const number = value => {
|
|
|
9
10
|
}
|
|
10
11
|
const BATTLES = new Set(['/kcsapi/api_req_sortie/battleresult', '/kcsapi/api_req_combined_battle/battleresult'])
|
|
11
12
|
function createAdapter() {
|
|
12
|
-
return { account: null, mapId: null, node: null }
|
|
13
|
+
return { account: null, nickname: '', mapId: null, node: null, ranking: createRankingReader() }
|
|
13
14
|
}
|
|
14
15
|
// Read only documented, relevant fields. Tokens and complete API bodies never enter the journal.
|
|
15
16
|
function decode(adapter, detail) {
|
|
@@ -19,17 +20,24 @@ function decode(adapter, detail) {
|
|
|
19
20
|
path === '/kcsapi/api_get_member/basic' ? body : null
|
|
20
21
|
if (basic && /^\d+$/.test(String(basic.api_member_id))) {
|
|
21
22
|
const account = String(basic.api_member_id)
|
|
22
|
-
if (adapter.account !== account) { adapter.mapId = null; adapter.node = null }
|
|
23
|
+
if (adapter.account !== account) { adapter.mapId = null; adapter.node = null; adapter.ranking = createRankingReader(); adapter.nickname = '' }
|
|
23
24
|
adapter.account = account
|
|
25
|
+
if (typeof basic.api_nickname === 'string') adapter.nickname = basic.api_nickname
|
|
24
26
|
}
|
|
25
27
|
if (path === '/kcsapi/api_start2/getData') {
|
|
26
28
|
adapter.account = null
|
|
27
29
|
adapter.mapId = null
|
|
28
30
|
adapter.node = null
|
|
31
|
+
adapter.nickname = ''
|
|
32
|
+
adapter.ranking = createRankingReader()
|
|
29
33
|
}
|
|
30
34
|
if (!adapter.account) return null
|
|
31
35
|
const records = []
|
|
32
36
|
const push = data => records.push({ v: 1, at, ...data })
|
|
37
|
+
if (path === RANKING_PATH) {
|
|
38
|
+
const ranking = readRanking(adapter.ranking, body, at, adapter.nickname, adapter.account)
|
|
39
|
+
if (ranking) records.push(ranking)
|
|
40
|
+
}
|
|
33
41
|
let exp = null
|
|
34
42
|
if (basic) exp = number(basic.api_experience)
|
|
35
43
|
else if (path === '/kcsapi/api_get_member/record') exp = number(body.api_experience?.[0])
|
|
@@ -44,6 +52,7 @@ function decode(adapter, detail) {
|
|
|
44
52
|
const mapLabel = adapter.mapId === null ? '海域未知' : `${Math.floor(adapter.mapId / 10)}-${adapter.mapId % 10}`
|
|
45
53
|
if (exp !== null) push({ type: 'experience', exp,
|
|
46
54
|
gain: BATTLES.has(path) ? number(body.api_get_exp) : null,
|
|
55
|
+
...(BATTLES.has(path) ? { mapId: adapter.mapId, node: adapter.node, rank: String(body.api_win_rank || '?') } : {}),
|
|
47
56
|
label: BATTLES.has(path) ? `${mapLabel}${adapter.node === null ? '' : ` 节点 ${adapter.node}`} · ${body.api_win_rank || '?'} 胜败` : '总经验观测' })
|
|
48
57
|
const eoAmount = number(body.api_get_exmap_rate) || number(body.api_get_eo_rate)
|
|
49
58
|
if (eoAmount && (BATTLES.has(path) || path === '/kcsapi/api_req_map/next' || path === '/kcsapi/api_req_map/start')) {
|
package/src/export.js
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
const { summarize } = require('./model')
|
|
4
4
|
const { formatTime } = require('./time')
|
|
5
|
+
const { translator, battleText } = require('./i18n')
|
|
5
6
|
// Spreadsheet applications interpret leading formula characters even inside CSV quotes.
|
|
6
7
|
function cell(value) {
|
|
7
8
|
const text = String(value ?? '')
|
|
8
9
|
return '"' + (/^[=+@\-\t\r]/.test(text) ? "'" + text : text).replaceAll('"', '""') + '"'
|
|
9
10
|
}
|
|
10
|
-
function toCSV(state, month, zone) {
|
|
11
|
+
function toCSV(state, month, zone, language = 'zh-CN') {
|
|
12
|
+
const t = translator(language)
|
|
11
13
|
const stats = summarize(state, month, zone)
|
|
12
|
-
const rows = [['
|
|
13
|
-
['
|
|
14
|
-
['
|
|
14
|
+
const rows = [[t('month'), month, t('timezone'), zone], [t('monthTotal'), stats.total.toFixed(4)], [t('normal'), stats.normal.toFixed(4)],
|
|
15
|
+
[t('eo'), stats.eo.toFixed(4)], [t('quest'), stats.quest.toFixed(4)], [],
|
|
16
|
+
['source', 'kind', 'senka', 'experience', 'csvTime', 'from', 'to', 'map', 'timezone'].map(key => t(key))]
|
|
15
17
|
const events = [...stats.days.flatMap(d => d.events), ...stats.unknown].sort((a, b) => a.at - b.at)
|
|
16
|
-
for (const e of events) rows.push([e.source === 'local' ? '
|
|
17
|
-
e.from === undefined ? '' : formatTime(e.from, zone), e.to === undefined ? '' : formatTime(e.to, zone), e.source === 'local' ? e
|
|
18
|
+
for (const e of events) rows.push([t(e.source === 'local' ? 'local' : 'unlocated'), t('normalKind'), e.amount.toFixed(4), e.exp ?? '', formatTime(e.at, zone),
|
|
19
|
+
e.from === undefined ? '' : formatTime(e.from, zone), e.to === undefined ? '' : formatTime(e.to, zone), e.source === 'local' ? battleText(e, t) : '', zone])
|
|
18
20
|
return '\ufeff' + rows.map(row => row.map(cell).join(',')).join('\r\n')
|
|
19
21
|
}
|
|
20
22
|
module.exports = { toCSV, cell }
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const resources = {
|
|
4
|
+
'en-US': require('../i18n/en-US.json'), 'zh-CN': require('../i18n/zh-CN.json'),
|
|
5
|
+
'zh-TW': require('../i18n/zh-TW.json'), 'ja-JP': require('../i18n/ja-JP.json'), 'ko-KR': require('../i18n/ko-KR.json')
|
|
6
|
+
}
|
|
7
|
+
const namespace = 'poi-plugin-senka-ledger'
|
|
8
|
+
function normalize(language = 'en-US') {
|
|
9
|
+
const value = language.toLowerCase().replace('_', '-')
|
|
10
|
+
if (/^zh-(tw|hk|hant)/.test(value)) return 'zh-TW'
|
|
11
|
+
if (value.startsWith('zh')) return 'zh-CN'
|
|
12
|
+
if (value.startsWith('ja')) return 'ja-JP'
|
|
13
|
+
if (value.startsWith('ko')) return 'ko-KR'
|
|
14
|
+
return 'en-US'
|
|
15
|
+
}
|
|
16
|
+
function translator(language) {
|
|
17
|
+
const data = resources[normalize(language)]
|
|
18
|
+
return (key, values = {}) => {
|
|
19
|
+
const value = data[key] ?? resources['en-US'][key] ?? key
|
|
20
|
+
return typeof value === 'string' ? value.replace(/\{\{(\w+)\}\}/g, (_, name) => String(values[name] ?? '')) : value
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function errorText(error, t) {
|
|
24
|
+
const message = error?.message || String(error || '')
|
|
25
|
+
if (message.startsWith('存储锁无效')) return t('invalidLock')
|
|
26
|
+
if (message.startsWith('另一个 poi')) return t('locked')
|
|
27
|
+
if (message === 'Invalid account') return t('invalidAccount')
|
|
28
|
+
if (message === '存储尚未初始化') return t('storageNotReady')
|
|
29
|
+
const corrupt = message.match(/^记录第 (\d+) 行异常:/)
|
|
30
|
+
if (corrupt) return t('corrupt', { line: corrupt[1] })
|
|
31
|
+
if (message.startsWith('保存失败,已暂停写入:')) return t('saveFailed', { message: message.split(':').slice(1).join(':') })
|
|
32
|
+
return message
|
|
33
|
+
}
|
|
34
|
+
function battleText(event, t) {
|
|
35
|
+
const legacy = event.label?.match(/^(\d+-\d+|海域未知)(?: 节点 (\d+))? · ([A-Z?]+) 胜败$/)
|
|
36
|
+
const map = event.mapId != null ? `${Math.floor(event.mapId / 10)}-${event.mapId % 10}` : legacy?.[1] !== '海域未知' && legacy?.[1] || t('unknownMap')
|
|
37
|
+
const node = event.node ?? legacy?.[2]
|
|
38
|
+
const rank = event.rank || legacy?.[3]
|
|
39
|
+
return `${map}${node != null ? ' · ' + t('node', { node }) : ''}${rank ? ' · ' + rank : ''}`
|
|
40
|
+
}
|
|
41
|
+
module.exports = { resources, namespace, normalize, translator, errorText, battleText }
|
package/src/icon.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Original notebook, bookmark and tally design; shared by the SVG and poi icon.
|
|
4
|
+
const iconPath = 'M16 4H48A8 8 0 0 1 56 12V52A8 8 0 0 1 48 60H16A8 8 0 0 1 8 52V12A8 8 0 0 1 16 4ZM18 10A4 4 0 0 0 14 14V50A4 4 0 0 0 18 54H46A4 4 0 0 0 50 50V14A4 4 0 0 0 46 10H18ZM34 4H44V26L39 22L34 26V4ZM21 30H43V34H21ZM21 40H25V47H21ZM29 38H33V47H29ZM37 36H41V47H37Z'
|
|
5
|
+
const definition = { prefix: 'fas', iconName: 'senka-ledger', icon: [64, 64, [], 'e620', iconPath] }
|
|
6
|
+
function register(library) { library.add(definition) }
|
|
7
|
+
function createIcon(React, props = {}) {
|
|
8
|
+
return React.createElement('svg', { viewBox: '0 0 64 64', fill: 'currentColor', 'aria-hidden': true, ...props }, React.createElement('path', { d: iconPath, fillRule: 'nonzero' }))
|
|
9
|
+
}
|
|
10
|
+
module.exports = { iconPath, definition, register, createIcon }
|
package/src/layout.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
function bindPanel(root) {
|
|
4
|
+
if (!root) return () => {}
|
|
5
|
+
const view = root.ownerDocument.defaultView
|
|
6
|
+
const host = root.closest('.poi-app-tabpane') || root.parentElement
|
|
7
|
+
const update = () => {
|
|
8
|
+
const top = root.getBoundingClientRect().top
|
|
9
|
+
const bottom = host?.getBoundingClientRect().bottom || view.innerHeight
|
|
10
|
+
const height = Math.max(0, Math.floor(Math.min(bottom, view.innerHeight) - top))
|
|
11
|
+
if (root.style.height !== height + 'px') root.style.height = height + 'px'
|
|
12
|
+
}
|
|
13
|
+
const resize = new view.ResizeObserver(update)
|
|
14
|
+
if (host) resize.observe(host)
|
|
15
|
+
view.addEventListener('resize', update)
|
|
16
|
+
update()
|
|
17
|
+
return () => { resize.disconnect(); view.removeEventListener('resize', update) }
|
|
18
|
+
}
|
|
19
|
+
function fitNumbers(root) {
|
|
20
|
+
if (!root) return
|
|
21
|
+
const view = root.ownerDocument.defaultView
|
|
22
|
+
const calendar = root.querySelector('.calendar')
|
|
23
|
+
if (calendar) {
|
|
24
|
+
const context = root.ownerDocument.createElement('canvas').getContext('2d')
|
|
25
|
+
const gap = parseFloat(view.getComputedStyle(calendar).columnGap) || 0
|
|
26
|
+
let required = 380
|
|
27
|
+
for (const el of calendar.querySelectorAll('.tile-value')) {
|
|
28
|
+
const tile = view.getComputedStyle(el.parentElement)
|
|
29
|
+
context.font = '650 12px ' + view.getComputedStyle(el).fontFamily
|
|
30
|
+
const cell = context.measureText(el.textContent).width + parseFloat(tile.paddingLeft) + parseFloat(tile.paddingRight) + 2
|
|
31
|
+
required = Math.max(required, cell * 7 + gap * 6)
|
|
32
|
+
}
|
|
33
|
+
calendar.style.minWidth = Math.ceil(required) + 'px'
|
|
34
|
+
}
|
|
35
|
+
for (const el of root.querySelectorAll('.tile-value')) {
|
|
36
|
+
el.style.fontSize = ''
|
|
37
|
+
let size = parseFloat(view.getComputedStyle(el).fontSize)
|
|
38
|
+
while (size > 8 && el.scrollWidth > el.clientWidth + 1) { size--; el.style.fontSize = size + 'px' }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
module.exports = { bindPanel, fitNumbers }
|
package/src/ledger.js
CHANGED
|
@@ -15,11 +15,12 @@ function validInput(input) {
|
|
|
15
15
|
case 'bonus': return ['eo', 'quest'].includes(input.kind) && integer(input.amount) && input.amount > 0 && typeof input.key === 'string' && typeof input.label === 'string' &&
|
|
16
16
|
(input.mapId === null || integer(input.mapId)) && (input.questId === null || integer(input.questId))
|
|
17
17
|
case 'maps': return Array.isArray(input.cleared) && input.cleared.every(n => integer(n) && Object.hasOwn(EO, n))
|
|
18
|
+
case 'ranking': return integer(input.period) && input.period <= input.at && Array.isArray(input.entries) && input.entries.length <= 8 && input.entries.every(e => integer(e.rank) && e.rank > 0 && integer(e.score) && typeof e.self === 'boolean')
|
|
18
19
|
default: return false
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
function createLedger() {
|
|
22
|
-
return { events: [], baseline: null, eoMonths: {}, unlocatedEO: {}, ambiguousEO: {}, bonusKeys: new Set(), sequence: 0 }
|
|
23
|
+
return { events: [], rankingHistory: [], baseline: null, eoMonths: {}, unlocatedEO: {}, ambiguousEO: {}, bonusKeys: new Set(), sequence: 0 }
|
|
23
24
|
}
|
|
24
25
|
function add(state, event) {
|
|
25
26
|
state.events.push({ id: ++state.sequence, ...event })
|
|
@@ -30,14 +31,16 @@ function unknown(state, input, amount, kind, from, label) {
|
|
|
30
31
|
function apply(state, input) {
|
|
31
32
|
if (!validInput(input)) throw new Error('Invalid ledger record')
|
|
32
33
|
const { at } = input
|
|
33
|
-
if (input.type === '
|
|
34
|
+
if (input.type === 'ranking') {
|
|
35
|
+
state.rankingHistory.push(input)
|
|
36
|
+
} else if (input.type === 'experience') {
|
|
34
37
|
const old = state.baseline
|
|
35
38
|
// Ignore stale observations: they must never move the cumulative baseline backwards.
|
|
36
39
|
if (old && at < old.at) return
|
|
37
40
|
const localGain = input.gain
|
|
38
41
|
if (!old) {
|
|
39
42
|
if (localGain !== null && localGain <= input.exp && localGain > 0) {
|
|
40
|
-
add(state, { source: 'local', kind: 'normal', amount: localGain * RATE, exp: localGain, at, label: input.label })
|
|
43
|
+
add(state, { source: 'local', kind: 'normal', amount: localGain * RATE, exp: localGain, at, label: input.label, mapId: input.mapId, node: input.node, rank: input.rank })
|
|
41
44
|
}
|
|
42
45
|
add(state, { source: 'baseline', kind: 'baseline', amount: 0, at, label: '首次观测:此前普通战果未收录' })
|
|
43
46
|
} else {
|
|
@@ -51,7 +54,7 @@ function apply(state, input) {
|
|
|
51
54
|
} else {
|
|
52
55
|
const known = localGain || 0
|
|
53
56
|
if (delta > known) unknown(state, input, (delta - known) * RATE, 'normal', old.at, '未在本地记录的经验增量(可能来自其他客户端)')
|
|
54
|
-
if (known > 0) add(state, { source: 'local', kind: 'normal', amount: known * RATE, exp: known, at, label: input.label })
|
|
57
|
+
if (known > 0) add(state, { source: 'local', kind: 'normal', amount: known * RATE, exp: known, at, label: input.label, mapId: input.mapId, node: input.node, rank: input.rank })
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
state.baseline = { exp: input.exp, at }
|
package/src/model.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const { parts, monthBounds } = require('./time')
|
|
4
4
|
function months(state, zone) {
|
|
5
5
|
const result = new Set()
|
|
6
|
+
for (const record of state.rankingHistory || []) result.add(parts(record.period).month)
|
|
6
7
|
for (const e of state.events) {
|
|
7
8
|
if (e.source === 'unknown' && e.kind !== 'normal') continue
|
|
8
9
|
result.add(parts(e.at, zone).month)
|
package/src/panel.js
CHANGED
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
const { parts, formatTime, monthBounds, DAY } = require('./time')
|
|
4
4
|
const { months, summarize } = require('./model')
|
|
5
5
|
const { createLedger } = require('./ledger')
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const { snapshot: rankingSnapshot, ANCHORS } = require('./ranking')
|
|
7
|
+
const { translator, normalize, errorText, battleText } = require('./i18n')
|
|
8
|
+
const { bindPanel, fitNumbers } = require('./layout')
|
|
9
|
+
const { createIcon } = require('./icon')
|
|
10
|
+
const style = require('./styles')
|
|
11
|
+
|
|
12
12
|
const colors = ['rgba(130,150,160,.13)', '#c4e9d8', '#81cdb2', '#36aa8f', '#087e70']
|
|
13
|
-
const fmt = n => n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
14
|
-
const tileNumber = n => n.toLocaleString('zh-CN', { useGrouping: false, minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
15
13
|
function tileStyle(value, max) {
|
|
16
14
|
const level = value <= 0 ? 0 : Math.min(4, 1 + Math.floor(value / (max || 1) * 3))
|
|
17
15
|
return { background: colors[level], color: level === 4 ? '#fff' : level ? '#173e36' : 'inherit' }
|
|
@@ -19,22 +17,34 @@ function tileStyle(value, max) {
|
|
|
19
17
|
function createPanel(React, service) {
|
|
20
18
|
const h = React.createElement
|
|
21
19
|
return function SenkaLedgerPanel() {
|
|
22
|
-
const [
|
|
20
|
+
const [status, setStatus] = React.useState(service.snapshot())
|
|
23
21
|
const [zone, setZone] = React.useState('Asia/Tokyo')
|
|
24
22
|
const [month, setMonth] = React.useState(parts(Date.now()).month)
|
|
25
23
|
const [day, setDay] = React.useState(null)
|
|
26
24
|
const [viewAccount, setViewAccount] = React.useState('')
|
|
27
25
|
const [slot, setSlot] = React.useState(null)
|
|
28
26
|
const [exportError, setExportError] = React.useState('')
|
|
29
|
-
|
|
30
|
-
const
|
|
27
|
+
const root = React.useRef(null)
|
|
28
|
+
const language = normalize(status.language)
|
|
29
|
+
const t = translator(language)
|
|
30
|
+
const fmt = n => n.toLocaleString(language, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
31
|
+
const tileNumber = n => n.toLocaleString(language, { useGrouping: false, minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
32
|
+
React.useEffect(() => service.subscribe(setStatus), [])
|
|
33
|
+
React.useEffect(() => bindPanel(root.current), [])
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const view = root.current?.ownerDocument.defaultView
|
|
36
|
+
if (view?.isWindowMode) root.current.ownerDocument.title = t('Senka Ledger')
|
|
37
|
+
}, [language])
|
|
38
|
+
const account = viewAccount || status.account || status.accounts[0] || ''
|
|
31
39
|
const entry = service.entry(account)
|
|
32
40
|
const state = entry?.state || createLedger()
|
|
33
41
|
const allMonths = [...new Set([parts(Date.now(), zone).month, month, ...months(state, zone)])].sort().reverse()
|
|
34
42
|
const stats = summarize(state, month, zone)
|
|
35
43
|
const selected = stats.days.find(d => d.day === day) || null
|
|
36
44
|
const totals = selected || stats
|
|
37
|
-
const
|
|
45
|
+
const ranks = rankingSnapshot(state.rankingHistory, month)
|
|
46
|
+
const own = ranks.rows.find(row => row.self)
|
|
47
|
+
const rankRows = [...new Set([...ANCHORS, ...(own ? [own.rank] : [])])].sort((a, b) => a - b)
|
|
38
48
|
const maxDay = Math.max(0, ...stats.days.map(d => d.normal))
|
|
39
49
|
const maxHour = selected ? Math.max(0, ...selected.slots) : 0
|
|
40
50
|
const timeline = selected ? selected.events.filter(e => slot === null || parts(e.at, zone).hour === slot).slice().sort((a, b) => b.at - a.at || b.id - a.id) : []
|
|
@@ -42,56 +52,73 @@ function createPanel(React, service) {
|
|
|
42
52
|
const selectedStart = selected ? start + (Number(selected.day.slice(-2)) - 1) * DAY : null
|
|
43
53
|
const unknown = stats.unknown.filter(e => !selected || (e.from < selectedStart + DAY && e.to >= selectedStart)).slice().sort((a, b) => b.at - a.at)
|
|
44
54
|
const offset = (new Date(month + '-01T00:00:00Z').getUTCDay() + 6) % 7
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
fitNumbers(root.current)
|
|
57
|
+
const observer = new root.current.ownerDocument.defaultView.ResizeObserver(() => fitNumbers(root.current))
|
|
58
|
+
observer.observe(root.current)
|
|
59
|
+
return () => observer.disconnect()
|
|
60
|
+
}, [month, day, zone, language, status, account])
|
|
61
|
+
const card = (key, value, accent = false) => h('div', { className: 'card', 'data-summary': key }, h('div', { className: 'muted card-label' }, t(key)), h('div', { className: `value${accent ? ' accent' : ''}` }, fmt(value)))
|
|
62
|
+
const th = labels => h('thead', null, h('tr', null, ...labels.map(key => h('th', { key }, t(key)))))
|
|
63
|
+
const stamp = at => {
|
|
64
|
+
const text = formatTime(at, zone)
|
|
65
|
+
return h('time', { className: 'stamp', dateTime: new Date(at).toISOString() }, h('span', null, text.slice(0, 10)), h('span', null, text.slice(11)))
|
|
66
|
+
}
|
|
47
67
|
const back = () => { setDay(null); setSlot(null) }
|
|
48
68
|
const openDay = value => { setDay(value); setSlot(null) }
|
|
49
69
|
const download = type => {
|
|
50
|
-
try { service.export(account, month, zone, type); setExportError('') } catch (error) { setExportError(error.message) }
|
|
70
|
+
try { service.export(account, month, zone, type, language); setExportError('') } catch (error) { setExportError(error.message) }
|
|
51
71
|
}
|
|
52
|
-
const
|
|
53
|
-
return h('main', { className: 'sl', 'data-view': selected ? 'day' : 'month' }, h('style', null, style),
|
|
54
|
-
h('div', { className: 'top' }, h('h2', null, '
|
|
55
|
-
|
|
72
|
+
const failure = status.error || entry?.error || exportError
|
|
73
|
+
return h('div', { className: 'sl-shell', ref: root }, h('main', { className: 'sl', 'data-view': selected ? 'day' : 'month', lang: language }, h('style', null, style),
|
|
74
|
+
h('div', { className: 'top' }, h('div', { className: 'brand' }, createIcon(React), h('h2', null, t('Senka Ledger'))), h('span', { className: 'tag' }, t(failure ? 'storageError' : status.account ? 'recording' : 'waiting'))),
|
|
75
|
+
failure && h('p', { role: 'alert', className: 'error' }, errorText(failure, t)),
|
|
56
76
|
h('div', { className: 'controls' },
|
|
57
|
-
h('label', null, '
|
|
58
|
-
!account && h('option', { value: '' }, '
|
|
59
|
-
h('label', null, '
|
|
60
|
-
h('label', null, '
|
|
61
|
-
h('button', { disabled: !account, onClick: () => download('csv') }, '
|
|
62
|
-
h('button', { disabled: !account, onClick: () => download('json') }, '
|
|
77
|
+
h('label', null, t('account'), h('select', { 'aria-label': t('account'), 'data-control': 'account', value: account, onChange: e => { setViewAccount(e.target.value); back() } },
|
|
78
|
+
!account && h('option', { value: '' }, t('waiting')), ...status.accounts.map(id => h('option', { key: id, value: id }, id + (id === status.account ? ' · ' + t('current') : ''))))),
|
|
79
|
+
h('label', null, t('month'), h('select', { 'aria-label': t('month'), 'data-control': 'month', value: month, onChange: e => { setMonth(e.target.value); back() } }, ...allMonths.map(m => h('option', { key: m }, m)))),
|
|
80
|
+
h('label', null, t('timezone'), h('select', { 'aria-label': t('timezone'), 'data-control': 'zone', value: zone, onChange: e => { setZone(e.target.value); setSlot(null) } }, h('option', { value: 'Asia/Tokyo' }, t('japan')), h('option', { value: 'Asia/Shanghai' }, t('china')))),
|
|
81
|
+
h('button', { disabled: !account, onClick: () => download('csv') }, t('exportCSV')),
|
|
82
|
+
h('button', { disabled: !account, onClick: () => download('json') }, t('backupJSON'))),
|
|
63
83
|
selected && h('div', { className: 'top section-head navigation' },
|
|
64
|
-
h('button', { onClick: back, '
|
|
84
|
+
h('button', { onClick: back, 'data-action': 'back' }, '← ' + t('back')), h('h3', null, selected.day),
|
|
65
85
|
h('div', { className: 'navigation' },
|
|
66
|
-
h('button', { disabled: selected === stats.days[0], onClick: () => openDay(stats.days[stats.days.indexOf(selected) - 1].day) }, '
|
|
67
|
-
h('button', { disabled: selected === stats.days[stats.days.length - 1], onClick: () => openDay(stats.days[stats.days.indexOf(selected) + 1].day) }, '
|
|
68
|
-
h('div', { className: 'cards' }, card(
|
|
69
|
-
|
|
70
|
-
h(
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
h('button', { disabled: selected === stats.days[0], onClick: () => openDay(stats.days[stats.days.indexOf(selected) - 1].day) }, t('prevDay')),
|
|
87
|
+
h('button', { disabled: selected === stats.days[stats.days.length - 1], onClick: () => openDay(stats.days[stats.days.indexOf(selected) + 1].day) }, t('nextDay')))),
|
|
88
|
+
h('div', { className: 'cards' }, card(selected ? 'dayTotal' : 'monthTotal', totals.total, true), card('normal', totals.normal), card('eo', totals.eo), card('quest', totals.quest)),
|
|
89
|
+
h('details', { className: 'section ranking', 'aria-label': t('rankTitle') }, h('summary', { className: 'rank-summary' }, h('h3', null, t('rankTitle')), h('span', { className: 'rank-own' }, own ? `${t('rankSelf')} #${own.rank} · ${fmt(own.score)}` : t('rankPending'))),
|
|
90
|
+
ranks.rows.length ? h(React.Fragment, null,
|
|
91
|
+
h('div', { className: 'rank-meta' }, h('span', { className: 'rank-own' }, own ? `${t('rankSelf')} #${own.rank} · ${fmt(own.score)}` : `${t('official')} · ${t('rankPending')}`)),
|
|
92
|
+
h('div', { className: 'scroll' }, h('table', { className: 'rank-table', 'data-table': 'ranking' }, th(['rankNo', 'rankScore', 'rankGap', 'rankReadAt']), h('tbody', null, ...rankRows.map(rank => {
|
|
93
|
+
const row = ranks.rows.find(r => r.rank === rank)
|
|
94
|
+
const gap = row && own ? row.score - own.score : null
|
|
95
|
+
return h('tr', { key: rank, className: row?.self ? 'rank-own' : '' }, h('td', null, `#${rank}${row?.self ? ' · ' + t('rankSelf') : ''}`), h('td', null, row ? fmt(row.score) : '—'), h('td', null, gap === null || row.self ? '—' : `${gap > 0 ? '+' : ''}${fmt(gap)}`), h('td', null, row ? stamp(row.at) : '—'))
|
|
96
|
+
}))))) : h('p', { className: 'muted empty' }, t('rankWaiting'))),
|
|
97
|
+
!selected ? h('section', { className: 'section' },
|
|
98
|
+
h('h3', { className: 'section-head' }, `${month} · ${t('daily')}`),
|
|
99
|
+
h('div', { className: 'scroll' }, h('div', { className: 'calendar', 'aria-label': t('daily') },
|
|
100
|
+
...t('weekdays').map((s, i) => h('div', { key: i, className: 'weekday' }, s)),
|
|
73
101
|
...Array.from({ length: offset }, (_, i) => h('div', { key: `blank-${i}`, 'aria-hidden': true })),
|
|
74
|
-
...stats.days.map(d => h('button', { key: d.day, className: 'tile', 'data-day': d.day,
|
|
75
|
-
'aria-label': `${d.day}
|
|
76
|
-
h('span', { className: 'tile-label' }, Number(d.day.slice(-2))), h('span', { className: 'tile-value' }, tileNumber(d.normal))))))
|
|
77
|
-
h('section', { className: 'section', '
|
|
78
|
-
h('
|
|
79
|
-
|
|
80
|
-
'aria-label': `${selected.day} ${hour}时 普通战果 ${tileNumber(value)}`, 'aria-pressed': slot === hour,
|
|
102
|
+
...stats.days.map(d => h('button', { key: d.day, className: 'tile', 'data-day': d.day, title: `${d.day} · ${tileNumber(d.normal)}`,
|
|
103
|
+
'aria-label': `${d.day} · ${t('normal')} ${tileNumber(d.normal)}`, style: tileStyle(d.normal, maxDay), onClick: () => openDay(d.day) },
|
|
104
|
+
h('span', { className: 'tile-label' }, Number(d.day.slice(-2))), h('span', { className: 'tile-value' }, tileNumber(d.normal))))))) :
|
|
105
|
+
h('section', { className: 'section' }, h('h3', { className: 'section-head' }, t('hourly')),
|
|
106
|
+
h('div', { className: 'hours', 'aria-label': t('hourly') }, ...selected.slots.map((value, hour) => h('button', { key: hour, className: 'tile', 'data-hour': hour,
|
|
107
|
+
title: `${String(hour).padStart(2, '0')}:00 · ${tileNumber(value)}`, 'aria-label': `${selected.day} ${hour}:00 · ${tileNumber(value)}`, 'aria-pressed': slot === hour,
|
|
81
108
|
style: tileStyle(value, maxHour), onClick: () => setSlot(slot === hour ? null : hour) },
|
|
82
|
-
h('span', { className: 'tile-label' }, `${String(hour).padStart(2, '0')}:00`), h('span', { className: 'tile-value' }, tileNumber(value))))),
|
|
83
|
-
h('div', { className: 'top section section-head' }, h('h3', null, slot === null ? '
|
|
84
|
-
slot !== null && h('button', { onClick: () => setSlot(null) }, '
|
|
85
|
-
h('div', { className: 'scroll' }, h('table', { 'aria-label': '
|
|
86
|
-
h('tbody', null, ...timeline.slice(0, 300).map(e => h('tr', { key: e.id }, h('td', null, formatTime(e.at, zone).slice(11)), h('td', null, e.exp.toLocaleString()), h('td', null, fmt(e.amount)), h('td', null, e
|
|
87
|
-
!timeline.length && h('tr', null, h('td', { colSpan: 4, className: 'empty' }, '
|
|
88
|
-
timeline.length > 300 && h('p', { className: 'muted' },
|
|
89
|
-
h('section', { className: 'section' }, h('h3', { className: 'section-head' }, '
|
|
90
|
-
h('div', { className: 'scroll' }, h('table', { 'aria-label': '
|
|
91
|
-
...unknown.slice(0, 200).map(e => h('tr', { key: e.id }, h('td', null,
|
|
92
|
-
!unknown.length && h('tr', null, h('td', { colSpan: 3, className: 'empty' }, '
|
|
93
|
-
unknown.length > 200 && h('p', { className: 'muted' },
|
|
94
|
-
h('div', { className: 'foot' }, 'v0.
|
|
109
|
+
h('span', { className: 'tile-label' }, `${String(hour).padStart(2, '0')}:00`), h('span', { className: 'tile-value' }, tileNumber(value))))),
|
|
110
|
+
h('div', { className: 'top section section-head' }, h('h3', null, slot === null ? t('dayDetail') : t('hourDetail', { hour: `${String(slot).padStart(2, '0')}:00–${String(slot + 1).padStart(2, '0')}:00` })),
|
|
111
|
+
slot !== null && h('button', { onClick: () => setSlot(null), 'data-action': 'all' }, t('viewAll'))),
|
|
112
|
+
h('div', { className: 'scroll' }, h('table', { className: 'details-table', 'data-table': 'details', 'aria-label': t('dayDetail') }, th(['time', 'experience', 'senka', 'map']),
|
|
113
|
+
h('tbody', null, ...timeline.slice(0, 300).map(e => h('tr', { key: e.id }, h('td', null, formatTime(e.at, zone).slice(11)), h('td', null, e.exp.toLocaleString(language)), h('td', null, fmt(e.amount)), h('td', null, battleText(e, t)))),
|
|
114
|
+
!timeline.length && h('tr', null, h('td', { colSpan: 4, className: 'empty' }, t('empty')))))),
|
|
115
|
+
timeline.length > 300 && h('p', { className: 'muted' }, t('shown', { count: timeline.length, limit: 300 }))),
|
|
116
|
+
h('section', { className: 'section' }, h('h3', { className: 'section-head' }, t('unknown')),
|
|
117
|
+
h('div', { className: 'scroll' }, h('table', { className: 'unknown-table', 'data-table': 'unknown', 'aria-label': t('unknown') }, th(['interval', 'detected', 'senka']), h('tbody', null,
|
|
118
|
+
...unknown.slice(0, 200).map(e => h('tr', { key: e.id }, h('td', null, stamp(e.from), '→', stamp(e.to)), h('td', null, stamp(e.at)), h('td', { className: 'amber' }, fmt(e.amount)))),
|
|
119
|
+
!unknown.length && h('tr', null, h('td', { colSpan: 3, className: 'empty' }, t('empty')))))),
|
|
120
|
+
unknown.length > 200 && h('p', { className: 'muted' }, t('shown', { count: unknown.length, limit: 200 }))),
|
|
121
|
+
h('div', { className: 'foot' }, 'v0.2.0')))
|
|
95
122
|
}
|
|
96
123
|
}
|
|
97
124
|
module.exports = { createPanel }
|