textbrowser 0.50.0 → 0.51.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/.ncurc.cjs +3 -0
- package/CHANGES.md +8 -0
- package/dist/WorkInfo-es.js +361 -111
- package/dist/activateCallback-es.js +72 -10
- package/dist/dist/WorkInfo-es.d.ts +331 -0
- package/dist/dist/WorkInfo-es.d.ts.map +1 -0
- package/dist/dist/activateCallback-es.d.ts +17 -0
- package/dist/dist/activateCallback-es.d.ts.map +1 -0
- package/dist/dist/index-es.d.ts +619 -0
- package/dist/dist/index-es.d.ts.map +1 -0
- package/dist/dist/sw-helper.d.ts +3 -0
- package/dist/dist/sw-helper.d.ts.map +1 -0
- package/dist/eslint.config.d.ts +126 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/index-es.js +959 -195
- package/dist/index-es.min.js +2 -2
- package/dist/resources/activateCallback.d.ts +23 -0
- package/dist/resources/activateCallback.d.ts.map +1 -0
- package/dist/resources/index.d.ts +128 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/resultsDisplay.d.ts +110 -0
- package/dist/resources/resultsDisplay.d.ts.map +1 -0
- package/dist/resources/templates/index.d.ts +59 -0
- package/dist/resources/templates/index.d.ts.map +1 -0
- package/dist/resources/templates/languageSelect.d.ts +18 -0
- package/dist/resources/templates/languageSelect.d.ts.map +1 -0
- package/dist/resources/templates/resultsDisplayClient.d.ts +26 -0
- package/dist/resources/templates/resultsDisplayClient.d.ts.map +1 -0
- package/dist/resources/templates/resultsDisplayServerOrClient.d.ts +131 -0
- package/dist/resources/templates/resultsDisplayServerOrClient.d.ts.map +1 -0
- package/dist/resources/templates/utils/dom.d.ts +15 -0
- package/dist/resources/templates/utils/dom.d.ts.map +1 -0
- package/dist/resources/templates/utils/html.d.ts +3 -0
- package/dist/resources/templates/utils/html.d.ts.map +1 -0
- package/dist/resources/templates/workDisplay.d.ts +183 -0
- package/dist/resources/templates/workDisplay.d.ts.map +1 -0
- package/dist/resources/templates/workSelect.d.ts +18 -0
- package/dist/resources/templates/workSelect.d.ts.map +1 -0
- package/dist/resources/user-sample.d.ts +2 -0
- package/dist/resources/user-sample.d.ts.map +1 -0
- package/dist/resources/user.d.ts +2 -0
- package/dist/resources/user.d.ts.map +1 -0
- package/dist/resources/utils/IntlURLSearchParams.d.ts +56 -0
- package/dist/resources/utils/IntlURLSearchParams.d.ts.map +1 -0
- package/dist/resources/utils/Languages.d.ts +81 -0
- package/dist/resources/utils/Languages.d.ts.map +1 -0
- package/dist/resources/utils/Metadata.d.ts +133 -0
- package/dist/resources/utils/Metadata.d.ts.map +1 -0
- package/dist/resources/utils/Params.d.ts +30 -0
- package/dist/resources/utils/Params.d.ts.map +1 -0
- package/dist/resources/utils/Plugin.d.ts +274 -0
- package/dist/resources/utils/Plugin.d.ts.map +1 -0
- package/dist/resources/utils/ServiceWorker.d.ts +26 -0
- package/dist/resources/utils/ServiceWorker.d.ts.map +1 -0
- package/dist/resources/utils/WorkInfo.d.ts +104 -0
- package/dist/resources/utils/WorkInfo.d.ts.map +1 -0
- package/dist/resources/utils/dialogs.d.ts +155 -0
- package/dist/resources/utils/dialogs.d.ts.map +1 -0
- package/dist/resources/utils/getLocaleFallbackResults.d.ts +19 -0
- package/dist/resources/utils/getLocaleFallbackResults.d.ts.map +1 -0
- package/dist/resources/utils/sanitize.d.ts +6 -0
- package/dist/resources/utils/sanitize.d.ts.map +1 -0
- package/dist/resources/vendor/json-refs-min.d.ts +3 -0
- package/dist/resources/vendor/json-refs-min.d.ts.map +1 -0
- package/dist/resources/workDisplay.d.ts +81 -0
- package/dist/resources/workDisplay.d.ts.map +1 -0
- package/dist/resources/workSelect.d.ts +17 -0
- package/dist/resources/workSelect.d.ts.map +1 -0
- package/dist/rollup.config.d.ts +19 -0
- package/dist/rollup.config.d.ts.map +1 -0
- package/dist/server/main.d.ts +46 -0
- package/dist/server/main.d.ts.map +1 -0
- package/dist/sw-helper.d.ts +3 -0
- package/dist/sw-helper.d.ts.map +1 -0
- package/dist/sw-helper.js +52 -12
- package/dist/sw-sample.d.ts +2 -0
- package/dist/sw-sample.d.ts.map +1 -0
- package/general-schemas/files.jsonschema +6 -0
- package/package.json +21 -8
- package/resources/activateCallback.js +75 -10
- package/resources/index.js +161 -49
- package/resources/resultsDisplay.js +517 -152
- package/resources/templates/index.js +39 -16
- package/resources/templates/languageSelect.js +14 -1
- package/resources/templates/resultsDisplayClient.js +22 -3
- package/resources/templates/resultsDisplayServerOrClient.js +188 -49
- package/resources/templates/utils/dom.js +13 -2
- package/resources/templates/workDisplay.js +299 -75
- package/resources/templates/workSelect.js +16 -3
- package/resources/utils/IntlURLSearchParams.js +46 -4
- package/resources/utils/Languages.js +71 -4
- package/resources/utils/Metadata.js +219 -22
- package/resources/utils/Params.js +70 -23
- package/resources/utils/Plugin.js +169 -1
- package/resources/utils/ServiceWorker.js +48 -19
- package/resources/utils/WorkInfo.js +255 -43
- package/resources/utils/dialogs.js +105 -7
- package/resources/utils/getLocaleFallbackResults.js +12 -2
- package/resources/utils/sanitize.js +4 -0
- package/resources/workDisplay.js +151 -25
- package/resources/workSelect.js +37 -17
- package/server/main.js +111 -19
- package/tsconfig.json +30 -0
- package/resources/user.js +0 -20
|
@@ -2,24 +2,81 @@ import {jml, $, $$, nbsp} from 'jamilih';
|
|
|
2
2
|
import Templates from './index.js';
|
|
3
3
|
import {colors, fonts} from './utils/html.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @callback LOption
|
|
7
|
+
* @param {string[]} key
|
|
8
|
+
* @param {import('jamilih').JamilihAttributes} atts
|
|
9
|
+
* @returns {import('jamilih').JamilihArray}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {(info: {
|
|
14
|
+
* form: HTMLFormElement,
|
|
15
|
+
* random: {
|
|
16
|
+
* checked: boolean,
|
|
17
|
+
* },
|
|
18
|
+
* checkboxes: HTMLInputElement[],
|
|
19
|
+
* type: string,
|
|
20
|
+
* fieldAliasOrNames?: string[],
|
|
21
|
+
* workName: string
|
|
22
|
+
* }) => URLSearchParams} ParamsSetter
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {(cfg: {
|
|
27
|
+
* $: typeof $,
|
|
28
|
+
* l: import('intl-dom').I18NCallback,
|
|
29
|
+
* jml: typeof jml,
|
|
30
|
+
* paramsSetter: ParamsSetter,
|
|
31
|
+
* getDataForSerializingParamsAsURL: () => {
|
|
32
|
+
* form: HTMLFormElement,
|
|
33
|
+
* random: HTMLInputElement,
|
|
34
|
+
* checkboxes: HTMLInputElement[]
|
|
35
|
+
* },
|
|
36
|
+
* work: string,
|
|
37
|
+
* replaceHash: (paramsCopy: URLSearchParams) => string,
|
|
38
|
+
* getFieldAliasOrNames: import('../workDisplay.js').GetFieldAliasOrNames
|
|
39
|
+
* }) => import('jamilih').JamilihArray} PreferencesPlugin
|
|
40
|
+
*/
|
|
41
|
+
|
|
5
42
|
const nbsp2 = nbsp.repeat(2);
|
|
6
43
|
const nbsp3 = nbsp.repeat(3);
|
|
7
44
|
|
|
8
45
|
const getDataForSerializingParamsAsURL = () => ({
|
|
9
|
-
form: $('form#browse'),
|
|
46
|
+
form: /** @type {HTMLFormElement} */ ($('form#browse')),
|
|
10
47
|
// Todo: We don't need any default once random
|
|
11
48
|
// functionality is completed
|
|
12
|
-
random: $('#rand') || {},
|
|
13
|
-
checkboxes: $$('input[type=checkbox]')
|
|
49
|
+
random: /** @type {HTMLInputElement} */ ($('#rand')) || {checked: false},
|
|
50
|
+
checkboxes: /** @type {HTMLInputElement[]} */ ($$('input[type=checkbox]'))
|
|
14
51
|
});
|
|
15
52
|
|
|
16
53
|
export default {
|
|
54
|
+
/**
|
|
55
|
+
* @param {{
|
|
56
|
+
* fallbackDirection: "ltr"|"rtl",
|
|
57
|
+
* message: string
|
|
58
|
+
* }} cfg
|
|
59
|
+
* @returns {import('jamilih').JamilihArray}
|
|
60
|
+
*/
|
|
17
61
|
bdo ({fallbackDirection, message}) {
|
|
18
62
|
// Displaying as div with inline display instead of span since
|
|
19
63
|
// Firefox puts punctuation at left otherwise (bdo dir
|
|
20
64
|
// seemed to have issues in Firefox)
|
|
21
65
|
return ['div', {style: 'display: inline; direction: ' + fallbackDirection}, [message]];
|
|
22
66
|
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {{
|
|
70
|
+
* lDirectional: import('../workDisplay.js').LDirectional,
|
|
71
|
+
* fieldInfo: import('../utils/WorkInfo.js').FieldInfo,
|
|
72
|
+
* $p: import('../utils/IntlURLSearchParams.js').default,
|
|
73
|
+
* lElement: import('../workDisplay.js').LElement,
|
|
74
|
+
* lIndexedParam: (key: string) => string,
|
|
75
|
+
* l: import('intl-dom').I18NCallback,
|
|
76
|
+
* fieldMatchesLocale: (field: string) => boolean
|
|
77
|
+
* }} cfg
|
|
78
|
+
* @returns {import('jamilih').JamilihArray}
|
|
79
|
+
*/
|
|
23
80
|
columnsTable: ({
|
|
24
81
|
lDirectional, fieldInfo, $p, lElement, lIndexedParam, l,
|
|
25
82
|
// metadataObj, preferredLocale, schemaItems,
|
|
@@ -51,12 +108,12 @@ export default {
|
|
|
51
108
|
]]
|
|
52
109
|
*/
|
|
53
110
|
]],
|
|
54
|
-
...fieldInfo.map((fieldInfoItem, i) => {
|
|
111
|
+
...((fieldInfo.map((fieldInfoItem, i) => {
|
|
55
112
|
const idx = i + 1;
|
|
56
113
|
const checkedIndex = 'checked' + idx;
|
|
57
114
|
const fieldIndex = 'field' + idx;
|
|
58
115
|
const fieldParam = $p.get(fieldIndex);
|
|
59
|
-
return ['tr', [
|
|
116
|
+
return /** @type {import('jamilih').JamilihArray} */ (['tr', [
|
|
60
117
|
// Todo: Get Jamilih to accept numbers and
|
|
61
118
|
// booleans (`toString` is too dangerous)
|
|
62
119
|
['td', [String(idx)]],
|
|
@@ -77,14 +134,14 @@ export default {
|
|
|
77
134
|
size: '1'
|
|
78
135
|
}, fieldInfo.map(({field, fieldAliasOrName}, j) => {
|
|
79
136
|
const matchedFieldParam = fieldParam && fieldParam === fieldAliasOrName;
|
|
80
|
-
return ['option', {
|
|
137
|
+
return /** @type {import('jamilih').JamilihArray} */ (['option', {
|
|
81
138
|
dataset: {name: field},
|
|
82
139
|
value: fieldAliasOrName,
|
|
83
140
|
selected: (
|
|
84
141
|
matchedFieldParam ||
|
|
85
142
|
(j === i && !$p.has(fieldIndex))
|
|
86
143
|
)
|
|
87
|
-
}, [fieldAliasOrName]];
|
|
144
|
+
}, [fieldAliasOrName]]);
|
|
88
145
|
})]
|
|
89
146
|
]),
|
|
90
147
|
['td', [ // Todo: Make as tag selector with fields as options
|
|
@@ -102,15 +159,16 @@ export default {
|
|
|
102
159
|
['input', {name: lIndexedParam('search') + idx, value: $p.get('search' + idx)}]
|
|
103
160
|
]]
|
|
104
161
|
*/
|
|
105
|
-
]];
|
|
106
|
-
}),
|
|
162
|
+
]]);
|
|
163
|
+
}))),
|
|
107
164
|
['tr', [
|
|
108
165
|
['td', {colspan: 3}, [
|
|
109
166
|
lElement('check_all', 'input', 'value', {
|
|
110
167
|
type: 'button',
|
|
111
168
|
$on: {
|
|
112
169
|
click () {
|
|
113
|
-
|
|
170
|
+
/** @type {HTMLInputElement[]} */
|
|
171
|
+
($$('.fieldSelector')).forEach((checkbox) => {
|
|
114
172
|
checkbox.checked = true;
|
|
115
173
|
});
|
|
116
174
|
}
|
|
@@ -120,7 +178,8 @@ export default {
|
|
|
120
178
|
type: 'button',
|
|
121
179
|
$on: {
|
|
122
180
|
click () {
|
|
123
|
-
|
|
181
|
+
/** @type {HTMLInputElement[]} */
|
|
182
|
+
($$('.fieldSelector')).forEach((checkbox) => {
|
|
124
183
|
checkbox.checked = false;
|
|
125
184
|
});
|
|
126
185
|
}
|
|
@@ -134,8 +193,13 @@ export default {
|
|
|
134
193
|
const idx = i + 1;
|
|
135
194
|
// The following is redundant with 'field' but may need to
|
|
136
195
|
// retrieve later out of order?
|
|
137
|
-
const fld =
|
|
138
|
-
|
|
196
|
+
const fld = /** @type {string} */ (
|
|
197
|
+
/** @type {HTMLSelectElement} */ (
|
|
198
|
+
$('#field' + idx)
|
|
199
|
+
).selectedOptions[0].dataset.name
|
|
200
|
+
);
|
|
201
|
+
/** @type {HTMLInputElement} */
|
|
202
|
+
($('#checked' + idx)).checked = fieldMatchesLocale(fld);
|
|
139
203
|
});
|
|
140
204
|
}
|
|
141
205
|
}
|
|
@@ -143,17 +207,30 @@ export default {
|
|
|
143
207
|
]]
|
|
144
208
|
]]
|
|
145
209
|
]],
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @param {{
|
|
213
|
+
* lDirectional: import('../workDisplay.js').LDirectional,
|
|
214
|
+
* lParam: (key: string) => string,
|
|
215
|
+
* l: import('intl-dom').I18NCallback,
|
|
216
|
+
* lOption: LOption,
|
|
217
|
+
* lElement: import('../workDisplay.js').LElement,
|
|
218
|
+
* $p: import('../utils/IntlURLSearchParams.js').default,
|
|
219
|
+
* hideFormattingSection: boolean
|
|
220
|
+
* }} cfg
|
|
221
|
+
* @returns {import('jamilih').JamilihArray}
|
|
222
|
+
*/
|
|
146
223
|
advancedFormatting: ({lDirectional, lParam, l, lOption, lElement, $p, hideFormattingSection}) => ['td', {
|
|
147
224
|
id: 'advancedformatting', style: {display: (hideFormattingSection ? 'none' : 'block')}
|
|
148
|
-
}, [
|
|
225
|
+
}, /** @type {import('jamilih').JamilihChildren} */ ([
|
|
149
226
|
['h3', [lDirectional('advancedformatting')]],
|
|
150
227
|
['label', [
|
|
151
228
|
lDirectional('textcolor'), nbsp2,
|
|
152
229
|
['select', {name: lParam('colorName')}, colors.map((color, i) => {
|
|
153
|
-
const atts = {
|
|
230
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
154
231
|
value: l(['param_values', 'colors', color]),
|
|
155
232
|
selected: null
|
|
156
|
-
};
|
|
233
|
+
});
|
|
157
234
|
if ($p.get('colorName') === l(['param_values', 'colors', color]) ||
|
|
158
235
|
(i === 1 && !$p.has('colorName'))) {
|
|
159
236
|
atts.selected = 'selected';
|
|
@@ -174,10 +251,10 @@ export default {
|
|
|
174
251
|
['label', [
|
|
175
252
|
lDirectional('backgroundcolor'), nbsp2,
|
|
176
253
|
['select', {name: lParam('bgcolorName')}, colors.map((color, i) => {
|
|
177
|
-
const atts = {
|
|
254
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
178
255
|
value: l(['param_values', 'colors', color]),
|
|
179
256
|
selected: null
|
|
180
|
-
};
|
|
257
|
+
});
|
|
181
258
|
if ($p.get('bgcolorName') === l(['param_values', 'colors', color]) ||
|
|
182
259
|
(i === 14 && !$p.has('bgcolorName'))) {
|
|
183
260
|
atts.selected = 'selected';
|
|
@@ -199,10 +276,10 @@ export default {
|
|
|
199
276
|
lDirectional('text_font'), nbsp2,
|
|
200
277
|
// Todo: remove hard-coded direction if i81nizing; also i18nize fontSeq param
|
|
201
278
|
['select', {name: lParam('fontSeq'), dir: 'ltr'}, fonts.map((fontSeq, i) => {
|
|
202
|
-
const atts = {
|
|
279
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
203
280
|
value: fontSeq,
|
|
204
281
|
selected: null
|
|
205
|
-
};
|
|
282
|
+
});
|
|
206
283
|
if ($p.get('fontSeq') === fontSeq || (i === 7 && !$p.has('fontSeq'))) {
|
|
207
284
|
atts.selected = 'selected';
|
|
208
285
|
}
|
|
@@ -217,10 +294,10 @@ export default {
|
|
|
217
294
|
'normal',
|
|
218
295
|
'oblique'
|
|
219
296
|
].map((fontstyle, i) => {
|
|
220
|
-
const atts = {
|
|
297
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
221
298
|
value: l(['param_values', 'fontstyle', fontstyle]),
|
|
222
299
|
selected: null
|
|
223
|
-
};
|
|
300
|
+
});
|
|
224
301
|
if ($p.get('fontstyle') === l(['param_values', 'fontstyle', fontstyle]) ||
|
|
225
302
|
(i === 1 && !$p.has('fontstyle'))) {
|
|
226
303
|
atts.selected = 'selected';
|
|
@@ -284,10 +361,10 @@ export default {
|
|
|
284
361
|
'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed',
|
|
285
362
|
'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'
|
|
286
363
|
].map((stretch) => {
|
|
287
|
-
const atts = {
|
|
364
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
288
365
|
value: lDirectional(['param_values', 'font-stretch', stretch]),
|
|
289
366
|
selected: null
|
|
290
|
-
};
|
|
367
|
+
});
|
|
291
368
|
if ($p.get('fontstretch') === stretch ||
|
|
292
369
|
(!$p.has('fontstretch') && stretch === 'normal')) {
|
|
293
370
|
atts.selected = 'selected';
|
|
@@ -323,9 +400,9 @@ export default {
|
|
|
323
400
|
['div', [
|
|
324
401
|
lDirectional('header_wstyles'), nbsp2,
|
|
325
402
|
...([
|
|
326
|
-
['yes', lDirectional(['param_values', 'y'])],
|
|
327
|
-
['no', lDirectional(['param_values', 'n'])],
|
|
328
|
-
['none', lDirectional(['param_values', '0'])]
|
|
403
|
+
['yes', /** @type {string} */ (lDirectional(['param_values', 'y']))],
|
|
404
|
+
['no', /** @type {string} */ (lDirectional(['param_values', 'n']))],
|
|
405
|
+
['none', /** @type {string} */ (lDirectional(['param_values', '0']))]
|
|
329
406
|
].map(([key, val], i, arr) => {
|
|
330
407
|
return ['label', [
|
|
331
408
|
['input', {
|
|
@@ -342,9 +419,9 @@ export default {
|
|
|
342
419
|
['div', [
|
|
343
420
|
lDirectional('footer_wstyles'), nbsp2,
|
|
344
421
|
...([
|
|
345
|
-
['yes', lDirectional(['param_values', 'y'])],
|
|
346
|
-
['no', lDirectional(['param_values', 'n'])],
|
|
347
|
-
['none', lDirectional(['param_values', '0'])]
|
|
422
|
+
['yes', /** @type {string} */ (lDirectional(['param_values', 'y']))],
|
|
423
|
+
['no', /** @type {string} */ (lDirectional(['param_values', 'n']))],
|
|
424
|
+
['none', /** @type {string} */ (lDirectional(['param_values', '0']))]
|
|
348
425
|
].map(([key, val], i, arr) => {
|
|
349
426
|
return ['label', [
|
|
350
427
|
['input', {
|
|
@@ -371,9 +448,9 @@ export default {
|
|
|
371
448
|
['div', [
|
|
372
449
|
lDirectional('caption_wstyles'), nbsp2,
|
|
373
450
|
...([
|
|
374
|
-
['yes', lDirectional(['param_values', 'y'])],
|
|
375
|
-
['no', lDirectional(['param_values', 'n'])],
|
|
376
|
-
['none', lDirectional(['param_values', '0'])]
|
|
451
|
+
['yes', /** @type {string} */ (lDirectional(['param_values', 'y']))],
|
|
452
|
+
['no', /** @type {string} */ (lDirectional(['param_values', 'n']))],
|
|
453
|
+
['none', /** @type {string} */ (lDirectional(['param_values', '0']))]
|
|
377
454
|
].map(([key, val], i, arr) => {
|
|
378
455
|
return ['label', [
|
|
379
456
|
['input', {
|
|
@@ -497,27 +574,43 @@ export default {
|
|
|
497
574
|
// , 'json-array',
|
|
498
575
|
// 'json-object'
|
|
499
576
|
].map((mode) => {
|
|
500
|
-
const atts = {
|
|
577
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
501
578
|
value: mode,
|
|
502
579
|
selected: null
|
|
503
|
-
};
|
|
580
|
+
});
|
|
504
581
|
if ($p.get('outputmode') === mode) {
|
|
505
582
|
atts.selected = 'selected';
|
|
506
583
|
}
|
|
507
584
|
return lOption(['param_values', 'outputmode', mode], atts);
|
|
508
585
|
})]
|
|
509
586
|
])
|
|
510
|
-
]],
|
|
587
|
+
])],
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* @param {{
|
|
591
|
+
* lParam: (key: string) => string,
|
|
592
|
+
* lDirectional: import('../workDisplay.js').LDirectional,
|
|
593
|
+
* l: import('intl-dom').I18NCallback,
|
|
594
|
+
* lElement: import('../workDisplay.js').LElement,
|
|
595
|
+
* $p: import('../utils/IntlURLSearchParams.js').default,
|
|
596
|
+
* serializeParamsAsURL: import('../workDisplay.js').SerializeParamsAsURL,
|
|
597
|
+
* content: import('jamilih').JamilihArray[]
|
|
598
|
+
* }} cfg
|
|
599
|
+
* @returns {void}
|
|
600
|
+
*/
|
|
511
601
|
addRandomFormFields ({
|
|
512
602
|
lParam, lDirectional, l, lElement, $p, serializeParamsAsURL, content
|
|
513
603
|
}) {
|
|
604
|
+
/**
|
|
605
|
+
* @param {import('jamilih').JamilihChildren} rowContent
|
|
606
|
+
*/
|
|
514
607
|
const addRowContent = (rowContent) => {
|
|
515
608
|
if (!rowContent || !rowContent.length) {
|
|
516
609
|
return;
|
|
517
610
|
}
|
|
518
611
|
content.push(['tr', rowContent]);
|
|
519
612
|
};
|
|
520
|
-
[
|
|
613
|
+
/** @type {import('jamilih').JamilihChildren[]} */ ([
|
|
521
614
|
[
|
|
522
615
|
['td', {colspan: 12, align: 'center'}, [['br'], lDirectional('or'), ['br'], ['br']]]
|
|
523
616
|
],
|
|
@@ -554,15 +647,33 @@ export default {
|
|
|
554
647
|
...getDataForSerializingParamsAsURL(),
|
|
555
648
|
type: 'randomResult'
|
|
556
649
|
});
|
|
557
|
-
|
|
650
|
+
/** @type {HTMLInputElement} */
|
|
651
|
+
($('#randomURL')).value = url;
|
|
558
652
|
}
|
|
559
653
|
}
|
|
560
654
|
}),
|
|
561
655
|
['input', {id: 'randomURL', type: 'text'}]
|
|
562
656
|
]]
|
|
563
657
|
]
|
|
564
|
-
].forEach(addRowContent);
|
|
658
|
+
]).forEach(addRowContent);
|
|
565
659
|
},
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* @param {{
|
|
663
|
+
* paramsSetter: ParamsSetter,
|
|
664
|
+
* replaceHash: (paramsCopy: URLSearchParams) => string,
|
|
665
|
+
* getFieldAliasOrNames: import('../workDisplay.js').GetFieldAliasOrNames,
|
|
666
|
+
* work: string,
|
|
667
|
+
* langs: import('../../server/main.js').LanguageInfo[],
|
|
668
|
+
* languageI18n: (code: string) => string,
|
|
669
|
+
* l: import('intl-dom').I18NCallback,
|
|
670
|
+
* localizeParamNames: boolean,
|
|
671
|
+
* namespace: string,
|
|
672
|
+
* hideFormattingSection: boolean,
|
|
673
|
+
* preferencesPlugin?: PreferencesPlugin
|
|
674
|
+
* }} cfg
|
|
675
|
+
* @returns {import('jamilih').JamilihArray}
|
|
676
|
+
*/
|
|
566
677
|
getPreferences: ({
|
|
567
678
|
// languageParam, workI18n, groups,
|
|
568
679
|
paramsSetter, replaceHash,
|
|
@@ -579,9 +690,11 @@ export default {
|
|
|
579
690
|
id: 'localizeParamNames',
|
|
580
691
|
type: 'checkbox',
|
|
581
692
|
checked: localizeParamNames,
|
|
582
|
-
$on: {change (
|
|
693
|
+
$on: {change (e) {
|
|
694
|
+
// eslint-disable-next-line prefer-destructuring -- TS
|
|
695
|
+
const checked = /** @type {HTMLInputElement} */ (e.target).checked;
|
|
583
696
|
localStorage.setItem(
|
|
584
|
-
namespace + '-localizeParamNames', checked
|
|
697
|
+
namespace + '-localizeParamNames', String(checked)
|
|
585
698
|
);
|
|
586
699
|
}}
|
|
587
700
|
}]
|
|
@@ -594,11 +707,14 @@ export default {
|
|
|
594
707
|
id: 'hideFormattingSection',
|
|
595
708
|
type: 'checkbox',
|
|
596
709
|
checked: hideFormattingSection,
|
|
597
|
-
$on: {change (
|
|
598
|
-
|
|
710
|
+
$on: {change (e) {
|
|
711
|
+
// eslint-disable-next-line prefer-destructuring -- TS
|
|
712
|
+
const checked = /** @type {HTMLInputElement} */ (e.target).checked;
|
|
713
|
+
/** @type {HTMLElement} */
|
|
714
|
+
($('#advancedformatting')).style.display = checked
|
|
599
715
|
? 'none'
|
|
600
716
|
: 'block';
|
|
601
|
-
localStorage.setItem(namespace + '-hideFormattingSection', checked);
|
|
717
|
+
localStorage.setItem(namespace + '-hideFormattingSection', String(checked));
|
|
602
718
|
}}
|
|
603
719
|
}]
|
|
604
720
|
]]
|
|
@@ -611,7 +727,11 @@ export default {
|
|
|
611
727
|
multiple: 'multiple',
|
|
612
728
|
size: langs.length,
|
|
613
729
|
$on: {
|
|
614
|
-
change (
|
|
730
|
+
change (e) {
|
|
731
|
+
// eslint-disable-next-line prefer-destructuring -- TS
|
|
732
|
+
const selectedOptions = /** @type {HTMLSelectElement} */ (
|
|
733
|
+
e.target
|
|
734
|
+
).selectedOptions;
|
|
615
735
|
// Todo: EU disclaimer re: storage?
|
|
616
736
|
localStorage.setItem(namespace + '-langCodes', JSON.stringify(
|
|
617
737
|
[...selectedOptions].map((opt) => {
|
|
@@ -623,10 +743,10 @@ export default {
|
|
|
623
743
|
}, langs.map((lan) => {
|
|
624
744
|
let langCodes = localStorage.getItem(namespace + '-langCodes');
|
|
625
745
|
langCodes = langCodes && JSON.parse(langCodes);
|
|
626
|
-
const atts = {
|
|
746
|
+
const atts = /** @type {import('jamilih').JamilihAttributes} */ ({
|
|
627
747
|
value: lan.code,
|
|
628
748
|
selected: null
|
|
629
|
-
};
|
|
749
|
+
});
|
|
630
750
|
if (langCodes && langCodes.includes(lan.code)) {
|
|
631
751
|
atts.selected = 'selected';
|
|
632
752
|
}
|
|
@@ -643,15 +763,33 @@ export default {
|
|
|
643
763
|
: ''
|
|
644
764
|
)
|
|
645
765
|
]],
|
|
766
|
+
/**
|
|
767
|
+
* @param {{
|
|
768
|
+
* browseFields: import('../utils/Metadata.js').BrowseFields,
|
|
769
|
+
* fieldInfo: import('../utils/WorkInfo.js').FieldInfo,
|
|
770
|
+
* i: number,
|
|
771
|
+
* lDirectional: (
|
|
772
|
+
* key: string|string[],
|
|
773
|
+
* substitutions?: Record<string, string>
|
|
774
|
+
* ) => string|Text|DocumentFragment,
|
|
775
|
+
* lIndexedParam: (key: string) => string,
|
|
776
|
+
* $p: import('../utils/IntlURLSearchParams.js').default,
|
|
777
|
+
* content: import('jamilih').JamilihArray[]
|
|
778
|
+
* }} cfg
|
|
779
|
+
* @returns {void}
|
|
780
|
+
*/
|
|
646
781
|
addBrowseFields ({browseFields, fieldInfo, lDirectional, i, lIndexedParam, $p, content}) {
|
|
647
782
|
const work = $p.get('work');
|
|
783
|
+
/**
|
|
784
|
+
* @param {import('jamilih').JamilihChildren} rowContent
|
|
785
|
+
*/
|
|
648
786
|
const addRowContent = (rowContent) => {
|
|
649
787
|
if (!rowContent || !rowContent.length) {
|
|
650
788
|
return;
|
|
651
789
|
}
|
|
652
790
|
content.push(['tr', rowContent]);
|
|
653
791
|
};
|
|
654
|
-
[
|
|
792
|
+
/** @type {import('jamilih').JamilihChildren[]} */ ([
|
|
655
793
|
// Todo: Separate formatting to CSS
|
|
656
794
|
i > 0
|
|
657
795
|
? [
|
|
@@ -660,6 +798,9 @@ export default {
|
|
|
660
798
|
: '',
|
|
661
799
|
[
|
|
662
800
|
...(() => {
|
|
801
|
+
/**
|
|
802
|
+
* @param {"start"|"end"} setType
|
|
803
|
+
*/
|
|
663
804
|
const addBrowseFieldSet = (setType) => {
|
|
664
805
|
return browseFields.reduce((rowContent, {
|
|
665
806
|
fieldName, aliases, fieldSchema: {minimum, maximum}
|
|
@@ -683,15 +824,23 @@ export default {
|
|
|
683
824
|
list: 'dl-' + id,
|
|
684
825
|
value: $p.get(name, true),
|
|
685
826
|
$on: setType === 'start'
|
|
686
|
-
? {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
827
|
+
? {
|
|
828
|
+
/**
|
|
829
|
+
* @param {Event} e
|
|
830
|
+
*/
|
|
831
|
+
change (e) {
|
|
832
|
+
/** @type {HTMLInputElement[]} */
|
|
833
|
+
($$('input.browseField')).forEach((bf) => {
|
|
834
|
+
if (bf.id.includes((i + 1) + '-' +
|
|
835
|
+
(j + 1))
|
|
836
|
+
) {
|
|
837
|
+
bf.value = /** @type {HTMLInputElement} */ (
|
|
838
|
+
e.target
|
|
839
|
+
).value;
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
}
|
|
695
844
|
: undefined
|
|
696
845
|
}]
|
|
697
846
|
: ['input', {
|
|
@@ -705,7 +854,7 @@ export default {
|
|
|
705
854
|
]]
|
|
706
855
|
);
|
|
707
856
|
return rowContent;
|
|
708
|
-
}, {'#': []});
|
|
857
|
+
}, {'#': /** @type {import('jamilih').JamilihChildren} */ ([])});
|
|
709
858
|
};
|
|
710
859
|
return [
|
|
711
860
|
addBrowseFieldSet('start'),
|
|
@@ -759,11 +908,11 @@ export default {
|
|
|
759
908
|
]]
|
|
760
909
|
);
|
|
761
910
|
return rowContent;
|
|
762
|
-
}, {'#': [
|
|
911
|
+
}, {'#': /** @type {import('jamilih').JamilihChildren} */ ([
|
|
763
912
|
['td', {style: 'font-weight: bold; vertical-align: bottom;'}, [
|
|
764
913
|
lDirectional('anchored-at') + nbsp3
|
|
765
914
|
]]
|
|
766
|
-
]}),
|
|
915
|
+
])}),
|
|
767
916
|
['td', [
|
|
768
917
|
['label', [
|
|
769
918
|
lDirectional('field') + nbsp2,
|
|
@@ -783,24 +932,73 @@ export default {
|
|
|
783
932
|
]]
|
|
784
933
|
]]
|
|
785
934
|
]
|
|
786
|
-
].forEach(addRowContent);
|
|
935
|
+
]).forEach(addRowContent);
|
|
787
936
|
},
|
|
937
|
+
/**
|
|
938
|
+
* @param {{
|
|
939
|
+
* workI18n: import('intl-dom').I18NCallback,
|
|
940
|
+
* languageParam: string,
|
|
941
|
+
* l: import('intl-dom').I18NCallback,
|
|
942
|
+
* namespace: string,
|
|
943
|
+
* heading: string,
|
|
944
|
+
* languageI18n: (code: string) => string,
|
|
945
|
+
* langs: import('../../server/main.js').LanguageInfo[],
|
|
946
|
+
* fieldInfo: import('../utils/WorkInfo.js').FieldInfo,
|
|
947
|
+
* localizeParamNames: boolean,
|
|
948
|
+
* serializeParamsAsURL: import('../workDisplay.js').SerializeParamsAsURL,
|
|
949
|
+
* paramsSetter: ParamsSetter,
|
|
950
|
+
* replaceHash: (paramsCopy: URLSearchParams) => string,
|
|
951
|
+
* getFieldAliasOrNames: import('../workDisplay.js').GetFieldAliasOrNames,
|
|
952
|
+
* hideFormattingSection: boolean,
|
|
953
|
+
* $p: import('../utils/IntlURLSearchParams.js').default,
|
|
954
|
+
* metadataObj: import('../utils/Metadata.js').MetadataObj,
|
|
955
|
+
* lParam: (key: string) => string,
|
|
956
|
+
* lElement: import('../workDisplay.js').LElement,
|
|
957
|
+
* lDirectional: import('../workDisplay.js').LDirectional,
|
|
958
|
+
* lIndexedParam: (key: string) => string,
|
|
959
|
+
* fieldMatchesLocale: (field: string) => boolean,
|
|
960
|
+
* preferredLocale: string,
|
|
961
|
+
* schemaItems: {
|
|
962
|
+
* title: string,
|
|
963
|
+
* type: string
|
|
964
|
+
* }[],
|
|
965
|
+
* content: import('jamilih').JamilihArray[],
|
|
966
|
+
* groups: import('../utils/WorkInfo.js').FileGroup[],
|
|
967
|
+
* preferencesPlugin?: PreferencesPlugin
|
|
968
|
+
* }} cfg
|
|
969
|
+
* @returns {void}
|
|
970
|
+
*/
|
|
788
971
|
main ({
|
|
789
|
-
workI18n,
|
|
972
|
+
// workI18n,
|
|
973
|
+
// languageParam,
|
|
790
974
|
l, namespace, heading, // fallbackDirection,
|
|
791
975
|
languageI18n, langs, fieldInfo, localizeParamNames,
|
|
792
976
|
serializeParamsAsURL, paramsSetter, replaceHash,
|
|
793
977
|
getFieldAliasOrNames,
|
|
794
978
|
hideFormattingSection, $p,
|
|
795
|
-
metadataObj,
|
|
796
|
-
|
|
979
|
+
// metadataObj,
|
|
980
|
+
lParam, lElement, lDirectional, lIndexedParam, fieldMatchesLocale,
|
|
981
|
+
// preferredLocale,
|
|
982
|
+
// schemaItems,
|
|
983
|
+
content,
|
|
984
|
+
// groups,
|
|
985
|
+
preferencesPlugin
|
|
797
986
|
}) {
|
|
798
987
|
const work = $p.get('work');
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @param {{
|
|
991
|
+
* type: string
|
|
992
|
+
* }} cfg
|
|
993
|
+
* @returns {string}
|
|
994
|
+
*/
|
|
799
995
|
const serializeParamsAsURLWithData = ({type}) => {
|
|
800
996
|
return serializeParamsAsURL(
|
|
801
997
|
{...getDataForSerializingParamsAsURL(), type}
|
|
802
998
|
);
|
|
803
999
|
};
|
|
1000
|
+
|
|
1001
|
+
/** @type {LOption} */
|
|
804
1002
|
const lOption = (key, atts) => {
|
|
805
1003
|
return ['option', atts, [
|
|
806
1004
|
l(
|
|
@@ -821,14 +1019,22 @@ export default {
|
|
|
821
1019
|
[
|
|
822
1020
|
['div', {style: 'float: left;'}, [
|
|
823
1021
|
['button', {$on: {click () {
|
|
824
|
-
const prefs = $('#preferences');
|
|
1022
|
+
const prefs = /** @type {HTMLElement} */ ($('#preferences'));
|
|
825
1023
|
prefs.hidden = !prefs.hidden;
|
|
826
1024
|
}}}, [l('Preferences')]],
|
|
827
1025
|
Templates.workDisplay.getPreferences({
|
|
828
|
-
languageParam,
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1026
|
+
// languageParam,
|
|
1027
|
+
// workI18n,
|
|
1028
|
+
paramsSetter, replaceHash,
|
|
1029
|
+
getFieldAliasOrNames,
|
|
1030
|
+
// eslint-disable-next-line object-shorthand -- TS
|
|
1031
|
+
work: /** @type {string} */ (work),
|
|
1032
|
+
langs,
|
|
1033
|
+
languageI18n,
|
|
1034
|
+
l, localizeParamNames, namespace,
|
|
1035
|
+
// groups,
|
|
1036
|
+
hideFormattingSection,
|
|
1037
|
+
preferencesPlugin
|
|
832
1038
|
})
|
|
833
1039
|
]],
|
|
834
1040
|
['h2', [heading]],
|
|
@@ -847,17 +1053,32 @@ export default {
|
|
|
847
1053
|
location.href = newURL;
|
|
848
1054
|
}
|
|
849
1055
|
}, $on: {
|
|
850
|
-
keydown (
|
|
1056
|
+
keydown (e) {
|
|
1057
|
+
const {target} = e;
|
|
1058
|
+
// eslint-disable-next-line prefer-destructuring -- TS
|
|
1059
|
+
const key = /** @type {KeyboardEvent & {target: HTMLElement}} */ (
|
|
1060
|
+
e
|
|
1061
|
+
).key;
|
|
851
1062
|
// Chrome is not having submit event triggered now with enter key
|
|
852
1063
|
// presses on inputs, despite having a `type=submit` input in the
|
|
853
1064
|
// form, and despite not using `preventDefault`
|
|
854
1065
|
if (key === 'Enter' && target.localName.toLowerCase() !== 'textarea') {
|
|
855
|
-
|
|
1066
|
+
/**
|
|
1067
|
+
* @type {HTMLFormElement & {
|
|
1068
|
+
* $submit: () => void
|
|
1069
|
+
* }}
|
|
1070
|
+
*/
|
|
1071
|
+
(this).$submit();
|
|
856
1072
|
}
|
|
857
1073
|
},
|
|
858
1074
|
submit (e) {
|
|
859
1075
|
e.preventDefault();
|
|
860
|
-
|
|
1076
|
+
/**
|
|
1077
|
+
* @type {HTMLFormElement & {
|
|
1078
|
+
* $submit: () => void
|
|
1079
|
+
* }}
|
|
1080
|
+
*/
|
|
1081
|
+
(this).$submit();
|
|
861
1082
|
}
|
|
862
1083
|
}, name: lParam('browse')}, [
|
|
863
1084
|
['table', {align: 'center'}, content],
|
|
@@ -869,7 +1090,9 @@ export default {
|
|
|
869
1090
|
['td', [
|
|
870
1091
|
Templates.workDisplay.columnsTable({
|
|
871
1092
|
lDirectional, fieldInfo, $p, lElement, lIndexedParam, l,
|
|
872
|
-
metadataObj,
|
|
1093
|
+
// metadataObj,
|
|
1094
|
+
// preferredLocale,
|
|
1095
|
+
// schemaItems,
|
|
873
1096
|
fieldMatchesLocale
|
|
874
1097
|
}),
|
|
875
1098
|
lElement('save-settings-URL', 'input', 'value', {
|
|
@@ -879,7 +1102,8 @@ export default {
|
|
|
879
1102
|
const url = serializeParamsAsURLWithData({
|
|
880
1103
|
type: 'saveSettings'
|
|
881
1104
|
});
|
|
882
|
-
|
|
1105
|
+
/** @type {HTMLInputElement} */
|
|
1106
|
+
($('#settings-URL')).value = url;
|
|
883
1107
|
}
|
|
884
1108
|
}
|
|
885
1109
|
}),
|
|
@@ -891,7 +1115,7 @@ export default {
|
|
|
891
1115
|
e.preventDefault();
|
|
892
1116
|
const paramsCopy = paramsSetter({
|
|
893
1117
|
...getDataForSerializingParamsAsURL(),
|
|
894
|
-
workName: work, // Delete work of current page
|
|
1118
|
+
workName: /** @type {string} */ (work), // Delete work of current page
|
|
895
1119
|
type: 'startEndResult'
|
|
896
1120
|
});
|
|
897
1121
|
const url = replaceHash(paramsCopy) + `&work=${work}&${work}-startEnd1=%s`; // %s will be escaped if set as param; also add changeable workName here
|