textbrowser 0.48.2 → 0.49.1
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/.babelrc.json +2 -7
- package/.ncurc.cjs +6 -0
- package/CHANGES.md +9 -0
- package/dist/WorkInfo-es.js +107 -143
- package/dist/activateCallback-es.js +1 -1
- package/dist/assets/index-D_XVedS3.css +9 -0
- package/dist/assets/languages-DWwAAJMo.json +67 -0
- package/dist/index-es.js +1538 -1454
- package/dist/index-es.min.js +4 -4
- package/dist/sw-helper.js +1 -0
- package/eslint.config.js +69 -0
- package/package.json +23 -41
- package/resources/activateCallback.js +1 -1
- package/resources/index.js +1 -13
- package/resources/resultsDisplay.js +7 -3
- package/resources/templates/index.js +1 -1
- package/resources/templates/languageSelect.js +0 -1
- package/resources/templates/resultsDisplayServerOrClient.js +3 -2
- package/resources/templates/workDisplay.js +1 -1
- package/resources/templates/workSelect.js +3 -2
- package/resources/utils/Languages.js +0 -1
- package/resources/utils/Metadata.js +4 -3
- package/resources/utils/Params.js +0 -1
- package/resources/utils/Plugin.js +3 -4
- package/resources/utils/ServiceWorker.js +2 -1
- package/resources/utils/WorkInfo.js +2 -1
- package/resources/workDisplay.js +0 -1
- package/resources/workSelect.js +0 -1
- package/server/main.js +8 -6
- package/.eslintignore +0 -4
- package/.eslintrc.cjs +0 -108
- package/.ncurc.js +0 -8
package/dist/index-es.js
CHANGED
|
@@ -1,99 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
14
|
-
r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) {
|
|
15
|
-
_defineProperty$1(e, r, t[r]);
|
|
16
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) {
|
|
17
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return e;
|
|
21
|
-
}
|
|
22
|
-
function _defineProperty$1(obj, key, value) {
|
|
23
|
-
key = _toPropertyKey$1(key);
|
|
24
|
-
if (key in obj) {
|
|
25
|
-
Object.defineProperty(obj, key, {
|
|
26
|
-
value: value,
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
obj[key] = value;
|
|
33
|
-
}
|
|
34
|
-
return obj;
|
|
35
|
-
}
|
|
36
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
37
|
-
if (source == null) return {};
|
|
38
|
-
var target = {};
|
|
39
|
-
var sourceKeys = Object.keys(source);
|
|
40
|
-
var key, i;
|
|
41
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
42
|
-
key = sourceKeys[i];
|
|
43
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
44
|
-
target[key] = source[key];
|
|
45
|
-
}
|
|
46
|
-
return target;
|
|
47
|
-
}
|
|
48
|
-
function _objectWithoutProperties(source, excluded) {
|
|
49
|
-
if (source == null) return {};
|
|
50
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
51
|
-
var key, i;
|
|
52
|
-
if (Object.getOwnPropertySymbols) {
|
|
53
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
54
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
55
|
-
key = sourceSymbolKeys[i];
|
|
56
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
57
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
58
|
-
target[key] = source[key];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return target;
|
|
62
|
-
}
|
|
63
|
-
function _toPrimitive$1(input, hint) {
|
|
64
|
-
if (typeof input !== "object" || input === null) return input;
|
|
65
|
-
var prim = input[Symbol.toPrimitive];
|
|
66
|
-
if (prim !== undefined) {
|
|
67
|
-
var res = prim.call(input, hint || "default");
|
|
68
|
-
if (typeof res !== "object") return res;
|
|
69
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
70
|
-
}
|
|
71
|
-
return (hint === "string" ? String : Number)(input);
|
|
72
|
-
}
|
|
73
|
-
function _toPropertyKey$1(arg) {
|
|
74
|
-
var key = _toPrimitive$1(arg, "string");
|
|
75
|
-
return typeof key === "symbol" ? key : String(key);
|
|
76
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {JSONValue[]} JSONArray
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {null|boolean|number|string|JSONArray|{[key: string]: JSONValue}} JSONValue
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @callback SimpleJSONCallback
|
|
10
|
+
* @param {...JSONValue} json
|
|
11
|
+
* @returns {void}
|
|
12
|
+
*/
|
|
77
13
|
|
|
78
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @callback SimpleJSONErrback
|
|
16
|
+
* @param {Error} err
|
|
17
|
+
* @param {string|string[]} jsonURL
|
|
18
|
+
* @returns {JSONValue}
|
|
19
|
+
*/
|
|
79
20
|
|
|
80
21
|
/**
|
|
81
|
-
* @
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
22
|
+
* @typedef {((
|
|
23
|
+
* jsonURL: string|string[],
|
|
24
|
+
* cb?: SimpleJSONCallback,
|
|
25
|
+
* errBack?: SimpleJSONErrback
|
|
26
|
+
* ) => Promise<JSONValue>) & {
|
|
27
|
+
* _fetch?: import('./index-polyglot.js').SimpleFetch,
|
|
28
|
+
* hasURLBasePath?: boolean,
|
|
29
|
+
* basePath?: string|false
|
|
30
|
+
* }} getJSONCallback
|
|
86
31
|
*/
|
|
87
32
|
|
|
88
33
|
/**
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
34
|
+
* @param {object} [cfg]
|
|
35
|
+
* @param {import('./index-polyglot.js').SimpleFetch} [cfg.fetch]
|
|
91
36
|
* @returns {getJSONCallback}
|
|
92
37
|
*/
|
|
38
|
+
|
|
93
39
|
function _await$2$1(value, then, direct) {
|
|
94
|
-
if (direct) {
|
|
95
|
-
return then ? then(value) : value;
|
|
96
|
-
}
|
|
97
40
|
if (!value || !value.then) {
|
|
98
41
|
value = Promise.resolve(value);
|
|
99
42
|
}
|
|
@@ -118,22 +61,9 @@ function _catch$2(body, recover) {
|
|
|
118
61
|
return result;
|
|
119
62
|
}
|
|
120
63
|
function buildGetJSONWithFetch({
|
|
121
|
-
// eslint-disable-next-line no-shadow
|
|
64
|
+
// eslint-disable-next-line no-shadow, no-undef -- This is a polyfill
|
|
122
65
|
fetch = typeof window !== 'undefined' ? window.fetch : self.fetch
|
|
123
66
|
} = {}) {
|
|
124
|
-
/**
|
|
125
|
-
* @callback SimpleJSONCallback
|
|
126
|
-
* @param {JSON} json
|
|
127
|
-
* @returns {void}
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @callback SimpleJSONErrback
|
|
132
|
-
* @param {Error} err
|
|
133
|
-
* @param {string|string[]} jsonURL
|
|
134
|
-
* @returns {void}
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
67
|
/**
|
|
138
68
|
* @type {getJSONCallback}
|
|
139
69
|
*/
|
|
@@ -144,10 +74,10 @@ function buildGetJSONWithFetch({
|
|
|
144
74
|
return _invoke$1(function () {
|
|
145
75
|
if (Array.isArray(jsonURL)) {
|
|
146
76
|
return _await$2$1(Promise.all(jsonURL.map(url => {
|
|
147
|
-
return getJSON(url);
|
|
77
|
+
return /** @type {getJSONCallback} */getJSON(url);
|
|
148
78
|
})), function (arrResult) {
|
|
149
79
|
if (cb) {
|
|
150
|
-
// eslint-disable-next-line
|
|
80
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
|
|
151
81
|
cb(...arrResult);
|
|
152
82
|
}
|
|
153
83
|
_exit = true;
|
|
@@ -157,20 +87,22 @@ function buildGetJSONWithFetch({
|
|
|
157
87
|
}, function (_result) {
|
|
158
88
|
return _exit ? _result : _await$2$1(fetch(jsonURL), function (resp) {
|
|
159
89
|
return _await$2$1(resp.json(), function (result) {
|
|
160
|
-
return typeof cb === 'function'
|
|
161
|
-
|
|
162
|
-
|
|
90
|
+
return typeof cb === 'function'
|
|
91
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks -- Old-style API
|
|
92
|
+
? cb(result) : result;
|
|
93
|
+
// https://github.com/bcoe/c8/issues/135
|
|
163
94
|
/* c8 ignore next */
|
|
164
95
|
});
|
|
165
96
|
});
|
|
166
97
|
});
|
|
167
|
-
}, function (
|
|
98
|
+
}, function (err) {
|
|
99
|
+
const e = /** @type {Error} */err;
|
|
168
100
|
e.message += ` (File: ${jsonURL})`;
|
|
169
101
|
if (errBack) {
|
|
170
102
|
return errBack(e, jsonURL);
|
|
171
103
|
}
|
|
172
|
-
throw e;
|
|
173
|
-
|
|
104
|
+
throw e;
|
|
105
|
+
// https://github.com/bcoe/c8/issues/135
|
|
174
106
|
/* c8 ignore next */
|
|
175
107
|
}));
|
|
176
108
|
/* c8 ignore next */
|
|
@@ -180,35 +112,38 @@ function buildGetJSONWithFetch({
|
|
|
180
112
|
};
|
|
181
113
|
}
|
|
182
114
|
function _await$1$1(value, then, direct) {
|
|
183
|
-
if (direct) {
|
|
184
|
-
return then ? then(value) : value;
|
|
185
|
-
}
|
|
186
115
|
if (!value || !value.then) {
|
|
187
116
|
value = Promise.resolve(value);
|
|
188
117
|
}
|
|
189
118
|
return then ? value.then(then) : value;
|
|
190
119
|
}
|
|
120
|
+
/* globals process -- Node */
|
|
191
121
|
|
|
192
|
-
/* eslint-disable node/no-unsupported-features/node-builtins,
|
|
193
|
-
node/no-unsupported-features/es-syntax, compat/compat */
|
|
194
122
|
// Needed for polyglot support (no `path` in browser); even if
|
|
195
123
|
// polyglot using dynamic `import` not supported by Rollup (complaining
|
|
196
124
|
// of inability to do tree-shaking in UMD builds), still useful to delay
|
|
197
125
|
// path import for our testing, so that test can import this file in
|
|
198
126
|
// the browser without compilation without it choking
|
|
199
|
-
|
|
200
|
-
function _empty() {}
|
|
127
|
+
|
|
201
128
|
/**
|
|
202
|
-
* @
|
|
203
|
-
* @returns {string}
|
|
129
|
+
* @type {(directory: string) => string}
|
|
204
130
|
*/
|
|
131
|
+
let dirname;
|
|
205
132
|
|
|
133
|
+
/** @type {boolean} */
|
|
134
|
+
|
|
135
|
+
function _empty() {}
|
|
136
|
+
let isWindows;
|
|
206
137
|
function _invokeIgnored(body) {
|
|
207
138
|
var result = body();
|
|
208
139
|
if (result && result.then) {
|
|
209
140
|
return result.then(_empty);
|
|
210
141
|
}
|
|
211
|
-
}
|
|
142
|
+
} /**
|
|
143
|
+
* @param {string} path
|
|
144
|
+
* @returns {string}
|
|
145
|
+
*/
|
|
146
|
+
|
|
212
147
|
function _async$1$1(f) {
|
|
213
148
|
return function () {
|
|
214
149
|
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
@@ -224,7 +159,7 @@ function _async$1$1(f) {
|
|
|
224
159
|
const setDirname = _async$1$1(function () {
|
|
225
160
|
return _invokeIgnored(function () {
|
|
226
161
|
if (!dirname) {
|
|
227
|
-
return _await$1$1(import('path'), function (_import) {
|
|
162
|
+
return _await$1$1(import('node:path'), function (_import) {
|
|
228
163
|
({
|
|
229
164
|
dirname
|
|
230
165
|
} = _import);
|
|
@@ -238,15 +173,14 @@ function fixWindowsPath(path) {
|
|
|
238
173
|
}
|
|
239
174
|
return path.slice(
|
|
240
175
|
// https://github.com/bcoe/c8/issues/135
|
|
241
|
-
|
|
242
176
|
/* c8 ignore next */
|
|
243
177
|
isWindows ? 1 : 0);
|
|
244
178
|
}
|
|
179
|
+
|
|
245
180
|
/**
|
|
246
181
|
* @param {string} url
|
|
247
182
|
* @returns {string}
|
|
248
183
|
*/
|
|
249
|
-
|
|
250
184
|
function getDirectoryForURL(url) {
|
|
251
185
|
// Node should be ok with this, but transpiling
|
|
252
186
|
// to `require` doesn't work, so detect Windows
|
|
@@ -255,12 +189,15 @@ function getDirectoryForURL(url) {
|
|
|
255
189
|
return fixWindowsPath(dirname(new URL(url).pathname));
|
|
256
190
|
}
|
|
257
191
|
|
|
258
|
-
/*
|
|
192
|
+
/* globals window, self -- Polyglot */
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @typedef {(url: string) => Promise<Response>} SimpleFetch
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
/** @type {{default: SimpleFetch}} */
|
|
259
199
|
|
|
260
200
|
function _await$3(value, then, direct) {
|
|
261
|
-
if (direct) {
|
|
262
|
-
return then ? then(value) : value;
|
|
263
|
-
}
|
|
264
201
|
if (!value || !value.then) {
|
|
265
202
|
value = Promise.resolve(value);
|
|
266
203
|
}
|
|
@@ -268,10 +205,10 @@ function _await$3(value, then, direct) {
|
|
|
268
205
|
}
|
|
269
206
|
let nodeFetch;
|
|
270
207
|
/**
|
|
271
|
-
* @param {
|
|
272
|
-
* @param {string} cfg.baseURL
|
|
273
|
-
* @param {string} cfg.cwd
|
|
274
|
-
* @returns {getJSONCallback}
|
|
208
|
+
* @param {object} [cfg]
|
|
209
|
+
* @param {string} [cfg.baseURL]
|
|
210
|
+
* @param {string|false} [cfg.cwd]
|
|
211
|
+
* @returns {import('./buildGetJSONWithFetch.js').getJSONCallback}
|
|
275
212
|
*/
|
|
276
213
|
|
|
277
214
|
function _invoke$2(body, then) {
|
|
@@ -282,9 +219,6 @@ function _invoke$2(body, then) {
|
|
|
282
219
|
return then(result);
|
|
283
220
|
}
|
|
284
221
|
function _call(body, then, direct) {
|
|
285
|
-
if (direct) {
|
|
286
|
-
return then ? then(body()) : body();
|
|
287
|
-
}
|
|
288
222
|
try {
|
|
289
223
|
var result = Promise.resolve(body());
|
|
290
224
|
return then ? result.then(then) : result;
|
|
@@ -308,18 +242,27 @@ function buildGetJSON({
|
|
|
308
242
|
baseURL,
|
|
309
243
|
cwd: basePath
|
|
310
244
|
} = {}) {
|
|
311
|
-
const _fetch = typeof window !== 'undefined' || typeof self !== 'undefined' ? typeof window !== 'undefined' ? window.fetch : self.fetch
|
|
245
|
+
const _fetch = typeof window !== 'undefined' || typeof self !== 'undefined' ? typeof window !== 'undefined' ? window.fetch : self.fetch
|
|
246
|
+
// eslint-disable-next-line @stylistic/operator-linebreak -- TS
|
|
247
|
+
:
|
|
248
|
+
/**
|
|
249
|
+
* @param {string} jsonURL
|
|
250
|
+
* @returns {Promise<Response>}
|
|
251
|
+
*/
|
|
252
|
+
_async$2(function (jsonURL) {
|
|
312
253
|
let _exit = false;
|
|
313
254
|
return _invoke$2(function () {
|
|
314
255
|
if (/^https?:/u.test(jsonURL)) {
|
|
315
256
|
return _invoke$2(function () {
|
|
316
257
|
if (!nodeFetch) {
|
|
317
|
-
return _await$3(import('node-fetch'), function (
|
|
258
|
+
return _await$3(import('node-fetch'), function (/** @type {{default: SimpleFetch}} */
|
|
259
|
+
/** @type {unknown} */
|
|
260
|
+
_import) {
|
|
318
261
|
nodeFetch = _import;
|
|
319
262
|
});
|
|
320
263
|
}
|
|
321
264
|
}, function () {
|
|
322
|
-
const _nodeFetch$default = nodeFetch.default(jsonURL);
|
|
265
|
+
const _nodeFetch$default = /** @type {SimpleFetch} */nodeFetch.default(jsonURL);
|
|
323
266
|
_exit = true;
|
|
324
267
|
return _nodeFetch$default;
|
|
325
268
|
});
|
|
@@ -335,45 +278,50 @@ function buildGetJSON({
|
|
|
335
278
|
// Filed https://github.com/bergos/file-fetch/issues/12 to see
|
|
336
279
|
// about getting relative basePaths in `file-fetch` and using
|
|
337
280
|
// that better-tested package instead
|
|
281
|
+
// @ts-expect-error Todo
|
|
282
|
+
// Don't change to an import as won't resolve for browser testing
|
|
283
|
+
// eslint-disable-next-line promise/avoid-new -- own API
|
|
284
|
+
/* c8 ignore next */
|
|
338
285
|
return _await$3(import('local-xmlhttprequest'), function (localXMLHttpRequest) {
|
|
339
|
-
|
|
340
|
-
|
|
286
|
+
const XMLHttpRequest = /* eslint-disable jsdoc/valid-types -- Bug */
|
|
287
|
+
/**
|
|
288
|
+
* @type {{
|
|
289
|
+
* prototype: XMLHttpRequest;
|
|
290
|
+
* new(): XMLHttpRequest
|
|
291
|
+
* }}
|
|
292
|
+
*/localXMLHttpRequest.default({
|
|
293
|
+
/* eslint-enable jsdoc/valid-types -- Bug */
|
|
341
294
|
basePath
|
|
342
|
-
});
|
|
343
|
-
// eslint-disable-next-line promise/avoid-new
|
|
344
|
-
|
|
295
|
+
});
|
|
345
296
|
return new Promise((resolve, reject) => {
|
|
346
297
|
const r = new XMLHttpRequest();
|
|
347
|
-
r.open('GET', jsonURL, true);
|
|
298
|
+
r.open('GET', jsonURL, true);
|
|
299
|
+
// r.responseType = 'json';
|
|
348
300
|
// eslint-disable-next-line unicorn/prefer-add-event-listener -- May not be available
|
|
349
|
-
|
|
350
301
|
r.onreadystatechange = function () {
|
|
351
302
|
// Not sure how to simulate `if`
|
|
352
|
-
|
|
353
|
-
/* c8 ignore next */
|
|
303
|
+
/* c8 ignore next 3 */
|
|
354
304
|
if (r.readyState !== 4) {
|
|
355
305
|
return;
|
|
356
306
|
}
|
|
357
307
|
if (r.status === 200) {
|
|
358
308
|
// var json = r.json;
|
|
359
309
|
const response = r.responseText;
|
|
360
|
-
resolve({
|
|
310
|
+
resolve(/** @type {Response} */{
|
|
361
311
|
json: () => JSON.parse(response)
|
|
362
312
|
});
|
|
363
313
|
return;
|
|
364
314
|
}
|
|
365
315
|
reject(new SyntaxError('Failed to fetch URL: ' + jsonURL + 'state: ' + r.readyState + '; status: ' + r.status));
|
|
366
316
|
};
|
|
367
|
-
r.send();
|
|
368
|
-
|
|
317
|
+
r.send();
|
|
318
|
+
// https://github.com/bcoe/c8/issues/135
|
|
369
319
|
/* c8 ignore next */
|
|
370
320
|
});
|
|
371
|
-
/* c8 ignore next */
|
|
372
321
|
});
|
|
373
322
|
});
|
|
374
323
|
});
|
|
375
324
|
});
|
|
376
|
-
|
|
377
325
|
const ret = buildGetJSONWithFetch({
|
|
378
326
|
fetch: _fetch
|
|
379
327
|
});
|
|
@@ -790,7 +738,6 @@ function generateUUID() {
|
|
|
790
738
|
if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
|
|
791
739
|
d += performance.now(); // use high-precision timer if available
|
|
792
740
|
}
|
|
793
|
-
|
|
794
741
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
795
742
|
/* eslint-disable no-bitwise */
|
|
796
743
|
var r = Math.trunc((d + Math.random() * 16) % 16);
|
|
@@ -1052,7 +999,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
|
|
|
1052
999
|
type: 'DATERANGE',
|
|
1053
1000
|
options: extraOpts
|
|
1054
1001
|
}));
|
|
1055
|
-
return dtf.formatRange.apply(dtf, _toConsumableArray$1(
|
|
1002
|
+
return dtf.formatRange.apply(dtf, _toConsumableArray$1(/** @type {[Date, Date]} */
|
|
1056
1003
|
[/** @type {number|Date} */
|
|
1057
1004
|
value, /** @type {Date} */
|
|
1058
1005
|
opts].map(function (val) {
|
|
@@ -1063,12 +1010,11 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
|
|
|
1063
1010
|
case 'language':
|
|
1064
1011
|
case 'script':
|
|
1065
1012
|
case 'currency':
|
|
1066
|
-
return
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
);
|
|
1013
|
+
return /** @type {string} */new Intl.DisplayNames(locale, _objectSpread2(_objectSpread2({}, applyArgs({
|
|
1014
|
+
type: singleKey.toUpperCase()
|
|
1015
|
+
})), {}, {
|
|
1016
|
+
type: singleKey
|
|
1017
|
+
})).of(/** @type {string} */value);
|
|
1072
1018
|
case 'relative':
|
|
1073
1019
|
// The second argument actually contains the primary options, so swap
|
|
1074
1020
|
// eslint-disable-next-line max-len -- Long
|
|
@@ -1078,12 +1024,12 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
|
|
|
1078
1024
|
opts = _ref4[1];
|
|
1079
1025
|
return new Intl.RelativeTimeFormat(locale, applyArgs({
|
|
1080
1026
|
type: 'RELATIVE'
|
|
1081
|
-
})).format(
|
|
1027
|
+
})).format(/** @type {number} */value, extraOpts);
|
|
1082
1028
|
|
|
1083
1029
|
// ListFormat (with Collator)
|
|
1084
1030
|
case 'list':
|
|
1085
1031
|
if (callback) {
|
|
1086
|
-
return sortList(
|
|
1032
|
+
return sortList(/** @type {string} */locale, /** @type {string[]} */
|
|
1087
1033
|
value, callback, applyArgs({
|
|
1088
1034
|
type: 'LIST'
|
|
1089
1035
|
}), applyArgs({
|
|
@@ -1092,7 +1038,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
|
|
|
1092
1038
|
checkArgOptions: true
|
|
1093
1039
|
}));
|
|
1094
1040
|
}
|
|
1095
|
-
return sortList(
|
|
1041
|
+
return sortList(/** @type {string} */locale, /** @type {string[]} */
|
|
1096
1042
|
value, applyArgs({
|
|
1097
1043
|
type: 'LIST'
|
|
1098
1044
|
}), applyArgs({
|
|
@@ -1106,7 +1052,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
|
|
|
1106
1052
|
|
|
1107
1053
|
// Dates
|
|
1108
1054
|
if (value) {
|
|
1109
|
-
if (typeof value === 'number' && (expectsDatetime || /^DATE(?:TIME)(?:\||$)/.test(
|
|
1055
|
+
if (typeof value === 'number' && (expectsDatetime || /^DATE(?:TIME)(?:\||$)/.test(/** @type {string} */arg))) {
|
|
1110
1056
|
value = new Date(value);
|
|
1111
1057
|
}
|
|
1112
1058
|
if (_typeof$1(value) === 'object' && 'getTime' in value && typeof value.getTime === 'function') {
|
|
@@ -1124,7 +1070,7 @@ var defaultAllSubstitutions = function defaultAllSubstitutions(_ref2) {
|
|
|
1124
1070
|
return (_Intl$DateTimeFormat = new Intl.DateTimeFormat(locale, applyArgs({
|
|
1125
1071
|
type: 'DATERANGE',
|
|
1126
1072
|
options: _extraOpts2
|
|
1127
|
-
}))).formatRange.apply(_Intl$DateTimeFormat, _toConsumableArray$1(
|
|
1073
|
+
}))).formatRange.apply(_Intl$DateTimeFormat, _toConsumableArray$1(/** @type {[Date, Date]} */
|
|
1128
1074
|
value.slice(0, 2).map(function (val) {
|
|
1129
1075
|
return typeof val === 'number' ? new Date(val) : val;
|
|
1130
1076
|
})));
|
|
@@ -1217,28 +1163,27 @@ var LocalFormatter = /*#__PURE__*/function (_Formatter) {
|
|
|
1217
1163
|
var components = key.slice(1).split('.');
|
|
1218
1164
|
/** @type {import('./getMessageForKeyByStyle.js').LocaleBody} */
|
|
1219
1165
|
var parent = this.locals;
|
|
1220
|
-
return
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
);
|
|
1166
|
+
return /** @type {typeof LocalFormatter} */this.constructor.isMatchingKey(key) && components.every(function (cmpt) {
|
|
1167
|
+
var result = cmpt in parent;
|
|
1168
|
+
parent =
|
|
1169
|
+
/**
|
|
1170
|
+
* @type {import('./defaultLocaleResolver.js').
|
|
1171
|
+
* RichNestedLocaleStringBodyObject|
|
|
1172
|
+
* import('./defaultLocaleResolver.js').
|
|
1173
|
+
* PlainNestedLocaleStringBodyObject|
|
|
1174
|
+
* import('./defaultLocaleResolver.js').RichLocaleStringSubObject
|
|
1175
|
+
* }
|
|
1176
|
+
*/
|
|
1177
|
+
/**
|
|
1178
|
+
* @type {import('./defaultLocaleResolver.js').
|
|
1179
|
+
* RichNestedLocaleStringBodyObject|
|
|
1180
|
+
* import('./defaultLocaleResolver.js').
|
|
1181
|
+
* PlainNestedLocaleStringBodyObject
|
|
1182
|
+
* }
|
|
1183
|
+
*/
|
|
1184
|
+
parent[cmpt];
|
|
1185
|
+
return result;
|
|
1186
|
+
});
|
|
1242
1187
|
}
|
|
1243
1188
|
/**
|
|
1244
1189
|
* @param {string} key
|
|
@@ -1277,8 +1222,7 @@ var RegularFormatter = /*#__PURE__*/function (_Formatter2) {
|
|
|
1277
1222
|
_createClass(RegularFormatter, [{
|
|
1278
1223
|
key: "isMatch",
|
|
1279
1224
|
value: function isMatch(key) {
|
|
1280
|
-
return
|
|
1281
|
-
);
|
|
1225
|
+
return /** @type {typeof RegularFormatter} */this.constructor.isMatchingKey(key) && key in this.substitutions;
|
|
1282
1226
|
}
|
|
1283
1227
|
/**
|
|
1284
1228
|
* @param {string} key
|
|
@@ -1422,11 +1366,11 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
|
|
|
1422
1366
|
// eslint-disable-next-line default-case
|
|
1423
1367
|
switch (type) {
|
|
1424
1368
|
case 'NUMBER':
|
|
1425
|
-
match = getNumberFormat(
|
|
1369
|
+
match = getNumberFormat(/** @type {number} */value, /** @type {Intl.NumberFormatOptions} */
|
|
1426
1370
|
options);
|
|
1427
1371
|
break;
|
|
1428
1372
|
case 'PLURAL':
|
|
1429
|
-
match = getPluralFormat(
|
|
1373
|
+
match = getPluralFormat(/** @type {number} */value, /** @type {Intl.PluralRulesOptions} */
|
|
1430
1374
|
options);
|
|
1431
1375
|
break;
|
|
1432
1376
|
}
|
|
@@ -1447,7 +1391,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
|
|
|
1447
1391
|
try {
|
|
1448
1392
|
return _getSubstitution({
|
|
1449
1393
|
messageStyle: messageStyle,
|
|
1450
|
-
key: match ? preventNesting(
|
|
1394
|
+
key: match ? preventNesting(/** @type {string} */match) : arg,
|
|
1451
1395
|
body: body,
|
|
1452
1396
|
type: 'switch'
|
|
1453
1397
|
});
|
|
@@ -1455,7 +1399,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
|
|
|
1455
1399
|
try {
|
|
1456
1400
|
return _getSubstitution({
|
|
1457
1401
|
messageStyle: messageStyle,
|
|
1458
|
-
key: '*' + preventNesting(
|
|
1402
|
+
key: '*' + preventNesting(/** @type {string} */match),
|
|
1459
1403
|
body: body,
|
|
1460
1404
|
type: 'switch'
|
|
1461
1405
|
});
|
|
@@ -1535,8 +1479,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
|
|
|
1535
1479
|
});
|
|
1536
1480
|
return ret ? [].concat(_toConsumableArray$1(ret), [k]) : [];
|
|
1537
1481
|
}, this.switches);
|
|
1538
|
-
return
|
|
1539
|
-
);
|
|
1482
|
+
return /** @type {SwitchMatch} */returnValue;
|
|
1540
1483
|
}
|
|
1541
1484
|
|
|
1542
1485
|
/**
|
|
@@ -1556,8 +1499,7 @@ var SwitchFormatter = /*#__PURE__*/function (_Formatter3) {
|
|
|
1556
1499
|
key: "getKey",
|
|
1557
1500
|
value: function getKey(key) {
|
|
1558
1501
|
var match = key.match(/^(?:[\0-\{\}-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*/);
|
|
1559
|
-
return
|
|
1560
|
-
);
|
|
1502
|
+
return /** @type {string} */match && match[0];
|
|
1561
1503
|
}
|
|
1562
1504
|
}]);
|
|
1563
1505
|
return SwitchFormatter;
|
|
@@ -1597,9 +1539,6 @@ promiseChainForValues(['a', 'b', 'c'], (val) => {
|
|
|
1597
1539
|
*/
|
|
1598
1540
|
|
|
1599
1541
|
function _await$2(value, then, direct) {
|
|
1600
|
-
if (direct) {
|
|
1601
|
-
return then ? then(value) : value;
|
|
1602
|
-
}
|
|
1603
1542
|
if (!value || !value.then) {
|
|
1604
1543
|
value = Promise.resolve(value);
|
|
1605
1544
|
}
|
|
@@ -1703,13 +1642,7 @@ function _for(test, update, body) {
|
|
|
1703
1642
|
break;
|
|
1704
1643
|
}
|
|
1705
1644
|
}
|
|
1706
|
-
|
|
1707
|
-
var updateValue = update();
|
|
1708
|
-
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
|
|
1709
|
-
stage = 2;
|
|
1710
|
-
break;
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1645
|
+
var updateValue;
|
|
1713
1646
|
}
|
|
1714
1647
|
var pact = new _Pact();
|
|
1715
1648
|
var reject = _settle.bind(null, pact, 2);
|
|
@@ -1718,13 +1651,6 @@ function _for(test, update, body) {
|
|
|
1718
1651
|
function _resumeAfterBody(value) {
|
|
1719
1652
|
result = value;
|
|
1720
1653
|
do {
|
|
1721
|
-
if (update) {
|
|
1722
|
-
updateValue = update();
|
|
1723
|
-
if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
|
|
1724
|
-
updateValue.then(_resumeAfterUpdate).then(void 0, reject);
|
|
1725
|
-
return;
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
1654
|
shouldContinue = test();
|
|
1729
1655
|
if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
|
|
1730
1656
|
_settle(pact, 1, result);
|
|
@@ -2135,9 +2061,9 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
|
|
|
2135
2061
|
});
|
|
2136
2062
|
};
|
|
2137
2063
|
addFunctionKeys();
|
|
2138
|
-
var localFormatter = new LocalFormatter(
|
|
2064
|
+
var localFormatter = new LocalFormatter(/** @type {import('./getMessageForKeyByStyle.js').LocalObject} */locals);
|
|
2139
2065
|
var regularFormatter = new RegularFormatter(substitutions);
|
|
2140
|
-
var switchFormatter = new SwitchFormatter(
|
|
2066
|
+
var switchFormatter = new SwitchFormatter(/** @type {import('./defaultLocaleResolver.js').Switches} */
|
|
2141
2067
|
switches, {
|
|
2142
2068
|
substitutions: substitutions
|
|
2143
2069
|
});
|
|
@@ -2227,8 +2153,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
|
|
|
2227
2153
|
}
|
|
2228
2154
|
|
|
2229
2155
|
// Change this and return type if other substitutions possible
|
|
2230
|
-
return
|
|
2231
|
-
);
|
|
2156
|
+
return /** @type {string|Node} */substitution;
|
|
2232
2157
|
};
|
|
2233
2158
|
var recursiveLocalCount = 1;
|
|
2234
2159
|
/**
|
|
@@ -2251,7 +2176,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
|
|
|
2251
2176
|
if (recursiveLocalCount++ > maximumLocalNestingDepth) {
|
|
2252
2177
|
throw new TypeError('Too much recursion in local variables.');
|
|
2253
2178
|
}
|
|
2254
|
-
if (
|
|
2179
|
+
if (/** @type {typeof import('./Formatter.js').LocalFormatter} */localFormatter.constructor.isMatchingKey(ky)) {
|
|
2255
2180
|
var extraSubsts = substitutions;
|
|
2256
2181
|
var localFormatters;
|
|
2257
2182
|
if (arg) {
|
|
@@ -2268,7 +2193,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
|
|
|
2268
2193
|
substitutions: localFormatters
|
|
2269
2194
|
});
|
|
2270
2195
|
}
|
|
2271
|
-
} else if (
|
|
2196
|
+
} else if (/** @type {typeof import('./Formatter.js').SwitchFormatter} */
|
|
2272
2197
|
switchFormatter.constructor.isMatchingKey(ky)) {
|
|
2273
2198
|
subst = processSubsts({
|
|
2274
2199
|
str: substitution
|
|
@@ -2397,7 +2322,7 @@ var defaultInsertNodes = function defaultInsertNodes(_ref) {
|
|
|
2397
2322
|
push(substitution.cloneNode(true));
|
|
2398
2323
|
} else {
|
|
2399
2324
|
// Why no number here?
|
|
2400
|
-
push(
|
|
2325
|
+
push(/** @type {string} */substitution);
|
|
2401
2326
|
}
|
|
2402
2327
|
}
|
|
2403
2328
|
usedKeys.push(ky);
|
|
@@ -2440,7 +2365,7 @@ function defaultKeyCheckerConverter(key, messageStyle) {
|
|
|
2440
2365
|
return typeof k === 'string';
|
|
2441
2366
|
}) && typeof messageStyle === 'string' && messageStyle.endsWith('Nested')) {
|
|
2442
2367
|
return key.map(function (k) {
|
|
2443
|
-
return k.replace(
|
|
2368
|
+
return k.replace(/*#__PURE__*/_wrapRegExp(/(\\+)/g, {
|
|
2444
2369
|
backslashes: 1
|
|
2445
2370
|
}), '\\$<backslashes>').replace(/\./g, '\\.');
|
|
2446
2371
|
}).join('.');
|
|
@@ -2753,7 +2678,6 @@ var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
|
|
|
2753
2678
|
locale = _ref.locale,
|
|
2754
2679
|
locals = _ref.locals,
|
|
2755
2680
|
switches = _ref.switches;
|
|
2756
|
-
_ref.maximumLocalNestingDepth;
|
|
2757
2681
|
var _ref$allSubstitutions = _ref.allSubstitutions,
|
|
2758
2682
|
allSubstitutions = _ref$allSubstitutions === void 0 ? [defaultAllSubstitutions] : _ref$allSubstitutions,
|
|
2759
2683
|
_ref$insertNodes = _ref.insertNodes,
|
|
@@ -2846,9 +2770,6 @@ var getDOMForLocaleString = function getDOMForLocaleString(_ref) {
|
|
|
2846
2770
|
return container;
|
|
2847
2771
|
};
|
|
2848
2772
|
function _await$1(value, then, direct) {
|
|
2849
|
-
if (direct) {
|
|
2850
|
-
return then ? then(value) : value;
|
|
2851
|
-
}
|
|
2852
2773
|
if (!value || !value.then) {
|
|
2853
2774
|
value = Promise.resolve(value);
|
|
2854
2775
|
}
|
|
@@ -2936,14 +2857,13 @@ var findLocaleStrings = function findLocaleStrings() {
|
|
|
2936
2857
|
localeResolver = _ref2.localeResolver,
|
|
2937
2858
|
localesBasePath = _ref2.localesBasePath,
|
|
2938
2859
|
localeMatcher = _ref2.localeMatcher;
|
|
2939
|
-
return
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
);
|
|
2860
|
+
return /** @type {Promise<LocaleObjectInfo>} */_findLocale({
|
|
2861
|
+
locales: locales,
|
|
2862
|
+
defaultLocales: defaultLocales,
|
|
2863
|
+
localeResolver: localeResolver,
|
|
2864
|
+
localesBasePath: localesBasePath,
|
|
2865
|
+
localeMatcher: localeMatcher
|
|
2866
|
+
});
|
|
2947
2867
|
};
|
|
2948
2868
|
|
|
2949
2869
|
/**
|
|
@@ -2989,10 +2909,10 @@ var _findLocale = _async(function (_ref4) {
|
|
|
2989
2909
|
});
|
|
2990
2910
|
});
|
|
2991
2911
|
}, function (err) {
|
|
2992
|
-
if (
|
|
2912
|
+
if (/** @type {Error} */err.name === 'SyntaxError') {
|
|
2993
2913
|
throw err;
|
|
2994
2914
|
}
|
|
2995
|
-
return _await$1(
|
|
2915
|
+
return _await$1(/** @type {LocaleMatcher} */localeMatcher(locale), getLocale);
|
|
2996
2916
|
});
|
|
2997
2917
|
});
|
|
2998
2918
|
var _ref4$locales = _ref4.locales,
|
|
@@ -3056,9 +2976,6 @@ var _findLocale = _async(function (_ref4) {
|
|
|
3056
2976
|
*/
|
|
3057
2977
|
|
|
3058
2978
|
function _await(value, then, direct) {
|
|
3059
|
-
if (direct) {
|
|
3060
|
-
return then ? then(value) : value;
|
|
3061
|
-
}
|
|
3062
2979
|
if (!value || !value.then) {
|
|
3063
2980
|
value = Promise.resolve(value);
|
|
3064
2981
|
}
|
|
@@ -3266,6 +3183,24 @@ var i18n = function i18n() {
|
|
|
3266
3183
|
}
|
|
3267
3184
|
};
|
|
3268
3185
|
|
|
3186
|
+
/**
|
|
3187
|
+
* @param {string|string[]} stylesheets
|
|
3188
|
+
* @param {{
|
|
3189
|
+
* before?: HTMLElement,
|
|
3190
|
+
* after?: HTMLElement,
|
|
3191
|
+
* favicon?: boolean,
|
|
3192
|
+
* image?: boolean,
|
|
3193
|
+
* canvas?: boolean,
|
|
3194
|
+
* acceptErrors?: boolean|((info: {
|
|
3195
|
+
* error: ErrorEvent,
|
|
3196
|
+
* stylesheetURL: string,
|
|
3197
|
+
* options: {},
|
|
3198
|
+
* resolve: (value: any) => void,
|
|
3199
|
+
* reject: (reason?: any) => void
|
|
3200
|
+
* }) => (reason?: any) => void)
|
|
3201
|
+
* }} cfg
|
|
3202
|
+
* @returns {Promise<HTMLLinkElement[]>}
|
|
3203
|
+
*/
|
|
3269
3204
|
function loadStylesheets(stylesheets, {
|
|
3270
3205
|
before: beforeDefault,
|
|
3271
3206
|
after: afterDefault,
|
|
@@ -3275,10 +3210,31 @@ function loadStylesheets(stylesheets, {
|
|
|
3275
3210
|
acceptErrors
|
|
3276
3211
|
} = {}) {
|
|
3277
3212
|
stylesheets = Array.isArray(stylesheets) ? stylesheets : [stylesheets];
|
|
3278
|
-
|
|
3213
|
+
|
|
3214
|
+
/**
|
|
3215
|
+
* @typedef {{
|
|
3216
|
+
* before?: HTMLElement,
|
|
3217
|
+
* after?: HTMLElement,
|
|
3218
|
+
* favicon?: boolean,
|
|
3219
|
+
* image?: boolean,
|
|
3220
|
+
* canvas?: boolean,
|
|
3221
|
+
* }} Options
|
|
3222
|
+
*/
|
|
3223
|
+
|
|
3224
|
+
/**
|
|
3225
|
+
* @param {string|[stylesheetURL: string, options: Options]} stylesheetURLInfo
|
|
3226
|
+
* @returns {Promise<HTMLLinkElement>}
|
|
3227
|
+
*/
|
|
3228
|
+
function setupLink(stylesheetURLInfo) {
|
|
3229
|
+
/** @type {Options} */
|
|
3279
3230
|
let options = {};
|
|
3280
|
-
|
|
3281
|
-
|
|
3231
|
+
|
|
3232
|
+
/** @type {string} */
|
|
3233
|
+
let stylesheetURL;
|
|
3234
|
+
if (Array.isArray(stylesheetURLInfo)) {
|
|
3235
|
+
[stylesheetURL, options = {}] = stylesheetURLInfo;
|
|
3236
|
+
} else {
|
|
3237
|
+
stylesheetURL = stylesheetURLInfo;
|
|
3282
3238
|
}
|
|
3283
3239
|
let {
|
|
3284
3240
|
favicon = faviconDefault
|
|
@@ -3295,7 +3251,7 @@ function loadStylesheets(stylesheets, {
|
|
|
3295
3251
|
} else if (after) {
|
|
3296
3252
|
after.after(link);
|
|
3297
3253
|
} else {
|
|
3298
|
-
document.head.
|
|
3254
|
+
document.head.append(link);
|
|
3299
3255
|
}
|
|
3300
3256
|
}
|
|
3301
3257
|
const link = document.createElement('link');
|
|
@@ -3338,6 +3294,9 @@ function loadStylesheets(stylesheets, {
|
|
|
3338
3294
|
reject(error);
|
|
3339
3295
|
});
|
|
3340
3296
|
img.addEventListener('load', () => {
|
|
3297
|
+
if (!context) {
|
|
3298
|
+
throw new Error('Canvas context could not be found');
|
|
3299
|
+
}
|
|
3341
3300
|
context.drawImage(img, 0, 0);
|
|
3342
3301
|
link.href = canvas ? cnv.toDataURL('image/x-icon') : stylesheetURL;
|
|
3343
3302
|
addLink();
|
|
@@ -3789,14 +3748,15 @@ function deserialize(form, hash) {
|
|
|
3789
3748
|
/**
|
|
3790
3749
|
* @file Note that this should be kept as a polyglot client-server file.
|
|
3791
3750
|
*/
|
|
3792
|
-
async function getLocaleFallbackResults({
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3751
|
+
async function getLocaleFallbackResults(_ref) {
|
|
3752
|
+
let {
|
|
3753
|
+
$p,
|
|
3754
|
+
lang,
|
|
3755
|
+
langs,
|
|
3756
|
+
langData,
|
|
3757
|
+
fallbackLanguages,
|
|
3758
|
+
basePath = ''
|
|
3759
|
+
} = _ref;
|
|
3800
3760
|
const l = await i18n({
|
|
3801
3761
|
messageStyle: 'plainNested',
|
|
3802
3762
|
locales: lang,
|
|
@@ -3817,7 +3777,6 @@ async function getLocaleFallbackResults({
|
|
|
3817
3777
|
return l;
|
|
3818
3778
|
}
|
|
3819
3779
|
|
|
3820
|
-
var _win;
|
|
3821
3780
|
/*
|
|
3822
3781
|
Possible todos:
|
|
3823
3782
|
0. Add XSLT to JML-string stylesheet (or even vice versa)
|
|
@@ -3885,7 +3844,7 @@ if (typeof window !== 'undefined' && window) {
|
|
|
3885
3844
|
}
|
|
3886
3845
|
|
|
3887
3846
|
/* c8 ignore next */
|
|
3888
|
-
let doc = typeof document !== 'undefined' && document ||
|
|
3847
|
+
let doc = typeof document !== 'undefined' && document || win?.document;
|
|
3889
3848
|
|
|
3890
3849
|
// STATIC PROPERTIES
|
|
3891
3850
|
|
|
@@ -3894,7 +3853,6 @@ const possibleOptions = ['$plugins',
|
|
|
3894
3853
|
// '$state', // Used internally
|
|
3895
3854
|
'$map' // Add any other options here
|
|
3896
3855
|
];
|
|
3897
|
-
|
|
3898
3856
|
const NS_HTML = 'http://www.w3.org/1999/xhtml',
|
|
3899
3857
|
hyphenForCamelCase = /-([a-z])/gu;
|
|
3900
3858
|
const ATTR_MAP = new Map([['maxlength', 'maxLength'], ['minlength', 'minLength'], ['readonly', 'readOnly']]);
|
|
@@ -4556,7 +4514,7 @@ function _DOMfromJMLOrString (childNodeJML) {
|
|
|
4556
4514
|
* @returns {Promise<void>|string|null}
|
|
4557
4515
|
*/
|
|
4558
4516
|
function checkPluginValue(elem, att, attVal, opts, state) {
|
|
4559
|
-
opts.$state = state
|
|
4517
|
+
opts.$state = state ?? 'attributeValue';
|
|
4560
4518
|
if (attVal && typeof attVal === 'object') {
|
|
4561
4519
|
const matchingPlugin = getMatchingPlugin(opts, Object.keys(attVal)[0]);
|
|
4562
4520
|
if (matchingPlugin) {
|
|
@@ -4570,8 +4528,7 @@ function checkPluginValue(elem, att, attVal, opts, state) {
|
|
|
4570
4528
|
});
|
|
4571
4529
|
}
|
|
4572
4530
|
}
|
|
4573
|
-
return
|
|
4574
|
-
);
|
|
4531
|
+
return /** @type {string} */attVal;
|
|
4575
4532
|
}
|
|
4576
4533
|
|
|
4577
4534
|
/**
|
|
@@ -4585,15 +4542,27 @@ function getMatchingPlugin(opts, pluginName) {
|
|
|
4585
4542
|
});
|
|
4586
4543
|
}
|
|
4587
4544
|
|
|
4545
|
+
/* eslint-disable jsdoc/valid-types -- pratt parser bug */
|
|
4546
|
+
/**
|
|
4547
|
+
* @template T
|
|
4548
|
+
* @typedef {T[keyof T]} ValueOf
|
|
4549
|
+
*/
|
|
4550
|
+
/* eslint-enable jsdoc/valid-types -- pratt parser bug */
|
|
4551
|
+
|
|
4552
|
+
/* eslint-disable jsdoc/valid-types -- pratt parser bug */
|
|
4588
4553
|
/**
|
|
4589
4554
|
* Creates an XHTML or HTML element (XHTML is preferred, but only in browsers
|
|
4590
4555
|
* that support); any element after element can be omitted, and any subsequent
|
|
4591
4556
|
* type or types added afterwards.
|
|
4592
|
-
* @
|
|
4593
|
-
* @
|
|
4557
|
+
* @template {JamilihArray} T
|
|
4558
|
+
* @param {T} args
|
|
4559
|
+
* @returns {T extends [keyof HTMLElementTagNameMap, any?, any?, any?]
|
|
4560
|
+
* ? HTMLElementTagNameMap[T[0]] : JamilihReturn}
|
|
4561
|
+
* The newly created (and possibly already appended)
|
|
4594
4562
|
* element or array of elements
|
|
4595
4563
|
*/
|
|
4596
4564
|
const jml = function jml(...args) {
|
|
4565
|
+
/* eslint-enable jsdoc/valid-types -- pratt parser bug */
|
|
4597
4566
|
if (!win) {
|
|
4598
4567
|
throw new Error('No window object');
|
|
4599
4568
|
}
|
|
@@ -4615,8 +4584,7 @@ const jml = function jml(...args) {
|
|
|
4615
4584
|
throw new Error('No document object');
|
|
4616
4585
|
}
|
|
4617
4586
|
for (let [att, attVal] of Object.entries(atts)) {
|
|
4618
|
-
|
|
4619
|
-
att = (_ATTR_MAP$get = ATTR_MAP.get(att)) !== null && _ATTR_MAP$get !== void 0 ? _ATTR_MAP$get : att;
|
|
4587
|
+
att = ATTR_MAP.get(att) ?? att;
|
|
4620
4588
|
|
|
4621
4589
|
/**
|
|
4622
4590
|
* @typedef {any} ElementExpando
|
|
@@ -4682,7 +4650,7 @@ const jml = function jml(...args) {
|
|
|
4682
4650
|
} else if (typeof template === 'string') {
|
|
4683
4651
|
template = /** @type {HTMLTemplateElement} */$$1(template);
|
|
4684
4652
|
}
|
|
4685
|
-
jml(
|
|
4653
|
+
jml(/** @type {HTMLTemplateElement} */
|
|
4686
4654
|
/** @type {HTMLTemplateElement} */template.content.cloneNode(true), shadowRoot);
|
|
4687
4655
|
} else {
|
|
4688
4656
|
if (!content) {
|
|
@@ -4815,7 +4783,7 @@ const jml = function jml(...args) {
|
|
|
4815
4783
|
cnstrctr = getConstructor();
|
|
4816
4784
|
}
|
|
4817
4785
|
if (!cnstrctr.toString().startsWith('class')) {
|
|
4818
|
-
cnstrctr = getConstructor(
|
|
4786
|
+
cnstrctr = getConstructor(/** @type {DefineUserConstructor} */cnstrctr);
|
|
4819
4787
|
}
|
|
4820
4788
|
if (!options && customizedBuiltIn) {
|
|
4821
4789
|
options = {
|
|
@@ -4835,7 +4803,7 @@ const jml = function jml(...args) {
|
|
|
4835
4803
|
{
|
|
4836
4804
|
const [symbol, func] = /** @type {SymbolArray} */attVal;
|
|
4837
4805
|
if (typeof func === 'function') {
|
|
4838
|
-
const funcBound = func.bind(
|
|
4806
|
+
const funcBound = func.bind(/** @type {HTMLElement} */elem);
|
|
4839
4807
|
if (typeof symbol === 'string') {
|
|
4840
4808
|
// @ts-expect-error
|
|
4841
4809
|
elem[Symbol.for(symbol)] = funcBound;
|
|
@@ -4858,7 +4826,7 @@ const jml = function jml(...args) {
|
|
|
4858
4826
|
}
|
|
4859
4827
|
case '$data':
|
|
4860
4828
|
{
|
|
4861
|
-
setMap(
|
|
4829
|
+
setMap(/** @type {true|string[]|Map<any, any>|WeakMap<any, any>|DataAttributeObject} */
|
|
4862
4830
|
attVal);
|
|
4863
4831
|
break;
|
|
4864
4832
|
}
|
|
@@ -4866,7 +4834,7 @@ const jml = function jml(...args) {
|
|
|
4866
4834
|
{
|
|
4867
4835
|
// Attribute node
|
|
4868
4836
|
const attr = /** @type {JamilihAttributeNodeValue} */attVal;
|
|
4869
|
-
const node = attr.length === 3 ? doc.createAttributeNS(attr[0], attr[1]) : doc.createAttribute(
|
|
4837
|
+
const node = attr.length === 3 ? doc.createAttributeNS(attr[0], attr[1]) : doc.createAttribute(/** @type {string} */attr[0]);
|
|
4870
4838
|
node.value = /** @type {string} */attr[attr.length - 1];
|
|
4871
4839
|
nodes[nodes.length] = node;
|
|
4872
4840
|
break;
|
|
@@ -4874,7 +4842,7 @@ const jml = function jml(...args) {
|
|
|
4874
4842
|
case '$text':
|
|
4875
4843
|
{
|
|
4876
4844
|
// Todo: Also allow as jml(['a text node']) (or should that become a fragment)?
|
|
4877
|
-
const node = doc.createTextNode(
|
|
4845
|
+
const node = doc.createTextNode(/** @type {string} */attVal);
|
|
4878
4846
|
nodes[nodes.length] = node;
|
|
4879
4847
|
break;
|
|
4880
4848
|
}
|
|
@@ -4894,29 +4862,26 @@ const jml = function jml(...args) {
|
|
|
4894
4862
|
cn.remove();
|
|
4895
4863
|
// `j` should stay the same as removing will cause node to be present
|
|
4896
4864
|
}
|
|
4897
|
-
|
|
4898
4865
|
jamlihDoc.childNodes.forEach(_childrenToJML(docNode));
|
|
4899
4866
|
} else {
|
|
4900
4867
|
if (jamlihDoc.$DOCTYPE) {
|
|
4901
|
-
var _docNode$firstChild;
|
|
4902
4868
|
const dt = {
|
|
4903
4869
|
$DOCTYPE: jamlihDoc.$DOCTYPE
|
|
4904
4870
|
};
|
|
4905
4871
|
const doctype = jml(dt);
|
|
4906
|
-
|
|
4872
|
+
docNode.firstChild?.replaceWith(doctype);
|
|
4907
4873
|
}
|
|
4908
4874
|
const html = docNode.querySelector('html');
|
|
4909
|
-
const head = html
|
|
4910
|
-
const body = html
|
|
4875
|
+
const head = html?.querySelector('head');
|
|
4876
|
+
const body = html?.querySelector('body');
|
|
4911
4877
|
if (jamlihDoc.title || jamlihDoc.head) {
|
|
4912
4878
|
const meta = doc.createElement('meta');
|
|
4913
4879
|
// eslint-disable-next-line unicorn/text-encoding-identifier-case -- HTML
|
|
4914
4880
|
meta.setAttribute('charset', 'utf-8');
|
|
4915
|
-
head
|
|
4881
|
+
head?.append(meta);
|
|
4916
4882
|
if (jamlihDoc.title) {
|
|
4917
4883
|
docNode.title = jamlihDoc.title; // Appends after meta
|
|
4918
4884
|
}
|
|
4919
|
-
|
|
4920
4885
|
if (jamlihDoc.head && head) {
|
|
4921
4886
|
// each child of `head` is:
|
|
4922
4887
|
// (JamilihArray|TextNodeString|HTMLElement|Comment|ProcessingInstruction|
|
|
@@ -4949,16 +4914,15 @@ const jml = function jml(...args) {
|
|
|
4949
4914
|
{
|
|
4950
4915
|
// Events
|
|
4951
4916
|
// Allow for no-op by defaulting to `{}`
|
|
4952
|
-
for (let [p2, val] of Object.entries(
|
|
4917
|
+
for (let [p2, val] of Object.entries(/** @type {OnAttributeObject} */attVal || {})) {
|
|
4953
4918
|
if (typeof val === 'function') {
|
|
4954
4919
|
val = [val, false];
|
|
4955
4920
|
}
|
|
4956
4921
|
if (typeof val[0] !== 'function') {
|
|
4957
4922
|
throw new TypeError(`Expect a function for \`$on\`; args: ${JSON.stringify(args)}`);
|
|
4958
4923
|
}
|
|
4959
|
-
_addEvent(
|
|
4924
|
+
_addEvent(/** @type {HTMLElement} */elem, p2, val[0], val[1]); // element, event name, handler, capturing
|
|
4960
4925
|
}
|
|
4961
|
-
|
|
4962
4926
|
break;
|
|
4963
4927
|
}
|
|
4964
4928
|
case 'className':
|
|
@@ -4992,7 +4956,7 @@ const jml = function jml(...args) {
|
|
|
4992
4956
|
recurse(value, prop);
|
|
4993
4957
|
});
|
|
4994
4958
|
};
|
|
4995
|
-
recurse(
|
|
4959
|
+
recurse(/** @type {DatasetAttributeObject} */attVal, '');
|
|
4996
4960
|
break;
|
|
4997
4961
|
// Todo: Disable this by default unless configuration explicitly allows (for security)
|
|
4998
4962
|
}
|
|
@@ -5144,12 +5108,11 @@ const jml = function jml(...args) {
|
|
|
5144
5108
|
// Array of strings mapping to default
|
|
5145
5109
|
if (typeof dataVal[0] === 'string') {
|
|
5146
5110
|
dataVal.forEach(dVal => {
|
|
5147
|
-
setMap(
|
|
5111
|
+
setMap(/** @type {MapWithRoot} */opts.$map[dVal]);
|
|
5148
5112
|
});
|
|
5149
5113
|
return;
|
|
5150
5114
|
// Array of Map and non-map data object
|
|
5151
5115
|
}
|
|
5152
|
-
|
|
5153
5116
|
map = dataVal[0] || defMap[0];
|
|
5154
5117
|
obj = dataVal[1] || defMap[1];
|
|
5155
5118
|
// Map
|
|
@@ -5162,7 +5125,7 @@ const jml = function jml(...args) {
|
|
|
5162
5125
|
obj = dataVal;
|
|
5163
5126
|
}
|
|
5164
5127
|
/** @type {Map<HTMLElement, any> | WeakMap<HTMLElement, any>} */
|
|
5165
|
-
map.set(
|
|
5128
|
+
map.set(/** @type {HTMLElement} */
|
|
5166
5129
|
elem, obj);
|
|
5167
5130
|
};
|
|
5168
5131
|
for (let i = argStart; i < argc; i++) {
|
|
@@ -5172,17 +5135,17 @@ const jml = function jml(...args) {
|
|
|
5172
5135
|
case 'null':
|
|
5173
5136
|
// null always indicates a place-holder (only needed for last argument if want array returned)
|
|
5174
5137
|
if (i === argc - 1) {
|
|
5175
|
-
|
|
5138
|
+
// Casting needing unless changing `jml()` signature with overloads
|
|
5139
|
+
return /** @type {ArbitraryValue} */nodes.length <= 1 ? nodes[0]
|
|
5176
5140
|
// eslint-disable-next-line unicorn/no-array-callback-reference
|
|
5177
5141
|
: nodes.reduce(_fragReducer, doc.createDocumentFragment()); // nodes;
|
|
5178
5142
|
}
|
|
5179
|
-
|
|
5180
5143
|
throw new TypeError(`\`null\` values not allowed except as final Jamilih argument; index ${i} on args: ${JSON.stringify(args)}`);
|
|
5181
5144
|
case 'string':
|
|
5182
5145
|
// Strings normally indicate elements
|
|
5183
5146
|
switch (arg) {
|
|
5184
5147
|
case '!':
|
|
5185
|
-
nodes[nodes.length] = doc.createComment(
|
|
5148
|
+
nodes[nodes.length] = doc.createComment(/** @type {string} */args[++i]);
|
|
5186
5149
|
break;
|
|
5187
5150
|
case '?':
|
|
5188
5151
|
{
|
|
@@ -5213,7 +5176,6 @@ const jml = function jml(...args) {
|
|
|
5213
5176
|
break;
|
|
5214
5177
|
// Browsers don't support doc.createEntityReference, so we just use this as a convenience
|
|
5215
5178
|
}
|
|
5216
|
-
|
|
5217
5179
|
case '&':
|
|
5218
5180
|
nodes[nodes.length] = _createSafeReference('entity', '', /** @type {string} */
|
|
5219
5181
|
args[++i]);
|
|
@@ -5232,12 +5194,11 @@ const jml = function jml(...args) {
|
|
|
5232
5194
|
// CDATA valid in XML only, so we'll just treat as text for mutual compatibility
|
|
5233
5195
|
// Todo: config (or detection via some kind of doc.documentType property?) of whether in XML
|
|
5234
5196
|
try {
|
|
5235
|
-
nodes[nodes.length] = doc.createCDATASection(
|
|
5197
|
+
nodes[nodes.length] = doc.createCDATASection(/** @type {string} */args[++i]);
|
|
5236
5198
|
} catch (e2) {
|
|
5237
|
-
nodes[nodes.length] = doc.createTextNode(
|
|
5199
|
+
nodes[nodes.length] = doc.createTextNode(/** @type {string} */
|
|
5238
5200
|
args[i]); // i already incremented
|
|
5239
5201
|
}
|
|
5240
|
-
|
|
5241
5202
|
break;
|
|
5242
5203
|
case '':
|
|
5243
5204
|
nodes[nodes.length] = elem = doc.createDocumentFragment();
|
|
@@ -5305,8 +5266,7 @@ const jml = function jml(...args) {
|
|
|
5305
5266
|
opts.$state = 'element';
|
|
5306
5267
|
// }catch(e) {alert(elem.outerHTML);throw e;}
|
|
5307
5268
|
}
|
|
5308
|
-
|
|
5309
|
-
_checkAtts( /** @type {JamilihAttributes} */atts);
|
|
5269
|
+
_checkAtts(/** @type {JamilihAttributes} */atts);
|
|
5310
5270
|
break;
|
|
5311
5271
|
}
|
|
5312
5272
|
case 'document':
|
|
@@ -5326,7 +5286,7 @@ const jml = function jml(...args) {
|
|
|
5326
5286
|
// parent
|
|
5327
5287
|
const elsl = nodes.length;
|
|
5328
5288
|
for (let k = 0; k < elsl; k++) {
|
|
5329
|
-
_appendNode(
|
|
5289
|
+
_appendNode(/** @type {Document|DocumentFragment|HTMLElement} */arg, nodes[k]);
|
|
5330
5290
|
}
|
|
5331
5291
|
} else {
|
|
5332
5292
|
nodes[nodes.length] = /** @type {Document|DocumentFragment|HTMLElement} */arg;
|
|
@@ -5387,7 +5347,9 @@ const jml = function jml(...args) {
|
|
|
5387
5347
|
if (isRoot && opts.$map && /** @type {MapWithRoot} */opts.$map.root) {
|
|
5388
5348
|
setMap(true);
|
|
5389
5349
|
}
|
|
5390
|
-
|
|
5350
|
+
|
|
5351
|
+
// Casting needing unless changing `jml()` signature with overloads
|
|
5352
|
+
return /** @type {ArbitraryValue} */ret;
|
|
5391
5353
|
};
|
|
5392
5354
|
|
|
5393
5355
|
/**
|
|
@@ -5485,7 +5447,6 @@ jml.toJML = function (nde, {
|
|
|
5485
5447
|
if (typeof nde === 'string') {
|
|
5486
5448
|
nde = new /** @type {import('jsdom').DOMWindow} */win.DOMParser().parseFromString(nde, 'text/html'); // todo: Give option for XML once implemented and change JSDoc to allow for Element
|
|
5487
5449
|
}
|
|
5488
|
-
|
|
5489
5450
|
const dom = /** @type {HTMLElement|Node|Entity} */nde;
|
|
5490
5451
|
|
|
5491
5452
|
/**
|
|
@@ -5597,7 +5558,7 @@ jml.toJML = function (nde, {
|
|
|
5597
5558
|
...namespaces
|
|
5598
5559
|
};
|
|
5599
5560
|
const xmlChars = /^([\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]|[\uD800-\uDBFF][\uDC00-\uDFFF])*$/u; // eslint-disable-line no-control-regex
|
|
5600
|
-
if ([2, 3, 4, 7, 8].includes(type) && /** @type {Node} */nodeOrEntity.nodeValue && !xmlChars.test(
|
|
5561
|
+
if ([2, 3, 4, 7, 8].includes(type) && /** @type {Node} */nodeOrEntity.nodeValue && !xmlChars.test(/** @type {Node} */nodeOrEntity.nodeValue)) {
|
|
5601
5562
|
invalidStateError('Node has bad XML character value');
|
|
5602
5563
|
}
|
|
5603
5564
|
|
|
@@ -5626,7 +5587,6 @@ jml.toJML = function (nde, {
|
|
|
5626
5587
|
parentIdx = tmpParentIdx;
|
|
5627
5588
|
parentIdx++; // Increment index in parent container of this element
|
|
5628
5589
|
}
|
|
5629
|
-
|
|
5630
5590
|
switch (type) {
|
|
5631
5591
|
case 1:
|
|
5632
5592
|
{
|
|
@@ -5700,10 +5660,9 @@ jml.toJML = function (nde, {
|
|
|
5700
5660
|
}
|
|
5701
5661
|
case 4:
|
|
5702
5662
|
{
|
|
5703
|
-
var _node$nodeValue;
|
|
5704
5663
|
// CDATA
|
|
5705
5664
|
const node = /** @type {CDATASection} */nodeOrEntity;
|
|
5706
|
-
if (
|
|
5665
|
+
if (node.nodeValue?.includes(']]' + '>')) {
|
|
5707
5666
|
invalidStateError('CDATA cannot end with closing ]]>');
|
|
5708
5667
|
}
|
|
5709
5668
|
set(['![', node.nodeValue]);
|
|
@@ -5787,7 +5746,7 @@ jml.toJML = function (nde, {
|
|
|
5787
5746
|
}
|
|
5788
5747
|
};
|
|
5789
5748
|
const pubIdChar = /^(\u0020|\u000D|\u000A|[a-zA-Z0-9]|[-'()+,./:=?;!*#@$_%])*$/u; // eslint-disable-line no-control-regex
|
|
5790
|
-
if (!pubIdChar.test(
|
|
5749
|
+
if (!pubIdChar.test(/** @type {DocumentType} */node.publicId)) {
|
|
5791
5750
|
invalidStateError('A publicId must have valid characters.');
|
|
5792
5751
|
}
|
|
5793
5752
|
addExternalID(start.$DOCTYPE, node);
|
|
@@ -5835,7 +5794,7 @@ jml.toJML = function (nde, {
|
|
|
5835
5794
|
* @returns {string}
|
|
5836
5795
|
*/
|
|
5837
5796
|
jml.toJMLString = function (dom, config) {
|
|
5838
|
-
return
|
|
5797
|
+
return /** @type {string} */(
|
|
5839
5798
|
jml.toJML(dom, Object.assign(config || {}, {
|
|
5840
5799
|
stringOutput: true
|
|
5841
5800
|
}))
|
|
@@ -5867,15 +5826,12 @@ jml.toHTML = function (...args) {
|
|
|
5867
5826
|
// Todo: deal with serialization of properties like 'selected',
|
|
5868
5827
|
// 'checked', 'value', 'defaultValue', 'for', 'dataset', 'on*',
|
|
5869
5828
|
// 'style'! (i.e., need to build a string ourselves)
|
|
5870
|
-
return
|
|
5871
|
-
);
|
|
5829
|
+
return /** @type {HTMLElement} */ret.outerHTML;
|
|
5872
5830
|
}
|
|
5873
5831
|
case 2:
|
|
5874
5832
|
{
|
|
5875
5833
|
// ATTR
|
|
5876
|
-
return `${
|
|
5877
|
-
/** @type {Attr} */ret.name}="${
|
|
5878
|
-
/** @type {Attr} */ret.value.replace(/"/gu, '"')}"`;
|
|
5834
|
+
return `${/** @type {Attr} */ret.name}="${/** @type {Attr} */ret.value.replace(/"/gu, '"')}"`;
|
|
5879
5835
|
}
|
|
5880
5836
|
case 3:
|
|
5881
5837
|
{
|
|
@@ -5886,8 +5842,7 @@ jml.toHTML = function (...args) {
|
|
|
5886
5842
|
if (!ret.nodeValue) {
|
|
5887
5843
|
throw new TypeError('Unexpected null Text node');
|
|
5888
5844
|
}
|
|
5889
|
-
return
|
|
5890
|
-
);
|
|
5845
|
+
return /** @type {Text|CDATASection} */ret.nodeValue;
|
|
5891
5846
|
// case 5: // Entity Reference Node
|
|
5892
5847
|
// No 6: Entity Node
|
|
5893
5848
|
// No 12: Notation Node
|
|
@@ -5897,14 +5852,13 @@ jml.toHTML = function (...args) {
|
|
|
5897
5852
|
// } case 8: { // Comment
|
|
5898
5853
|
// return `<!--${ret.nodeValue}-->`;
|
|
5899
5854
|
}
|
|
5900
|
-
|
|
5901
5855
|
case 9:
|
|
5902
5856
|
case 11:
|
|
5903
5857
|
{
|
|
5904
5858
|
// DOCUMENT FRAGMENT
|
|
5905
5859
|
const node = /** @type {DocumentFragment} */ret;
|
|
5906
5860
|
return [...node.childNodes].map(childNode => {
|
|
5907
|
-
return jml.toHTML(
|
|
5861
|
+
return jml.toHTML(/** @type {JamilihFirstArgument} */childNode);
|
|
5908
5862
|
}).join('');
|
|
5909
5863
|
}
|
|
5910
5864
|
case 10:
|
|
@@ -5914,7 +5868,6 @@ jml.toHTML = function (...args) {
|
|
|
5914
5868
|
return `<!DOCTYPE ${node.name}${node.publicId ? ` PUBLIC "${node.publicId}" "${node.systemId}"` : node.systemId ? ` SYSTEM "${node.systemId}"` : ``}>`;
|
|
5915
5869
|
/* c8 ignore next 3 */
|
|
5916
5870
|
}
|
|
5917
|
-
|
|
5918
5871
|
default:
|
|
5919
5872
|
throw new Error('Unexpected node type');
|
|
5920
5873
|
}
|
|
@@ -6096,7 +6049,6 @@ jml.command = function (elem, symOrMap, methodName, ...args) {
|
|
|
6096
6049
|
if (typeof func === 'function') {
|
|
6097
6050
|
return func(methodName, ...args); // Already has `this` bound to `elem`
|
|
6098
6051
|
}
|
|
6099
|
-
|
|
6100
6052
|
return func[methodName](...args);
|
|
6101
6053
|
}
|
|
6102
6054
|
func = /** @type {Map<HTMLElement, MapCommand>|WeakMap<HTMLElement, MapCommand>} */symOrMap.get(elem);
|
|
@@ -6117,9 +6069,8 @@ jml.command = function (elem, symOrMap, methodName, ...args) {
|
|
|
6117
6069
|
* @returns {void}
|
|
6118
6070
|
*/
|
|
6119
6071
|
jml.setWindow = wind => {
|
|
6120
|
-
var _win2;
|
|
6121
6072
|
win = wind;
|
|
6122
|
-
doc =
|
|
6073
|
+
doc = win?.document;
|
|
6123
6074
|
if (doc && doc.body) {
|
|
6124
6075
|
// eslint-disable-next-line prefer-destructuring -- Needed for typing
|
|
6125
6076
|
body = /** @type {HTMLBodyElement} */doc.body;
|
|
@@ -6154,9 +6105,6 @@ const $e = (el, descendentsSel) => {
|
|
|
6154
6105
|
return el.querySelector(descendentsSel);
|
|
6155
6106
|
};
|
|
6156
6107
|
|
|
6157
|
-
const _excluded$1 = ["submit", "submitClass"],
|
|
6158
|
-
_excluded2 = ["submit", "cancel", "cancelClass", "submitClass"],
|
|
6159
|
-
_excluded3 = ["message", "submit"];
|
|
6160
6108
|
const defaultLocale = 'en';
|
|
6161
6109
|
const localeStrings = {
|
|
6162
6110
|
en: {
|
|
@@ -6166,29 +6114,36 @@ const localeStrings = {
|
|
|
6166
6114
|
}
|
|
6167
6115
|
};
|
|
6168
6116
|
class Dialog {
|
|
6169
|
-
constructor({
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6117
|
+
constructor() {
|
|
6118
|
+
let {
|
|
6119
|
+
locale,
|
|
6120
|
+
localeObject
|
|
6121
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
6173
6122
|
this.setLocale({
|
|
6174
6123
|
locale,
|
|
6175
6124
|
localeObject
|
|
6176
6125
|
});
|
|
6177
6126
|
}
|
|
6178
|
-
setLocale({
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6127
|
+
setLocale(_ref) {
|
|
6128
|
+
let {
|
|
6129
|
+
locale = {},
|
|
6130
|
+
localeObject = {}
|
|
6131
|
+
} = _ref;
|
|
6132
|
+
this.localeStrings = {
|
|
6133
|
+
...localeStrings[defaultLocale],
|
|
6134
|
+
...localeStrings[locale],
|
|
6135
|
+
...localeObject
|
|
6136
|
+
};
|
|
6183
6137
|
}
|
|
6184
|
-
makeDialog({
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6138
|
+
makeDialog(_ref2) {
|
|
6139
|
+
let {
|
|
6140
|
+
atts = {
|
|
6141
|
+
$on: null
|
|
6142
|
+
},
|
|
6143
|
+
children = [],
|
|
6144
|
+
close,
|
|
6145
|
+
remove = true
|
|
6146
|
+
} = _ref2;
|
|
6192
6147
|
if (close) {
|
|
6193
6148
|
if (!atts.$on) {
|
|
6194
6149
|
atts.$on = {};
|
|
@@ -6206,13 +6161,13 @@ class Dialog {
|
|
|
6206
6161
|
}
|
|
6207
6162
|
return dialog;
|
|
6208
6163
|
}
|
|
6209
|
-
makeSubmitDialog(
|
|
6164
|
+
makeSubmitDialog(_ref3) {
|
|
6210
6165
|
let {
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6166
|
+
submit,
|
|
6167
|
+
// Don't pass this on to `args` if present
|
|
6168
|
+
submitClass = 'submit',
|
|
6169
|
+
...args
|
|
6170
|
+
} = _ref3;
|
|
6216
6171
|
const dialog = this.makeCancelDialog(args);
|
|
6217
6172
|
$e(dialog, `button.${args.cancelClass || 'cancel'}`).before(jml('button', {
|
|
6218
6173
|
class: submitClass,
|
|
@@ -6229,16 +6184,16 @@ class Dialog {
|
|
|
6229
6184
|
}, [this.localeStrings.submit]), nbsp.repeat(2));
|
|
6230
6185
|
return dialog;
|
|
6231
6186
|
}
|
|
6232
|
-
makeCancelDialog(
|
|
6187
|
+
makeCancelDialog(_ref4) {
|
|
6233
6188
|
let {
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6189
|
+
// eslint-disable-next-line no-unused-vars -- Discarding
|
|
6190
|
+
submit,
|
|
6191
|
+
// Don't pass this on to `args` if present
|
|
6192
|
+
cancel,
|
|
6193
|
+
cancelClass = 'cancel',
|
|
6194
|
+
submitClass = 'submit',
|
|
6195
|
+
...args
|
|
6196
|
+
} = _ref4;
|
|
6242
6197
|
const dialog = this.makeDialog(args);
|
|
6243
6198
|
jml('div', {
|
|
6244
6199
|
class: submitClass
|
|
@@ -6289,15 +6244,16 @@ class Dialog {
|
|
|
6289
6244
|
message
|
|
6290
6245
|
} : message;
|
|
6291
6246
|
const {
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6247
|
+
message: msg,
|
|
6248
|
+
submit: userSubmit,
|
|
6249
|
+
...submitArgs
|
|
6250
|
+
} = message;
|
|
6296
6251
|
return new Promise((resolve, reject) => {
|
|
6297
|
-
const submit = function ({
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6252
|
+
const submit = function (_ref5) {
|
|
6253
|
+
let {
|
|
6254
|
+
e,
|
|
6255
|
+
dialog
|
|
6256
|
+
} = _ref5;
|
|
6301
6257
|
if (userSubmit) {
|
|
6302
6258
|
userSubmit.call(this, {
|
|
6303
6259
|
e,
|
|
@@ -6308,13 +6264,14 @@ class Dialog {
|
|
|
6308
6264
|
resolve($e(dialog, 'input').value);
|
|
6309
6265
|
};
|
|
6310
6266
|
/* const dialog = */
|
|
6311
|
-
this.makeSubmitDialog(
|
|
6267
|
+
this.makeSubmitDialog({
|
|
6268
|
+
...submitArgs,
|
|
6312
6269
|
submit,
|
|
6313
6270
|
cancel() {
|
|
6314
6271
|
reject(new Error('cancelled'));
|
|
6315
6272
|
},
|
|
6316
6273
|
children: [['label', [msg, nbsp.repeat(3), ['input']]]]
|
|
6317
|
-
})
|
|
6274
|
+
});
|
|
6318
6275
|
});
|
|
6319
6276
|
}
|
|
6320
6277
|
confirm(message) {
|
|
@@ -6349,12 +6306,12 @@ class Dialog {
|
|
|
6349
6306
|
}
|
|
6350
6307
|
const dialogs = new Dialog();
|
|
6351
6308
|
|
|
6352
|
-
/* eslint-env browser */
|
|
6353
6309
|
// Todo: remember this locales choice by cookie?
|
|
6354
|
-
const getPreferredLanguages =
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6310
|
+
const getPreferredLanguages = _ref => {
|
|
6311
|
+
let {
|
|
6312
|
+
namespace,
|
|
6313
|
+
preferredLocale
|
|
6314
|
+
} = _ref;
|
|
6358
6315
|
// Todo: Add to this optionally with one-off tag input box
|
|
6359
6316
|
// Todo: Switch to fallbackLanguages so can default to
|
|
6360
6317
|
// navigator.languages?
|
|
@@ -6378,9 +6335,10 @@ const getPreferredLanguages = ({
|
|
|
6378
6335
|
* @classdesc Note that this should be kept as a polyglot client-server class.
|
|
6379
6336
|
*/
|
|
6380
6337
|
class Languages {
|
|
6381
|
-
constructor({
|
|
6382
|
-
|
|
6383
|
-
|
|
6338
|
+
constructor(_ref2) {
|
|
6339
|
+
let {
|
|
6340
|
+
langData
|
|
6341
|
+
} = _ref2;
|
|
6384
6342
|
this.langData = langData;
|
|
6385
6343
|
}
|
|
6386
6344
|
localeFromLangData(langCode) {
|
|
@@ -6391,32 +6349,38 @@ class Languages {
|
|
|
6391
6349
|
// Could add something like this in place or as fallback, though need to pass in locale
|
|
6392
6350
|
// || new Intl.DisplayNames([locale], {type: 'language'}).of(code);
|
|
6393
6351
|
}
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
return workI18n(['plugins', pluginName, 'fieldname'],
|
|
6352
|
+
getFieldNameFromPluginNameAndLocales(_ref3) {
|
|
6353
|
+
let {
|
|
6354
|
+
pluginName,
|
|
6355
|
+
// locales,
|
|
6356
|
+
workI18n,
|
|
6357
|
+
targetLanguage,
|
|
6358
|
+
applicableFieldI18N,
|
|
6359
|
+
meta,
|
|
6360
|
+
metaApplicableField
|
|
6361
|
+
} = _ref3;
|
|
6362
|
+
return workI18n(['plugins', pluginName, 'fieldname'], {
|
|
6363
|
+
...meta,
|
|
6364
|
+
...metaApplicableField,
|
|
6405
6365
|
applicableField: applicableFieldI18N,
|
|
6406
6366
|
targetLanguage: targetLanguage ? this.getLanguageFromCode(targetLanguage) : ''
|
|
6407
|
-
}
|
|
6367
|
+
}, {
|
|
6408
6368
|
// We provide more than may be desired by the plugin
|
|
6409
6369
|
throwOnExtraSuppliedFormatters: false
|
|
6410
6370
|
});
|
|
6411
6371
|
}
|
|
6412
|
-
getLanguageInfo({
|
|
6413
|
-
|
|
6414
|
-
|
|
6372
|
+
getLanguageInfo(_ref4) {
|
|
6373
|
+
let {
|
|
6374
|
+
$p
|
|
6375
|
+
} = _ref4;
|
|
6415
6376
|
const langs = this.langData.languages;
|
|
6416
6377
|
const localePass = lcl => {
|
|
6417
|
-
return langs.some(
|
|
6418
|
-
|
|
6419
|
-
|
|
6378
|
+
return langs.some(_ref5 => {
|
|
6379
|
+
let {
|
|
6380
|
+
code
|
|
6381
|
+
} = _ref5;
|
|
6382
|
+
return code === lcl;
|
|
6383
|
+
}) ? lcl : false;
|
|
6420
6384
|
};
|
|
6421
6385
|
const languageParam = $p.get('lang', true);
|
|
6422
6386
|
// Todo: We could (unless overridden by another button) assume the
|
|
@@ -14356,8 +14320,6 @@ var JsonRefs = function (t) {
|
|
|
14356
14320
|
}, "object" === c(n) && void 0 !== t ? u(n) : (o = [n], void 0 === (i = "function" == typeof (e = u) ? e.apply(n, o) : e) || (t.exports = i));
|
|
14357
14321
|
}]);
|
|
14358
14322
|
|
|
14359
|
-
/* eslint-env browser */
|
|
14360
|
-
|
|
14361
14323
|
const getCurrDir = () => {
|
|
14362
14324
|
return window.location.href.replace(/(index\.html)?#.*$/, '');
|
|
14363
14325
|
};
|
|
@@ -14401,13 +14363,14 @@ const getMetadata = async (file, property, basePath) => {
|
|
|
14401
14363
|
}
|
|
14402
14364
|
})).resolved;
|
|
14403
14365
|
};
|
|
14404
|
-
const getFieldNameAndValueAliases = function ({
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14366
|
+
const getFieldNameAndValueAliases = function (_ref) {
|
|
14367
|
+
let {
|
|
14368
|
+
field,
|
|
14369
|
+
schemaItems,
|
|
14370
|
+
metadataObj,
|
|
14371
|
+
getFieldAliasOrName,
|
|
14372
|
+
lang
|
|
14373
|
+
} = _ref;
|
|
14411
14374
|
const fieldSchemaIndex = schemaItems.findIndex(item => {
|
|
14412
14375
|
return item.title === field;
|
|
14413
14376
|
});
|
|
@@ -14429,6 +14392,7 @@ const getFieldNameAndValueAliases = function ({
|
|
|
14429
14392
|
if (fieldValueAliasMap.localeKey) {
|
|
14430
14393
|
fieldValueAliasMap = getMetaProp(lang, metadataObj, fieldValueAliasMap.localeKey.split('/'), true);
|
|
14431
14394
|
}
|
|
14395
|
+
// eslint-disable-next-line unicorn/prefer-structured-clone -- Expecting JSON
|
|
14432
14396
|
ret.rawFieldValueAliasMap = JSON.parse(JSON.stringify(fieldValueAliasMap));
|
|
14433
14397
|
ret.aliases = [];
|
|
14434
14398
|
// Todo: We could use `prefer_alias` but algorithm below may cover
|
|
@@ -14447,7 +14411,8 @@ const getFieldNameAndValueAliases = function ({
|
|
|
14447
14411
|
// Todo: We might iterate over all values (in case some not
|
|
14448
14412
|
// included in fv map)
|
|
14449
14413
|
// Todo: Check `fieldSchema` for integer or string type
|
|
14450
|
-
Object.entries(fieldValueAliasMap).forEach(
|
|
14414
|
+
Object.entries(fieldValueAliasMap).forEach(_ref2 => {
|
|
14415
|
+
let [key, aliases] = _ref2;
|
|
14451
14416
|
// We'll preserve the numbers since probably more useful if
|
|
14452
14417
|
// stored with data (as opposed to enums)
|
|
14453
14418
|
if (!Array.isArray(aliases)) {
|
|
@@ -14462,20 +14427,20 @@ const getFieldNameAndValueAliases = function ({
|
|
|
14462
14427
|
);
|
|
14463
14428
|
});
|
|
14464
14429
|
}
|
|
14465
|
-
|
|
14430
|
+
// eslint-disable-next-line unicorn/prefer-structured-clone -- Expecting JSON
|
|
14466
14431
|
ret.fieldValueAliasMap = JSON.parse(JSON.stringify(fieldValueAliasMap));
|
|
14467
14432
|
// ret.aliases.sort();
|
|
14468
14433
|
}
|
|
14469
|
-
|
|
14470
14434
|
return ret;
|
|
14471
14435
|
};
|
|
14472
|
-
const getBrowseFieldData = function ({
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14436
|
+
const getBrowseFieldData = function (_ref3) {
|
|
14437
|
+
let {
|
|
14438
|
+
metadataObj,
|
|
14439
|
+
schemaItems,
|
|
14440
|
+
getFieldAliasOrName,
|
|
14441
|
+
lang,
|
|
14442
|
+
callback
|
|
14443
|
+
} = _ref3;
|
|
14479
14444
|
metadataObj.table.browse_fields.forEach((browseFieldSetObject, i) => {
|
|
14480
14445
|
if (typeof browseFieldSetObject === 'string') {
|
|
14481
14446
|
browseFieldSetObject = {
|
|
@@ -14507,15 +14472,16 @@ const getBrowseFieldData = function ({
|
|
|
14507
14472
|
browseFields,
|
|
14508
14473
|
i,
|
|
14509
14474
|
presort
|
|
14510
|
-
});
|
|
14475
|
+
});
|
|
14511
14476
|
});
|
|
14512
14477
|
};
|
|
14513
14478
|
|
|
14514
14479
|
// Todo: Incorporate other methods into this class
|
|
14515
14480
|
class Metadata {
|
|
14516
|
-
constructor({
|
|
14517
|
-
|
|
14518
|
-
|
|
14481
|
+
constructor(_ref4) {
|
|
14482
|
+
let {
|
|
14483
|
+
metadataObj
|
|
14484
|
+
} = _ref4;
|
|
14519
14485
|
this.metadataObj = metadataObj;
|
|
14520
14486
|
}
|
|
14521
14487
|
getFieldLang(field) {
|
|
@@ -14525,12 +14491,13 @@ class Metadata {
|
|
|
14525
14491
|
const fields = metadataObj && metadataObj.fields;
|
|
14526
14492
|
return fields && fields[field] && fields[field].lang;
|
|
14527
14493
|
}
|
|
14528
|
-
getFieldMatchesLocale({
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14494
|
+
getFieldMatchesLocale(_ref5) {
|
|
14495
|
+
let {
|
|
14496
|
+
namespace,
|
|
14497
|
+
preferredLocale,
|
|
14498
|
+
schemaItems,
|
|
14499
|
+
pluginsForWork
|
|
14500
|
+
} = _ref5;
|
|
14534
14501
|
const {
|
|
14535
14502
|
metadataObj
|
|
14536
14503
|
} = this;
|
|
@@ -14581,41 +14548,45 @@ const unescapePluginComponent = pluginName => {
|
|
|
14581
14548
|
return esc.length % 2 ? esc.slice(1) + '-' : n0;
|
|
14582
14549
|
}).replaceAll('^^', '^');
|
|
14583
14550
|
};
|
|
14584
|
-
const escapePlugin =
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14551
|
+
const escapePlugin = _ref => {
|
|
14552
|
+
let {
|
|
14553
|
+
pluginName,
|
|
14554
|
+
applicableField,
|
|
14555
|
+
targetLanguage
|
|
14556
|
+
} = _ref;
|
|
14589
14557
|
return escapePluginComponent(pluginName) + (applicableField ? '-' + escapePluginComponent(applicableField) : '-') + (targetLanguage ? '-' + escapePluginComponent(targetLanguage) : '');
|
|
14590
14558
|
};
|
|
14591
14559
|
class PluginsForWork {
|
|
14592
|
-
constructor({
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14596
|
-
|
|
14560
|
+
constructor(_ref2) {
|
|
14561
|
+
let {
|
|
14562
|
+
pluginsInWork,
|
|
14563
|
+
pluginFieldMappings,
|
|
14564
|
+
pluginObjects
|
|
14565
|
+
} = _ref2;
|
|
14597
14566
|
this.pluginsInWork = pluginsInWork;
|
|
14598
14567
|
this.pluginFieldMappings = pluginFieldMappings;
|
|
14599
14568
|
this.pluginObjects = pluginObjects;
|
|
14600
14569
|
}
|
|
14601
14570
|
getPluginObject(pluginName) {
|
|
14602
|
-
const idx = this.pluginsInWork.findIndex(
|
|
14571
|
+
const idx = this.pluginsInWork.findIndex(_ref3 => {
|
|
14572
|
+
let [name] = _ref3;
|
|
14603
14573
|
return name === pluginName;
|
|
14604
14574
|
});
|
|
14605
14575
|
const plugin = this.pluginObjects[idx];
|
|
14606
14576
|
return plugin;
|
|
14607
14577
|
}
|
|
14608
14578
|
iterateMappings(cb) {
|
|
14609
|
-
this.pluginFieldMappings.forEach(({
|
|
14610
|
-
|
|
14611
|
-
|
|
14612
|
-
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14618
|
-
|
|
14579
|
+
this.pluginFieldMappings.forEach((_ref4, i) => {
|
|
14580
|
+
let {
|
|
14581
|
+
placement,
|
|
14582
|
+
/*
|
|
14583
|
+
{fieldXYZ: {
|
|
14584
|
+
targetLanguage: "en"|["en"], // E.g., translating from Persian to English
|
|
14585
|
+
onByDefault: true // Overrides plugin default
|
|
14586
|
+
}}
|
|
14587
|
+
*/
|
|
14588
|
+
'applicable-fields': applicableFields
|
|
14589
|
+
} = _ref4;
|
|
14619
14590
|
const [pluginName, {
|
|
14620
14591
|
onByDefault: onByDefaultDefault,
|
|
14621
14592
|
lang: pluginLang,
|
|
@@ -14623,7 +14594,6 @@ class PluginsForWork {
|
|
|
14623
14594
|
}] = this.pluginsInWork[i];
|
|
14624
14595
|
const plugin = this.getPluginObject(pluginName);
|
|
14625
14596
|
cb({
|
|
14626
|
-
// eslint-disable-line n/no-callback-literal
|
|
14627
14597
|
plugin,
|
|
14628
14598
|
placement,
|
|
14629
14599
|
applicableFields,
|
|
@@ -14638,11 +14608,12 @@ class PluginsForWork {
|
|
|
14638
14608
|
if (!applicableFields) {
|
|
14639
14609
|
return false;
|
|
14640
14610
|
}
|
|
14641
|
-
Object.entries(applicableFields).forEach(
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14611
|
+
Object.entries(applicableFields).forEach(_ref5 => {
|
|
14612
|
+
let [applicableField, {
|
|
14613
|
+
targetLanguage,
|
|
14614
|
+
onByDefault,
|
|
14615
|
+
meta: metaApplicableField
|
|
14616
|
+
}] = _ref5;
|
|
14646
14617
|
if (Array.isArray(targetLanguage)) {
|
|
14647
14618
|
targetLanguage.forEach(targetLanguage => {
|
|
14648
14619
|
cb({
|
|
@@ -14650,31 +14621,31 @@ class PluginsForWork {
|
|
|
14650
14621
|
targetLanguage,
|
|
14651
14622
|
onByDefault,
|
|
14652
14623
|
metaApplicableField
|
|
14653
|
-
});
|
|
14624
|
+
});
|
|
14654
14625
|
});
|
|
14655
14626
|
} else {
|
|
14656
|
-
// eslint-disable-next-line n/callback-return
|
|
14657
14627
|
cb({
|
|
14658
14628
|
applicableField,
|
|
14659
14629
|
targetLanguage,
|
|
14660
14630
|
onByDefault,
|
|
14661
14631
|
metaApplicableField
|
|
14662
|
-
});
|
|
14632
|
+
});
|
|
14663
14633
|
}
|
|
14664
14634
|
});
|
|
14665
|
-
|
|
14666
14635
|
return true;
|
|
14667
14636
|
}
|
|
14668
|
-
isPluginField({
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14637
|
+
isPluginField(_ref6) {
|
|
14638
|
+
let {
|
|
14639
|
+
namespace,
|
|
14640
|
+
field
|
|
14641
|
+
} = _ref6;
|
|
14672
14642
|
return field.startsWith(`${namespace}-plugin-`);
|
|
14673
14643
|
}
|
|
14674
|
-
getPluginFieldParts({
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14644
|
+
getPluginFieldParts(_ref7) {
|
|
14645
|
+
let {
|
|
14646
|
+
namespace,
|
|
14647
|
+
field
|
|
14648
|
+
} = _ref7;
|
|
14678
14649
|
field = field.replace(`${namespace}-plugin-`, '');
|
|
14679
14650
|
let pluginName, applicableField, targetLanguage;
|
|
14680
14651
|
if (field.includes('-')) {
|
|
@@ -14686,6 +14657,7 @@ class PluginsForWork {
|
|
|
14686
14657
|
}
|
|
14687
14658
|
}
|
|
14688
14659
|
|
|
14660
|
+
/* globals process -- Node polyglot */
|
|
14689
14661
|
const getFilePaths = function getFilePaths(filesObj, fileGroup, fileData) {
|
|
14690
14662
|
const baseDir = (filesObj.baseDirectory || '') + (fileGroup.baseDirectory || '') + '/';
|
|
14691
14663
|
const schemaBaseDir = (filesObj.schemaBaseDirectory || '') + (fileGroup.schemaBaseDirectory || '') + '/';
|
|
@@ -14699,27 +14671,29 @@ const getFilePaths = function getFilePaths(filesObj, fileGroup, fileData) {
|
|
|
14699
14671
|
metadataFile
|
|
14700
14672
|
};
|
|
14701
14673
|
};
|
|
14702
|
-
const getWorkData = async function ({
|
|
14703
|
-
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
const
|
|
14714
|
-
const
|
|
14674
|
+
const getWorkData = async function (_ref) {
|
|
14675
|
+
let {
|
|
14676
|
+
lang,
|
|
14677
|
+
fallbackLanguages,
|
|
14678
|
+
work,
|
|
14679
|
+
files,
|
|
14680
|
+
allowPlugins,
|
|
14681
|
+
basePath,
|
|
14682
|
+
languages,
|
|
14683
|
+
preferredLocale
|
|
14684
|
+
} = _ref;
|
|
14685
|
+
const filesObj = await getJSON(files);
|
|
14686
|
+
const localizationStrings = filesObj['localization-strings'];
|
|
14687
|
+
const workI18n = await i18n({
|
|
14715
14688
|
messageStyle: 'plainNested',
|
|
14716
14689
|
locales: lang,
|
|
14717
14690
|
defaultLocales: fallbackLanguages,
|
|
14718
14691
|
// Todo: Could at least share this with `index.js`
|
|
14719
|
-
localeStringFinder({
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14692
|
+
localeStringFinder(_ref2) {
|
|
14693
|
+
let {
|
|
14694
|
+
locales,
|
|
14695
|
+
defaultLocales
|
|
14696
|
+
} = _ref2;
|
|
14723
14697
|
const locale = [...locales, ...defaultLocales].find(language => {
|
|
14724
14698
|
return language in localizationStrings;
|
|
14725
14699
|
});
|
|
@@ -14778,13 +14752,18 @@ const getWorkData = async function ({
|
|
|
14778
14752
|
const possiblePluginFieldMappingForWork = pluginFieldMappingID[fileData.name];
|
|
14779
14753
|
if (possiblePluginFieldMappingForWork) {
|
|
14780
14754
|
pluginFieldsForWork = Object.keys(possiblePluginFieldMappingForWork);
|
|
14781
|
-
pluginsInWork = Object.entries(filesObj.plugins).filter(
|
|
14755
|
+
pluginsInWork = Object.entries(filesObj.plugins).filter(_ref3 => {
|
|
14756
|
+
let [p] = _ref3;
|
|
14782
14757
|
return pluginFieldsForWork.includes(p);
|
|
14783
14758
|
});
|
|
14784
|
-
pluginFieldMappingForWork = pluginsInWork.map(
|
|
14759
|
+
pluginFieldMappingForWork = pluginsInWork.map(_ref4 => {
|
|
14760
|
+
let [p] = _ref4;
|
|
14785
14761
|
return possiblePluginFieldMappingForWork[p];
|
|
14786
14762
|
});
|
|
14787
|
-
pluginPaths = pluginsInWork.map(
|
|
14763
|
+
pluginPaths = pluginsInWork.map(_ref5 => {
|
|
14764
|
+
let [, pluginObj] = _ref5;
|
|
14765
|
+
return pluginObj.path;
|
|
14766
|
+
});
|
|
14788
14767
|
getPlugins = pluginsInWork;
|
|
14789
14768
|
}
|
|
14790
14769
|
}
|
|
@@ -14816,7 +14795,7 @@ const getWorkData = async function ({
|
|
|
14816
14795
|
const pluginFieldMappings = pluginFieldMappingForWork;
|
|
14817
14796
|
const cwd = typeof process === 'undefined' ? location.href.slice(0, location.href.lastIndexOf('/') + 1) : process.cwd() + '/';
|
|
14818
14797
|
const [schemaObj, pluginObjects] = await Promise.all([getMetadata(schemaFile, schemaProperty, basePath), getPlugins ? Promise.all(pluginPaths.map(pluginPath => {
|
|
14819
|
-
// eslint-disable-next-line no-unsanitized/method
|
|
14798
|
+
// // eslint-disable-next-line no-unsanitized/method
|
|
14820
14799
|
return import(cwd + pluginPath);
|
|
14821
14800
|
})) : null]);
|
|
14822
14801
|
const pluginsForWork = new PluginsForWork({
|
|
@@ -14825,9 +14804,10 @@ const getWorkData = async function ({
|
|
|
14825
14804
|
pluginObjects
|
|
14826
14805
|
});
|
|
14827
14806
|
const schemaItems = schemaObj.items.items;
|
|
14828
|
-
const fieldInfo = schemaItems.map(
|
|
14829
|
-
|
|
14830
|
-
|
|
14807
|
+
const fieldInfo = schemaItems.map(_ref6 => {
|
|
14808
|
+
let {
|
|
14809
|
+
title: field
|
|
14810
|
+
} = _ref6;
|
|
14831
14811
|
return {
|
|
14832
14812
|
field,
|
|
14833
14813
|
fieldAliasOrName: getFieldAliasOrName(field) || field
|
|
@@ -14844,21 +14824,23 @@ const getWorkData = async function ({
|
|
|
14844
14824
|
lang,
|
|
14845
14825
|
namespace
|
|
14846
14826
|
} = this; // array with first item as preferred
|
|
14847
|
-
pluginsForWork.iterateMappings(
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14827
|
+
pluginsForWork.iterateMappings(_ref7 => {
|
|
14828
|
+
let {
|
|
14829
|
+
// plugin,
|
|
14830
|
+
pluginName,
|
|
14831
|
+
pluginLang,
|
|
14832
|
+
onByDefaultDefault,
|
|
14833
|
+
placement,
|
|
14834
|
+
applicableFields,
|
|
14835
|
+
meta
|
|
14836
|
+
} = _ref7;
|
|
14837
|
+
const processField = function () {
|
|
14838
|
+
let {
|
|
14839
|
+
applicableField,
|
|
14840
|
+
targetLanguage,
|
|
14841
|
+
onByDefault,
|
|
14842
|
+
metaApplicableField
|
|
14843
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14862
14844
|
const plugin = pluginsForWork.getPluginObject(pluginName) || {};
|
|
14863
14845
|
const applicableFieldLang = metadata.getFieldLang(applicableField);
|
|
14864
14846
|
if (plugin.getTargetLanguage) {
|
|
@@ -14954,7 +14936,7 @@ const getWorkData = async function ({
|
|
|
14954
14936
|
*/
|
|
14955
14937
|
const setServiceWorkerDefaults = (target, source) => {
|
|
14956
14938
|
target.userJSON = source.userJSON || 'resources/user.json';
|
|
14957
|
-
target.languages = source.languages || new URL(new URL('assets/languages-
|
|
14939
|
+
target.languages = source.languages || new URL(new URL('assets/languages-DWwAAJMo.json', import.meta.url).href, import.meta.url).href;
|
|
14958
14940
|
target.serviceWorkerPath = source.serviceWorkerPath || `sw.js?pathToUserJSON=${encodeURIComponent(target.userJSON)}&stylesheets=${encodeURIComponent(JSON.stringify(target.stylesheets || []))}`;
|
|
14959
14941
|
target.files = source.files || 'files.json';
|
|
14960
14942
|
target.namespace = source.namespace || 'textbrowser';
|
|
@@ -14965,10 +14947,11 @@ const setServiceWorkerDefaults = (target, source) => {
|
|
|
14965
14947
|
// of new and activation of new or existing if still
|
|
14966
14948
|
// some tabs open)
|
|
14967
14949
|
|
|
14968
|
-
const listenForWorkerUpdate =
|
|
14969
|
-
|
|
14970
|
-
|
|
14971
|
-
|
|
14950
|
+
const listenForWorkerUpdate = _ref => {
|
|
14951
|
+
let {
|
|
14952
|
+
r
|
|
14953
|
+
// logger
|
|
14954
|
+
} = _ref;
|
|
14972
14955
|
r.addEventListener('updatefound', e => {
|
|
14973
14956
|
// New service worker has appeared
|
|
14974
14957
|
// r.installing now available (though r.active is also,
|
|
@@ -15030,18 +15013,20 @@ for offline installation.
|
|
|
15030
15013
|
});
|
|
15031
15014
|
});
|
|
15032
15015
|
};
|
|
15033
|
-
const respondToState = async
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15016
|
+
const respondToState = async _ref2 => {
|
|
15017
|
+
let {
|
|
15018
|
+
r,
|
|
15019
|
+
logger
|
|
15020
|
+
} = _ref2;
|
|
15037
15021
|
// We use this promise for rejecting (inside a listener)
|
|
15038
15022
|
// to a common catch and to prevent continuation by
|
|
15039
15023
|
// failing to return
|
|
15040
15024
|
return new Promise(async () => {
|
|
15041
|
-
// eslint-disable-line no-async-promise-executor
|
|
15042
|
-
navigator.serviceWorker.addEventListener('message',
|
|
15043
|
-
|
|
15044
|
-
|
|
15025
|
+
// eslint-disable-line no-async-promise-executor, sonarjs/no-misused-promises -- See above
|
|
15026
|
+
navigator.serviceWorker.addEventListener('message', _ref3 => {
|
|
15027
|
+
let {
|
|
15028
|
+
data
|
|
15029
|
+
} = _ref3;
|
|
15045
15030
|
const {
|
|
15046
15031
|
message,
|
|
15047
15032
|
type,
|
|
@@ -15162,10 +15147,11 @@ any indication it is installing.
|
|
|
15162
15147
|
|
|
15163
15148
|
// Keep in this file as may wish to avoid using for server (while still
|
|
15164
15149
|
// doing other service worker work)
|
|
15165
|
-
const registerServiceWorker = async
|
|
15166
|
-
|
|
15167
|
-
|
|
15168
|
-
|
|
15150
|
+
const registerServiceWorker = async _ref4 => {
|
|
15151
|
+
let {
|
|
15152
|
+
serviceWorkerPath,
|
|
15153
|
+
logger
|
|
15154
|
+
} = _ref4;
|
|
15169
15155
|
// Todo: We might wish to allow avoiding the other locale files
|
|
15170
15156
|
// and if only one chosen, switch to the work selection page
|
|
15171
15157
|
// in that language
|
|
@@ -15199,6 +15185,7 @@ const registerServiceWorker = async ({
|
|
|
15199
15185
|
r = await navigator.serviceWorker.register(serviceWorkerPath, {
|
|
15200
15186
|
type: 'module'
|
|
15201
15187
|
});
|
|
15188
|
+
// eslint-disable-next-line no-unused-vars -- Ok
|
|
15202
15189
|
} catch (err) {
|
|
15203
15190
|
console.log('serviceWorkerPath', serviceWorkerPath);
|
|
15204
15191
|
await dialogs.alert(`
|
|
@@ -15222,14 +15209,14 @@ const escapeHTML = s => {
|
|
|
15222
15209
|
return !s ? '' : s.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');
|
|
15223
15210
|
};
|
|
15224
15211
|
|
|
15225
|
-
/* eslint-env browser */
|
|
15226
15212
|
var languageSelect = {
|
|
15227
|
-
main({
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15213
|
+
main(_ref) {
|
|
15214
|
+
let {
|
|
15215
|
+
langs,
|
|
15216
|
+
languages,
|
|
15217
|
+
followParams,
|
|
15218
|
+
$p
|
|
15219
|
+
} = _ref;
|
|
15233
15220
|
jml('form', {
|
|
15234
15221
|
class: 'focus',
|
|
15235
15222
|
id: 'languageSelectionContainer',
|
|
@@ -15242,21 +15229,23 @@ var languageSelect = {
|
|
|
15242
15229
|
name: 'lang',
|
|
15243
15230
|
size: langs.length,
|
|
15244
15231
|
$on: {
|
|
15245
|
-
click({
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15232
|
+
click(_ref2) {
|
|
15233
|
+
let {
|
|
15234
|
+
target: {
|
|
15235
|
+
parentNode: {
|
|
15236
|
+
selectedOptions
|
|
15237
|
+
}
|
|
15249
15238
|
}
|
|
15250
|
-
}
|
|
15251
|
-
}) {
|
|
15239
|
+
} = _ref2;
|
|
15252
15240
|
followParams('#languageSelectionContainer', () => {
|
|
15253
15241
|
$p.set('lang', selectedOptions[0].value, true);
|
|
15254
15242
|
});
|
|
15255
15243
|
}
|
|
15256
15244
|
}
|
|
15257
|
-
}, langs.map(
|
|
15258
|
-
|
|
15259
|
-
|
|
15245
|
+
}, langs.map(_ref3 => {
|
|
15246
|
+
let {
|
|
15247
|
+
code
|
|
15248
|
+
} = _ref3;
|
|
15260
15249
|
return ['option', {
|
|
15261
15250
|
value: code
|
|
15262
15251
|
}, [languages.getLanguageFromCode(code)]];
|
|
@@ -15277,14 +15266,14 @@ var languageSelect = {
|
|
|
15277
15266
|
*/
|
|
15278
15267
|
};
|
|
15279
15268
|
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
}
|
|
15269
|
+
const workSelect$1 = function (_ref) {
|
|
15270
|
+
let {
|
|
15271
|
+
groups,
|
|
15272
|
+
workI18n,
|
|
15273
|
+
getNextAlias,
|
|
15274
|
+
$p,
|
|
15275
|
+
followParams
|
|
15276
|
+
} = _ref;
|
|
15288
15277
|
const form = jml('form', {
|
|
15289
15278
|
id: 'workSelect',
|
|
15290
15279
|
class: 'focus',
|
|
@@ -15301,11 +15290,12 @@ var workSelect$1 = (({
|
|
|
15301
15290
|
name: group.name.localeKey
|
|
15302
15291
|
},
|
|
15303
15292
|
$on: {
|
|
15304
|
-
change({
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15293
|
+
change(_ref2) {
|
|
15294
|
+
let {
|
|
15295
|
+
target: {
|
|
15296
|
+
value
|
|
15297
|
+
}
|
|
15298
|
+
} = _ref2;
|
|
15309
15299
|
/*
|
|
15310
15300
|
// If using click, but click doesn't always fire
|
|
15311
15301
|
if (e.target.nodeName.toLowerCase() === 'select') {
|
|
@@ -15319,9 +15309,10 @@ var workSelect$1 = (({
|
|
|
15319
15309
|
}
|
|
15320
15310
|
}, [['option', {
|
|
15321
15311
|
value: ''
|
|
15322
|
-
}, ['--']], ...group.files.map(
|
|
15323
|
-
|
|
15324
|
-
|
|
15312
|
+
}, ['--']], ...group.files.map(_ref3 => {
|
|
15313
|
+
let {
|
|
15314
|
+
name: fileName
|
|
15315
|
+
} = _ref3;
|
|
15325
15316
|
return ['option', {
|
|
15326
15317
|
value: workI18n(['workNames', group.id, fileName])
|
|
15327
15318
|
}, [getNextAlias()]];
|
|
@@ -15334,7 +15325,7 @@ var workSelect$1 = (({
|
|
|
15334
15325
|
deserialize(document.querySelector('#workSelect'), history.state);
|
|
15335
15326
|
}
|
|
15336
15327
|
return form;
|
|
15337
|
-
}
|
|
15328
|
+
};
|
|
15338
15329
|
|
|
15339
15330
|
const colors = ['aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow'];
|
|
15340
15331
|
const fonts = ['Helvetica, sans-serif', 'Verdana, sans-serif', 'Gill Sans, sans-serif', 'Avantgarde, sans-serif', 'Helvetica Narrow, sans-serif', 'sans-serif', 'Times, serif', 'Times New Roman, serif', 'Palatino, serif', 'Bookman, serif', 'New Century Schoolbook, serif', 'serif', 'Andale Mono, monospace', 'Courier New, monospace', 'Courier, monospace', 'Lucidatypewriter, monospace', 'Fixed, monospace', 'monospace', 'Comic Sans, Comic Sans MS, cursive', 'Zapf Chancery, cursive', 'Coronetscript, cursive', 'Florence, cursive', 'Parkavenue, cursive', 'cursive', 'Impact, fantasy', 'Arnoldboecklin, fantasy', 'Oldtown, fantasy', 'Blippo, fantasy', 'Brushstroke, fantasy', 'fantasy'];
|
|
@@ -15349,10 +15340,11 @@ const getDataForSerializingParamsAsURL = () => ({
|
|
|
15349
15340
|
checkboxes: $$('input[type=checkbox]')
|
|
15350
15341
|
});
|
|
15351
15342
|
var workDisplay$1 = {
|
|
15352
|
-
bdo({
|
|
15353
|
-
|
|
15354
|
-
|
|
15355
|
-
|
|
15343
|
+
bdo(_ref) {
|
|
15344
|
+
let {
|
|
15345
|
+
fallbackDirection,
|
|
15346
|
+
message
|
|
15347
|
+
} = _ref;
|
|
15356
15348
|
// Displaying as div with inline display instead of span since
|
|
15357
15349
|
// Firefox puts punctuation at left otherwise (bdo dir
|
|
15358
15350
|
// seemed to have issues in Firefox)
|
|
@@ -15360,355 +15352,366 @@ var workDisplay$1 = {
|
|
|
15360
15352
|
style: 'display: inline; direction: ' + fallbackDirection
|
|
15361
15353
|
}, [message]];
|
|
15362
15354
|
},
|
|
15363
|
-
columnsTable:
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
,
|
|
15383
|
-
['th', [
|
|
15384
|
-
lDirectional('fieldsearch')
|
|
15385
|
-
]]
|
|
15386
|
-
*/]], ...fieldInfo.map((fieldInfoItem, i) => {
|
|
15387
|
-
const idx = i + 1;
|
|
15388
|
-
const checkedIndex = 'checked' + idx;
|
|
15389
|
-
const fieldIndex = 'field' + idx;
|
|
15390
|
-
const fieldParam = $p.get(fieldIndex);
|
|
15391
|
-
return ['tr', [
|
|
15392
|
-
// Todo: Get Jamilih to accept numbers and
|
|
15393
|
-
// booleans (`toString` is too dangerous)
|
|
15394
|
-
['td', [String(idx)]], lElement('check-columns-to-browse', 'td', 'title', {}, [lElement('yes', 'input', 'value', {
|
|
15395
|
-
class: 'fieldSelector',
|
|
15396
|
-
id: checkedIndex,
|
|
15397
|
-
name: lIndexedParam('checked') + idx,
|
|
15398
|
-
checked: $p.get(checkedIndex) !== l('no') && ($p.has(checkedIndex) || fieldInfoItem.onByDefault !== false),
|
|
15399
|
-
type: 'checkbox'
|
|
15400
|
-
})]), lElement('check-sequence', 'td', 'title', {}, [['select', {
|
|
15401
|
-
name: lIndexedParam('field') + idx,
|
|
15402
|
-
id: fieldIndex,
|
|
15403
|
-
size: '1'
|
|
15404
|
-
}, fieldInfo.map(({
|
|
15405
|
-
field,
|
|
15406
|
-
fieldAliasOrName
|
|
15407
|
-
}, j) => {
|
|
15408
|
-
const matchedFieldParam = fieldParam && fieldParam === fieldAliasOrName;
|
|
15409
|
-
return ['option', {
|
|
15410
|
-
dataset: {
|
|
15411
|
-
name: field
|
|
15412
|
-
},
|
|
15413
|
-
value: fieldAliasOrName,
|
|
15414
|
-
selected: matchedFieldParam || j === i && !$p.has(fieldIndex)
|
|
15415
|
-
}, [fieldAliasOrName]];
|
|
15416
|
-
})]]), ['td', [
|
|
15417
|
-
// Todo: Make as tag selector with fields as options
|
|
15418
|
-
lElement('interlinear-tips', 'input', 'title', {
|
|
15419
|
-
name: lIndexedParam('interlin') + idx,
|
|
15420
|
-
value: $p.get('interlin' + idx)
|
|
15421
|
-
}) // Todo: Could allow i18n of numbers here
|
|
15422
|
-
]], ['td', [
|
|
15423
|
-
// Todo: Make as CodeMirror-highlighted CSS
|
|
15424
|
-
['input', {
|
|
15425
|
-
name: lIndexedParam('css') + idx,
|
|
15426
|
-
value: $p.get('css' + idx)
|
|
15427
|
-
}]]]
|
|
15355
|
+
columnsTable: _ref2 => {
|
|
15356
|
+
let {
|
|
15357
|
+
lDirectional,
|
|
15358
|
+
fieldInfo,
|
|
15359
|
+
$p,
|
|
15360
|
+
lElement,
|
|
15361
|
+
lIndexedParam,
|
|
15362
|
+
l,
|
|
15363
|
+
// metadataObj, preferredLocale, schemaItems,
|
|
15364
|
+
fieldMatchesLocale
|
|
15365
|
+
} = _ref2;
|
|
15366
|
+
return ['table', {
|
|
15367
|
+
border: '1',
|
|
15368
|
+
cellpadding: '5',
|
|
15369
|
+
align: 'center'
|
|
15370
|
+
}, [['tr', [['th', [lDirectional('fieldno')]], ['th', {
|
|
15371
|
+
align: 'left',
|
|
15372
|
+
width: '20'
|
|
15373
|
+
}, [lDirectional('field_enabled')]], ['th', [lDirectional('field_title')]], ['th', [lDirectional('fieldinterlin')]], ['th', [lDirectional('fieldcss')]]
|
|
15428
15374
|
/*
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15375
|
+
Todo: Support search?
|
|
15376
|
+
,
|
|
15377
|
+
['th', [
|
|
15378
|
+
lDirectional('fieldsearch')
|
|
15379
|
+
]]
|
|
15380
|
+
*/]], ...fieldInfo.map((fieldInfoItem, i) => {
|
|
15381
|
+
const idx = i + 1;
|
|
15382
|
+
const checkedIndex = 'checked' + idx;
|
|
15383
|
+
const fieldIndex = 'field' + idx;
|
|
15384
|
+
const fieldParam = $p.get(fieldIndex);
|
|
15385
|
+
return ['tr', [
|
|
15386
|
+
// Todo: Get Jamilih to accept numbers and
|
|
15387
|
+
// booleans (`toString` is too dangerous)
|
|
15388
|
+
['td', [String(idx)]], lElement('check-columns-to-browse', 'td', 'title', {}, [lElement('yes', 'input', 'value', {
|
|
15389
|
+
class: 'fieldSelector',
|
|
15390
|
+
id: checkedIndex,
|
|
15391
|
+
name: lIndexedParam('checked') + idx,
|
|
15392
|
+
checked: $p.get(checkedIndex) !== l('no') && ($p.has(checkedIndex) || fieldInfoItem.onByDefault !== false),
|
|
15393
|
+
type: 'checkbox'
|
|
15394
|
+
})]), lElement('check-sequence', 'td', 'title', {}, [['select', {
|
|
15395
|
+
name: lIndexedParam('field') + idx,
|
|
15396
|
+
id: fieldIndex,
|
|
15397
|
+
size: '1'
|
|
15398
|
+
}, fieldInfo.map((_ref3, j) => {
|
|
15399
|
+
let {
|
|
15400
|
+
field,
|
|
15401
|
+
fieldAliasOrName
|
|
15402
|
+
} = _ref3;
|
|
15403
|
+
const matchedFieldParam = fieldParam && fieldParam === fieldAliasOrName;
|
|
15404
|
+
return ['option', {
|
|
15405
|
+
dataset: {
|
|
15406
|
+
name: field
|
|
15407
|
+
},
|
|
15408
|
+
value: fieldAliasOrName,
|
|
15409
|
+
selected: matchedFieldParam || j === i && !$p.has(fieldIndex)
|
|
15410
|
+
}, [fieldAliasOrName]];
|
|
15411
|
+
})]]), ['td', [
|
|
15412
|
+
// Todo: Make as tag selector with fields as options
|
|
15413
|
+
lElement('interlinear-tips', 'input', 'title', {
|
|
15414
|
+
name: lIndexedParam('interlin') + idx,
|
|
15415
|
+
value: $p.get('interlin' + idx)
|
|
15416
|
+
}) // Todo: Could allow i18n of numbers here
|
|
15417
|
+
]], ['td', [
|
|
15418
|
+
// Todo: Make as CodeMirror-highlighted CSS
|
|
15419
|
+
['input', {
|
|
15420
|
+
name: lIndexedParam('css') + idx,
|
|
15421
|
+
value: $p.get('css' + idx)
|
|
15422
|
+
}]]]
|
|
15423
|
+
/*
|
|
15424
|
+
,
|
|
15425
|
+
['td', [ // Todo: Allow plain or regexp searching
|
|
15426
|
+
['input', {name: lIndexedParam('search') + idx, value: $p.get('search' + idx)}]
|
|
15427
|
+
]]
|
|
15428
|
+
*/]];
|
|
15429
|
+
}), ['tr', [['td', {
|
|
15430
|
+
colspan: 3
|
|
15431
|
+
}, [lElement('check_all', 'input', 'value', {
|
|
15432
|
+
type: 'button',
|
|
15433
|
+
$on: {
|
|
15434
|
+
click() {
|
|
15435
|
+
$$('.fieldSelector').forEach(checkbox => {
|
|
15436
|
+
checkbox.checked = true;
|
|
15437
|
+
});
|
|
15438
|
+
}
|
|
15443
15439
|
}
|
|
15444
|
-
}
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
}
|
|
15440
|
+
}), lElement('uncheck_all', 'input', 'value', {
|
|
15441
|
+
type: 'button',
|
|
15442
|
+
$on: {
|
|
15443
|
+
click() {
|
|
15444
|
+
$$('.fieldSelector').forEach(checkbox => {
|
|
15445
|
+
checkbox.checked = false;
|
|
15446
|
+
});
|
|
15447
|
+
}
|
|
15452
15448
|
}
|
|
15453
|
-
}
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
|
|
15461
|
-
|
|
15462
|
-
|
|
15463
|
-
|
|
15464
|
-
}
|
|
15449
|
+
}), lElement('checkmark_locale_fields_only', 'input', 'value', {
|
|
15450
|
+
type: 'button',
|
|
15451
|
+
$on: {
|
|
15452
|
+
click() {
|
|
15453
|
+
fieldInfo.forEach((/* {field} */_, i) => {
|
|
15454
|
+
const idx = i + 1;
|
|
15455
|
+
// The following is redundant with 'field' but may need to
|
|
15456
|
+
// retrieve later out of order?
|
|
15457
|
+
const fld = $$1('#field' + idx).selectedOptions[0].dataset.name;
|
|
15458
|
+
$$1('#checked' + idx).checked = fieldMatchesLocale(fld);
|
|
15459
|
+
});
|
|
15460
|
+
}
|
|
15465
15461
|
}
|
|
15466
|
-
}
|
|
15467
|
-
}
|
|
15468
|
-
advancedFormatting:
|
|
15469
|
-
|
|
15470
|
-
|
|
15471
|
-
|
|
15472
|
-
|
|
15473
|
-
|
|
15474
|
-
|
|
15475
|
-
|
|
15476
|
-
|
|
15477
|
-
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
|
|
15481
|
-
|
|
15482
|
-
|
|
15483
|
-
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
|
|
15535
|
-
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15544
|
-
checked: $p.get('fontvariant') !== lDirectional(['param_values', 'fontvariant', 'small-caps'])
|
|
15545
|
-
}], lDirectional(['param_values', 'fontvariant', 'normal']), nbsp]], ['label', [['input', {
|
|
15546
|
-
name: lParam('fontvariant'),
|
|
15547
|
-
type: 'radio',
|
|
15548
|
-
value: l(['param_values', 'fontvariant', 'small-caps']),
|
|
15549
|
-
checked: $p.get('fontvariant') === lDirectional(['param_values', 'fontvariant', 'small-caps'])
|
|
15550
|
-
}], lDirectional(['param_values', 'fontvariant', 'small-caps']), nbsp]]]], ['br'], ['label', [
|
|
15551
|
-
// Todo: i18n and allow for normal/bold pulldown and float input?
|
|
15552
|
-
lDirectional('font_weight'), ' (normal, bold, 100-900, etc.):', nbsp2, ['input', {
|
|
15553
|
-
name: lParam('fontweight'),
|
|
15554
|
-
type: 'text',
|
|
15555
|
-
value: $p.has('fontweight') ? $p.get('fontweight') : 'normal',
|
|
15556
|
-
size: '7',
|
|
15557
|
-
maxlength: '12'
|
|
15558
|
-
}]]], ['br'], ['label', [lDirectional('font_size'), ' (14pt, 14px, small, 75%, etc.):', nbsp2, ['input', {
|
|
15559
|
-
name: lParam('fontsize'),
|
|
15560
|
-
type: 'text',
|
|
15561
|
-
value: $p.get('fontsize'),
|
|
15562
|
-
size: '7',
|
|
15563
|
-
maxlength: '12'
|
|
15564
|
-
}]]], ['br'],
|
|
15565
|
-
// Todo: i18nize title and values?
|
|
15566
|
-
// Todo: remove hard-coded direction if i18nizing
|
|
15567
|
-
['label', {
|
|
15568
|
-
dir: 'ltr'
|
|
15569
|
-
}, [lDirectional('font_stretch'), nbsp, ['select', {
|
|
15570
|
-
name: lParam('fontstretch')
|
|
15571
|
-
}, ['ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'].map(stretch => {
|
|
15572
|
-
const atts = {
|
|
15573
|
-
value: lDirectional(['param_values', 'font-stretch', stretch]),
|
|
15574
|
-
selected: null
|
|
15575
|
-
};
|
|
15576
|
-
if ($p.get('fontstretch') === stretch || !$p.has('fontstretch') && stretch === 'normal') {
|
|
15577
|
-
atts.selected = 'selected';
|
|
15578
|
-
}
|
|
15579
|
-
return ['option', atts, [lDirectional(['param_values', 'font-stretch', stretch])]];
|
|
15580
|
-
})]]], /**/
|
|
15581
|
-
['br'], ['br'], ['label', [lDirectional('letter_spacing'), ' (normal, .9em, -.05cm): ', ['input', {
|
|
15582
|
-
name: lParam('letterspacing'),
|
|
15583
|
-
type: 'text',
|
|
15584
|
-
value: $p.has('letterspacing') ? $p.get('letterspacing') : 'normal',
|
|
15585
|
-
size: '7',
|
|
15586
|
-
maxlength: '12'
|
|
15587
|
-
}]]], ['br'], ['label', [lDirectional('line_height'), ' (normal, 1.5, 22px, 150%): ', ['input', {
|
|
15588
|
-
name: lParam('lineheight'),
|
|
15589
|
-
type: 'text',
|
|
15590
|
-
value: $p.has('lineheight') ? $p.get('lineheight') : 'normal',
|
|
15591
|
-
size: '7',
|
|
15592
|
-
maxlength: '12'
|
|
15593
|
-
}]]], ['br'], ['br'], lElement('tableformatting_tips', 'h3', 'title', {}, [lDirectional('tableformatting')]), ['div', [lDirectional('header_wstyles'), nbsp2, ...[['yes', lDirectional(['param_values', 'y'])], ['no', lDirectional(['param_values', 'n'])], ['none', lDirectional(['param_values', '0'])]].map(([key, val], i, arr) => {
|
|
15594
|
-
return ['label', [['input', {
|
|
15595
|
-
name: lParam('header'),
|
|
15462
|
+
})]]]]]];
|
|
15463
|
+
},
|
|
15464
|
+
advancedFormatting: _ref4 => {
|
|
15465
|
+
let {
|
|
15466
|
+
lDirectional,
|
|
15467
|
+
lParam,
|
|
15468
|
+
l,
|
|
15469
|
+
lOption,
|
|
15470
|
+
lElement,
|
|
15471
|
+
$p,
|
|
15472
|
+
hideFormattingSection
|
|
15473
|
+
} = _ref4;
|
|
15474
|
+
return ['td', {
|
|
15475
|
+
id: 'advancedformatting',
|
|
15476
|
+
style: {
|
|
15477
|
+
display: hideFormattingSection ? 'none' : 'block'
|
|
15478
|
+
}
|
|
15479
|
+
}, [['h3', [lDirectional('advancedformatting')]], ['label', [lDirectional('textcolor'), nbsp2, ['select', {
|
|
15480
|
+
name: lParam('colorName')
|
|
15481
|
+
}, colors.map((color, i) => {
|
|
15482
|
+
const atts = {
|
|
15483
|
+
value: l(['param_values', 'colors', color]),
|
|
15484
|
+
selected: null
|
|
15485
|
+
};
|
|
15486
|
+
if ($p.get('colorName') === l(['param_values', 'colors', color]) || i === 1 && !$p.has('colorName')) {
|
|
15487
|
+
atts.selected = 'selected';
|
|
15488
|
+
}
|
|
15489
|
+
return lOption(['param_values', 'colors', color], atts);
|
|
15490
|
+
})]]], ['label', [nbsp, lDirectional('or_entercolor'), nbsp2, ['input', {
|
|
15491
|
+
name: lParam('color'),
|
|
15492
|
+
type: 'text',
|
|
15493
|
+
value: $p.get('color') || '#',
|
|
15494
|
+
size: '7',
|
|
15495
|
+
maxlength: '7'
|
|
15496
|
+
}]]], ['br'], ['br'], ['label', [lDirectional('backgroundcolor'), nbsp2, ['select', {
|
|
15497
|
+
name: lParam('bgcolorName')
|
|
15498
|
+
}, colors.map((color, i) => {
|
|
15499
|
+
const atts = {
|
|
15500
|
+
value: l(['param_values', 'colors', color]),
|
|
15501
|
+
selected: null
|
|
15502
|
+
};
|
|
15503
|
+
if ($p.get('bgcolorName') === l(['param_values', 'colors', color]) || i === 14 && !$p.has('bgcolorName')) {
|
|
15504
|
+
atts.selected = 'selected';
|
|
15505
|
+
}
|
|
15506
|
+
return lOption(['param_values', 'colors', color], atts);
|
|
15507
|
+
})]]], ['label', [nbsp, lDirectional('or_entercolor'), nbsp2, ['input', {
|
|
15508
|
+
name: lParam('bgcolor'),
|
|
15509
|
+
type: 'text',
|
|
15510
|
+
value: $p.get('bgcolor') || '#',
|
|
15511
|
+
size: '7',
|
|
15512
|
+
maxlength: '7'
|
|
15513
|
+
}]]], ['br'], ['br'], ['label', [lDirectional('text_font'), nbsp2,
|
|
15514
|
+
// Todo: remove hard-coded direction if i81nizing; also i18nize fontSeq param
|
|
15515
|
+
['select', {
|
|
15516
|
+
name: lParam('fontSeq'),
|
|
15517
|
+
dir: 'ltr'
|
|
15518
|
+
}, fonts.map((fontSeq, i) => {
|
|
15519
|
+
const atts = {
|
|
15520
|
+
value: fontSeq,
|
|
15521
|
+
selected: null
|
|
15522
|
+
};
|
|
15523
|
+
if ($p.get('fontSeq') === fontSeq || i === 7 && !$p.has('fontSeq')) {
|
|
15524
|
+
atts.selected = 'selected';
|
|
15525
|
+
}
|
|
15526
|
+
return ['option', atts, [fontSeq]];
|
|
15527
|
+
})]]], ['br'], ['br'], ['label', [lDirectional('font_style'), nbsp2, ['select', {
|
|
15528
|
+
name: lParam('fontstyle')
|
|
15529
|
+
}, ['italic', 'normal', 'oblique'].map((fontstyle, i) => {
|
|
15530
|
+
const atts = {
|
|
15531
|
+
value: l(['param_values', 'fontstyle', fontstyle]),
|
|
15532
|
+
selected: null
|
|
15533
|
+
};
|
|
15534
|
+
if ($p.get('fontstyle') === l(['param_values', 'fontstyle', fontstyle]) || i === 1 && !$p.has('fontstyle')) {
|
|
15535
|
+
atts.selected = 'selected';
|
|
15536
|
+
}
|
|
15537
|
+
return lOption(['param_values', 'fontstyle', fontstyle], atts);
|
|
15538
|
+
})]]], ['br'], ['div', [lDirectional('font_variant'), nbsp3, ['label', [['input', {
|
|
15539
|
+
name: lParam('fontvariant'),
|
|
15596
15540
|
type: 'radio',
|
|
15597
|
-
value:
|
|
15598
|
-
checked: $p.get('
|
|
15599
|
-
}], lDirectional(
|
|
15600
|
-
|
|
15601
|
-
return ['label', [['input', {
|
|
15602
|
-
name: lParam('footer'),
|
|
15541
|
+
value: l(['param_values', 'fontvariant', 'normal']),
|
|
15542
|
+
checked: $p.get('fontvariant') !== lDirectional(['param_values', 'fontvariant', 'small-caps'])
|
|
15543
|
+
}], lDirectional(['param_values', 'fontvariant', 'normal']), nbsp]], ['label', [['input', {
|
|
15544
|
+
name: lParam('fontvariant'),
|
|
15603
15545
|
type: 'radio',
|
|
15604
|
-
value:
|
|
15605
|
-
checked: $p.get('
|
|
15606
|
-
}], lDirectional(
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15612
|
-
|
|
15613
|
-
|
|
15614
|
-
|
|
15546
|
+
value: l(['param_values', 'fontvariant', 'small-caps']),
|
|
15547
|
+
checked: $p.get('fontvariant') === lDirectional(['param_values', 'fontvariant', 'small-caps'])
|
|
15548
|
+
}], lDirectional(['param_values', 'fontvariant', 'small-caps']), nbsp]]]], ['br'], ['label', [
|
|
15549
|
+
// Todo: i18n and allow for normal/bold pulldown and float input?
|
|
15550
|
+
lDirectional('font_weight'), ' (normal, bold, 100-900, etc.):', nbsp2, ['input', {
|
|
15551
|
+
name: lParam('fontweight'),
|
|
15552
|
+
type: 'text',
|
|
15553
|
+
value: $p.has('fontweight') ? $p.get('fontweight') : 'normal',
|
|
15554
|
+
size: '7',
|
|
15555
|
+
maxlength: '12'
|
|
15556
|
+
}]]], ['br'], ['label', [lDirectional('font_size'), ' (14pt, 14px, small, 75%, etc.):', nbsp2, ['input', {
|
|
15557
|
+
name: lParam('fontsize'),
|
|
15558
|
+
type: 'text',
|
|
15559
|
+
value: $p.get('fontsize'),
|
|
15560
|
+
size: '7',
|
|
15561
|
+
maxlength: '12'
|
|
15562
|
+
}]]], ['br'],
|
|
15563
|
+
// Todo: i18nize title and values?
|
|
15564
|
+
// Todo: remove hard-coded direction if i18nizing
|
|
15565
|
+
['label', {
|
|
15566
|
+
dir: 'ltr'
|
|
15567
|
+
}, [lDirectional('font_stretch'), nbsp, ['select', {
|
|
15568
|
+
name: lParam('fontstretch')
|
|
15569
|
+
}, ['ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'].map(stretch => {
|
|
15570
|
+
const atts = {
|
|
15571
|
+
value: lDirectional(['param_values', 'font-stretch', stretch]),
|
|
15572
|
+
selected: null
|
|
15573
|
+
};
|
|
15574
|
+
if ($p.get('fontstretch') === stretch || !$p.has('fontstretch') && stretch === 'normal') {
|
|
15575
|
+
atts.selected = 'selected';
|
|
15576
|
+
}
|
|
15577
|
+
return ['option', atts, [lDirectional(['param_values', 'font-stretch', stretch])]];
|
|
15578
|
+
})]]], /**/
|
|
15579
|
+
['br'], ['br'], ['label', [lDirectional('letter_spacing'), ' (normal, .9em, -.05cm): ', ['input', {
|
|
15580
|
+
name: lParam('letterspacing'),
|
|
15581
|
+
type: 'text',
|
|
15582
|
+
value: $p.has('letterspacing') ? $p.get('letterspacing') : 'normal',
|
|
15583
|
+
size: '7',
|
|
15584
|
+
maxlength: '12'
|
|
15585
|
+
}]]], ['br'], ['label', [lDirectional('line_height'), ' (normal, 1.5, 22px, 150%): ', ['input', {
|
|
15586
|
+
name: lParam('lineheight'),
|
|
15587
|
+
type: 'text',
|
|
15588
|
+
value: $p.has('lineheight') ? $p.get('lineheight') : 'normal',
|
|
15589
|
+
size: '7',
|
|
15590
|
+
maxlength: '12'
|
|
15591
|
+
}]]], ['br'], ['br'], lElement('tableformatting_tips', 'h3', 'title', {}, [lDirectional('tableformatting')]), ['div', [lDirectional('header_wstyles'), nbsp2, ...[['yes', lDirectional(['param_values', 'y'])], ['no', lDirectional(['param_values', 'n'])], ['none', lDirectional(['param_values', '0'])]].map((_ref5, i, arr) => {
|
|
15592
|
+
let [key, val] = _ref5;
|
|
15593
|
+
return ['label', [['input', {
|
|
15594
|
+
name: lParam('header'),
|
|
15595
|
+
type: 'radio',
|
|
15596
|
+
value: val,
|
|
15597
|
+
checked: $p.get('header') === val || !$p.has('header') && i === 1
|
|
15598
|
+
}], lDirectional(key), i === arr.length - 1 ? '' : nbsp3]];
|
|
15599
|
+
})]], ['div', [lDirectional('footer_wstyles'), nbsp2, ...[['yes', lDirectional(['param_values', 'y'])], ['no', lDirectional(['param_values', 'n'])], ['none', lDirectional(['param_values', '0'])]].map((_ref6, i, arr) => {
|
|
15600
|
+
let [key, val] = _ref6;
|
|
15601
|
+
return ['label', [['input', {
|
|
15602
|
+
name: lParam('footer'),
|
|
15603
|
+
type: 'radio',
|
|
15604
|
+
value: val,
|
|
15605
|
+
checked: $p.get('footer') === val || !$p.has('footer') && i === 2
|
|
15606
|
+
}], lDirectional(key), i === arr.length - 1 ? '' : nbsp3]];
|
|
15607
|
+
})]], ['label', [['input', {
|
|
15608
|
+
name: lParam('headerfooterfixed'),
|
|
15609
|
+
type: 'checkbox',
|
|
15610
|
+
value: l('yes'),
|
|
15611
|
+
checked: $p.get('headerfooterfixed') === l('yes')
|
|
15612
|
+
}], nbsp2, lDirectional('headerfooterfixed-wishtoscroll')]], ['br'], ['div', [lDirectional('caption_wstyles'), nbsp2, ...[['yes', lDirectional(['param_values', 'y'])], ['no', lDirectional(['param_values', 'n'])], ['none', lDirectional(['param_values', '0'])]].map((_ref7, i, arr) => {
|
|
15613
|
+
let [key, val] = _ref7;
|
|
15614
|
+
return ['label', [['input', {
|
|
15615
|
+
name: lParam('caption'),
|
|
15616
|
+
type: 'radio',
|
|
15617
|
+
value: val,
|
|
15618
|
+
checked: $p.get('caption') === val || !$p.has('caption') && i === 2
|
|
15619
|
+
}], lDirectional(key), i === arr.length - 1 ? '' : nbsp3]];
|
|
15620
|
+
})]], ['br'], ['div', [lDirectional('table_wborder'), nbsp2, ['label', [['input', {
|
|
15621
|
+
name: lParam('border'),
|
|
15615
15622
|
type: 'radio',
|
|
15616
|
-
value:
|
|
15617
|
-
checked: $p.get('
|
|
15618
|
-
}], lDirectional(
|
|
15619
|
-
|
|
15620
|
-
|
|
15621
|
-
|
|
15622
|
-
|
|
15623
|
-
|
|
15624
|
-
|
|
15625
|
-
|
|
15626
|
-
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
|
|
15680
|
-
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15686
|
-
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
$p,
|
|
15709
|
-
serializeParamsAsURL,
|
|
15710
|
-
content
|
|
15711
|
-
}) {
|
|
15623
|
+
value: '1',
|
|
15624
|
+
checked: $p.get('border') !== '0'
|
|
15625
|
+
}], lDirectional('yes'), nbsp3]], ['label', [['input', {
|
|
15626
|
+
name: lParam('border'),
|
|
15627
|
+
type: 'radio',
|
|
15628
|
+
value: '0',
|
|
15629
|
+
checked: $p.get('border') === '0'
|
|
15630
|
+
}], lDirectional('no')]]]], ['div', [lDirectional('interlin_repeat_field_names'), nbsp2, ['label', [['input', {
|
|
15631
|
+
name: lParam('interlintitle'),
|
|
15632
|
+
type: 'radio',
|
|
15633
|
+
value: '1',
|
|
15634
|
+
checked: $p.get('interlintitle') !== '0'
|
|
15635
|
+
}], lDirectional('yes'), nbsp3]], ['label', [['input', {
|
|
15636
|
+
name: lParam('interlintitle'),
|
|
15637
|
+
type: 'radio',
|
|
15638
|
+
value: '0',
|
|
15639
|
+
checked: $p.get('interlintitle') === '0'
|
|
15640
|
+
}], lDirectional('no')]]]], ['label', [lDirectional('interlintitle_css'), nbsp2, ['input', {
|
|
15641
|
+
name: lParam('interlintitle_css'),
|
|
15642
|
+
type: 'text',
|
|
15643
|
+
value: $p.get('interlintitle_css') || '',
|
|
15644
|
+
size: '12'
|
|
15645
|
+
}]]], ['br'],
|
|
15646
|
+
/*
|
|
15647
|
+
['br'],
|
|
15648
|
+
['label', [
|
|
15649
|
+
['input', {
|
|
15650
|
+
name: lParam('transpose'),
|
|
15651
|
+
type: 'checkbox',
|
|
15652
|
+
value: l('yes'),
|
|
15653
|
+
checked: $p.get('transpose') === l('yes')
|
|
15654
|
+
}],
|
|
15655
|
+
nbsp2, lDirectional('transpose')
|
|
15656
|
+
]],
|
|
15657
|
+
*/
|
|
15658
|
+
['br'], lElement('pageformatting_tips', 'h3', 'title', {}, [lDirectional('pageformatting')]),
|
|
15659
|
+
/*
|
|
15660
|
+
['label', [
|
|
15661
|
+
lDirectional('speech_controls'), nbsp2,
|
|
15662
|
+
['label', [
|
|
15663
|
+
['input', {
|
|
15664
|
+
name: lParam('speech'),
|
|
15665
|
+
type: 'radio',
|
|
15666
|
+
value: '1',
|
|
15667
|
+
checked: $p.get('speech') === '1'
|
|
15668
|
+
}],
|
|
15669
|
+
lDirectional('yes'), nbsp3
|
|
15670
|
+
]],
|
|
15671
|
+
['label', [
|
|
15672
|
+
['input', {
|
|
15673
|
+
name: lParam('speech'),
|
|
15674
|
+
type: 'radio',
|
|
15675
|
+
value: '0',
|
|
15676
|
+
checked: $p.get('speech') !== '1'
|
|
15677
|
+
}],
|
|
15678
|
+
lDirectional('no')
|
|
15679
|
+
]]
|
|
15680
|
+
]],
|
|
15681
|
+
['br'],
|
|
15682
|
+
*/
|
|
15683
|
+
['label', [lDirectional('page_css'), nbsp2, ['textarea', {
|
|
15684
|
+
name: lParam('pagecss'),
|
|
15685
|
+
title: l('page_css_tips'),
|
|
15686
|
+
value: $p.get('pagecss')
|
|
15687
|
+
}]]], ['br'], lElement('outputmode_tips', 'label', 'title', {}, [lDirectional('outputmode'), nbsp2,
|
|
15688
|
+
// Todo: Could i18nize, but would need smaller values
|
|
15689
|
+
['select', {
|
|
15690
|
+
name: lParam('outputmode')
|
|
15691
|
+
}, ['table', 'div'
|
|
15692
|
+
// , 'json-array',
|
|
15693
|
+
// 'json-object'
|
|
15694
|
+
].map(mode => {
|
|
15695
|
+
const atts = {
|
|
15696
|
+
value: mode,
|
|
15697
|
+
selected: null
|
|
15698
|
+
};
|
|
15699
|
+
if ($p.get('outputmode') === mode) {
|
|
15700
|
+
atts.selected = 'selected';
|
|
15701
|
+
}
|
|
15702
|
+
return lOption(['param_values', 'outputmode', mode], atts);
|
|
15703
|
+
})]])]];
|
|
15704
|
+
},
|
|
15705
|
+
addRandomFormFields(_ref8) {
|
|
15706
|
+
let {
|
|
15707
|
+
lParam,
|
|
15708
|
+
lDirectional,
|
|
15709
|
+
l,
|
|
15710
|
+
lElement,
|
|
15711
|
+
$p,
|
|
15712
|
+
serializeParamsAsURL,
|
|
15713
|
+
content
|
|
15714
|
+
} = _ref8;
|
|
15712
15715
|
const addRowContent = rowContent => {
|
|
15713
15716
|
if (!rowContent || !rowContent.length) {
|
|
15714
15717
|
return;
|
|
@@ -15739,9 +15742,10 @@ var workDisplay$1 = {
|
|
|
15739
15742
|
type: 'button',
|
|
15740
15743
|
$on: {
|
|
15741
15744
|
click() {
|
|
15742
|
-
const url = serializeParamsAsURL(
|
|
15745
|
+
const url = serializeParamsAsURL({
|
|
15746
|
+
...getDataForSerializingParamsAsURL(),
|
|
15743
15747
|
type: 'randomResult'
|
|
15744
|
-
})
|
|
15748
|
+
});
|
|
15745
15749
|
$$1('#randomURL').value = url;
|
|
15746
15750
|
}
|
|
15747
15751
|
}
|
|
@@ -15750,102 +15754,109 @@ var workDisplay$1 = {
|
|
|
15750
15754
|
type: 'text'
|
|
15751
15755
|
}]]]]].forEach(addRowContent);
|
|
15752
15756
|
},
|
|
15753
|
-
getPreferences:
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15757
|
+
getPreferences: _ref9 => {
|
|
15758
|
+
let {
|
|
15759
|
+
// languageParam, workI18n, groups,
|
|
15760
|
+
paramsSetter,
|
|
15761
|
+
replaceHash,
|
|
15762
|
+
getFieldAliasOrNames,
|
|
15763
|
+
work,
|
|
15764
|
+
langs,
|
|
15765
|
+
languageI18n,
|
|
15766
|
+
l,
|
|
15767
|
+
localizeParamNames,
|
|
15768
|
+
namespace,
|
|
15769
|
+
hideFormattingSection,
|
|
15770
|
+
preferencesPlugin
|
|
15771
|
+
} = _ref9;
|
|
15772
|
+
return ['div', {
|
|
15773
|
+
style: {
|
|
15774
|
+
textAlign: 'left'
|
|
15775
|
+
},
|
|
15776
|
+
id: 'preferences',
|
|
15777
|
+
hidden: 'true'
|
|
15778
|
+
}, [['div', {
|
|
15779
|
+
style: 'margin-top: 10px;'
|
|
15780
|
+
}, [['label', [l('localizeParamNames'), ['input', {
|
|
15781
|
+
id: 'localizeParamNames',
|
|
15782
|
+
type: 'checkbox',
|
|
15783
|
+
checked: localizeParamNames,
|
|
15784
|
+
$on: {
|
|
15785
|
+
change(_ref10) {
|
|
15786
|
+
let {
|
|
15787
|
+
target: {
|
|
15788
|
+
checked
|
|
15789
|
+
}
|
|
15790
|
+
} = _ref10;
|
|
15791
|
+
localStorage.setItem(namespace + '-localizeParamNames', checked);
|
|
15782
15792
|
}
|
|
15783
|
-
}) {
|
|
15784
|
-
localStorage.setItem(namespace + '-localizeParamNames', checked);
|
|
15785
15793
|
}
|
|
15786
|
-
}
|
|
15787
|
-
|
|
15788
|
-
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15794
|
+
}]]]]], ['div', [['label', [l('Hide formatting section'), ['input', {
|
|
15795
|
+
id: 'hideFormattingSection',
|
|
15796
|
+
type: 'checkbox',
|
|
15797
|
+
checked: hideFormattingSection,
|
|
15798
|
+
$on: {
|
|
15799
|
+
change(_ref11) {
|
|
15800
|
+
let {
|
|
15801
|
+
target: {
|
|
15802
|
+
checked
|
|
15803
|
+
}
|
|
15804
|
+
} = _ref11;
|
|
15805
|
+
$$1('#advancedformatting').style.display = checked ? 'none' : 'block';
|
|
15806
|
+
localStorage.setItem(namespace + '-hideFormattingSection', checked);
|
|
15795
15807
|
}
|
|
15796
|
-
}) {
|
|
15797
|
-
$$1('#advancedformatting').style.display = checked ? 'none' : 'block';
|
|
15798
|
-
localStorage.setItem(namespace + '-hideFormattingSection', checked);
|
|
15799
15808
|
}
|
|
15800
|
-
}
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15804
|
-
|
|
15805
|
-
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15814
|
-
|
|
15815
|
-
|
|
15816
|
-
|
|
15809
|
+
}]]]]], ['div', [['label', {
|
|
15810
|
+
for: 'prefLangs'
|
|
15811
|
+
}, [l('Preferred language(s)')]], ['br'], ['select', {
|
|
15812
|
+
id: 'prefLangs',
|
|
15813
|
+
multiple: 'multiple',
|
|
15814
|
+
size: langs.length,
|
|
15815
|
+
$on: {
|
|
15816
|
+
change(_ref12) {
|
|
15817
|
+
let {
|
|
15818
|
+
target: {
|
|
15819
|
+
selectedOptions
|
|
15820
|
+
}
|
|
15821
|
+
} = _ref12;
|
|
15822
|
+
// Todo: EU disclaimer re: storage?
|
|
15823
|
+
localStorage.setItem(namespace + '-langCodes', JSON.stringify([...selectedOptions].map(opt => {
|
|
15824
|
+
return opt.value;
|
|
15825
|
+
})));
|
|
15826
|
+
}
|
|
15817
15827
|
}
|
|
15818
|
-
}
|
|
15819
|
-
|
|
15820
|
-
|
|
15821
|
-
|
|
15822
|
-
|
|
15823
|
-
|
|
15824
|
-
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
}
|
|
15840
|
-
addBrowseFields({
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
|
|
15844
|
-
|
|
15845
|
-
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15828
|
+
}, langs.map(lan => {
|
|
15829
|
+
let langCodes = localStorage.getItem(namespace + '-langCodes');
|
|
15830
|
+
langCodes = langCodes && JSON.parse(langCodes);
|
|
15831
|
+
const atts = {
|
|
15832
|
+
value: lan.code,
|
|
15833
|
+
selected: null
|
|
15834
|
+
};
|
|
15835
|
+
if (langCodes && langCodes.includes(lan.code)) {
|
|
15836
|
+
atts.selected = 'selected';
|
|
15837
|
+
}
|
|
15838
|
+
return ['option', atts, [languageI18n(lan.code)]];
|
|
15839
|
+
})]]], preferencesPlugin ? preferencesPlugin({
|
|
15840
|
+
$: $$1,
|
|
15841
|
+
l,
|
|
15842
|
+
jml,
|
|
15843
|
+
paramsSetter,
|
|
15844
|
+
getDataForSerializingParamsAsURL,
|
|
15845
|
+
work,
|
|
15846
|
+
replaceHash,
|
|
15847
|
+
getFieldAliasOrNames
|
|
15848
|
+
}) : '']];
|
|
15849
|
+
},
|
|
15850
|
+
addBrowseFields(_ref13) {
|
|
15851
|
+
let {
|
|
15852
|
+
browseFields,
|
|
15853
|
+
fieldInfo,
|
|
15854
|
+
lDirectional,
|
|
15855
|
+
i,
|
|
15856
|
+
lIndexedParam,
|
|
15857
|
+
$p,
|
|
15858
|
+
content
|
|
15859
|
+
} = _ref13;
|
|
15849
15860
|
const work = $p.get('work');
|
|
15850
15861
|
const addRowContent = rowContent => {
|
|
15851
15862
|
if (!rowContent || !rowContent.length) {
|
|
@@ -15860,14 +15871,15 @@ var workDisplay$1 = {
|
|
|
15860
15871
|
align: 'center'
|
|
15861
15872
|
}, [['br'], lDirectional('or'), ['br'], ['br']]]] : '', [...(() => {
|
|
15862
15873
|
const addBrowseFieldSet = setType => {
|
|
15863
|
-
return browseFields.reduce((rowContent, {
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15874
|
+
return browseFields.reduce((rowContent, _ref14, j) => {
|
|
15875
|
+
let {
|
|
15876
|
+
fieldName,
|
|
15877
|
+
aliases,
|
|
15878
|
+
fieldSchema: {
|
|
15879
|
+
minimum,
|
|
15880
|
+
maximum
|
|
15881
|
+
}
|
|
15882
|
+
} = _ref14;
|
|
15871
15883
|
// Namespace by work for sake of browser auto-complete caching
|
|
15872
15884
|
const name = work + '-' + lIndexedParam(setType) + (i + 1) + '-' + (j + 1);
|
|
15873
15885
|
const id = name;
|
|
@@ -15907,14 +15919,15 @@ var workDisplay$1 = {
|
|
|
15907
15919
|
})(), ['td', [browseFields.length > 1 ? lDirectional('versesendingdataoptional') : '']]], [['td', {
|
|
15908
15920
|
colspan: 4 * browseFields.length + 2 + 1,
|
|
15909
15921
|
align: 'center'
|
|
15910
|
-
}, [['table', [['tr', [browseFields.reduce((rowContent, {
|
|
15911
|
-
|
|
15912
|
-
|
|
15913
|
-
|
|
15914
|
-
|
|
15915
|
-
|
|
15916
|
-
|
|
15917
|
-
|
|
15922
|
+
}, [['table', [['tr', [browseFields.reduce((rowContent, _ref15, j) => {
|
|
15923
|
+
let {
|
|
15924
|
+
fieldName,
|
|
15925
|
+
aliases,
|
|
15926
|
+
fieldSchema: {
|
|
15927
|
+
minimum,
|
|
15928
|
+
maximum
|
|
15929
|
+
}
|
|
15930
|
+
} = _ref15;
|
|
15918
15931
|
// Namespace by work for sake of browser auto-complete caching
|
|
15919
15932
|
const name = work + '-' + lIndexedParam('anchor') + (i + 1) + '-' + (j + 1);
|
|
15920
15933
|
const id = name;
|
|
@@ -15944,9 +15957,10 @@ var workDisplay$1 = {
|
|
|
15944
15957
|
}), ['td', [['label', [lDirectional('field') + nbsp2, ['select', {
|
|
15945
15958
|
name: lIndexedParam('anchorfield') + (i + 1),
|
|
15946
15959
|
size: '1'
|
|
15947
|
-
}, fieldInfo.map(
|
|
15948
|
-
|
|
15949
|
-
|
|
15960
|
+
}, fieldInfo.map(_ref16 => {
|
|
15961
|
+
let {
|
|
15962
|
+
fieldAliasOrName
|
|
15963
|
+
} = _ref16;
|
|
15950
15964
|
const val = $p.get(lIndexedParam('anchorfield') + (i + 1), true);
|
|
15951
15965
|
if (val === fieldAliasOrName) {
|
|
15952
15966
|
return ['option', {
|
|
@@ -15956,42 +15970,45 @@ var workDisplay$1 = {
|
|
|
15956
15970
|
return ['option', [fieldAliasOrName]];
|
|
15957
15971
|
})]]]]]]]]]]]]].forEach(addRowContent);
|
|
15958
15972
|
},
|
|
15959
|
-
main({
|
|
15960
|
-
|
|
15961
|
-
|
|
15962
|
-
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
15981
|
-
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
|
|
15987
|
-
|
|
15973
|
+
main(_ref17) {
|
|
15974
|
+
let {
|
|
15975
|
+
workI18n,
|
|
15976
|
+
languageParam,
|
|
15977
|
+
l,
|
|
15978
|
+
namespace,
|
|
15979
|
+
heading,
|
|
15980
|
+
// fallbackDirection,
|
|
15981
|
+
languageI18n,
|
|
15982
|
+
langs,
|
|
15983
|
+
fieldInfo,
|
|
15984
|
+
localizeParamNames,
|
|
15985
|
+
serializeParamsAsURL,
|
|
15986
|
+
paramsSetter,
|
|
15987
|
+
replaceHash,
|
|
15988
|
+
getFieldAliasOrNames,
|
|
15989
|
+
hideFormattingSection,
|
|
15990
|
+
$p,
|
|
15991
|
+
metadataObj,
|
|
15992
|
+
lParam,
|
|
15993
|
+
lElement,
|
|
15994
|
+
lDirectional,
|
|
15995
|
+
lIndexedParam,
|
|
15996
|
+
fieldMatchesLocale,
|
|
15997
|
+
preferredLocale,
|
|
15998
|
+
schemaItems,
|
|
15999
|
+
content,
|
|
16000
|
+
groups,
|
|
16001
|
+
preferencesPlugin
|
|
16002
|
+
} = _ref17;
|
|
15988
16003
|
const work = $p.get('work');
|
|
15989
|
-
const serializeParamsAsURLWithData =
|
|
15990
|
-
|
|
15991
|
-
}) => {
|
|
15992
|
-
return serializeParamsAsURL(_objectSpread2$1(_objectSpread2$1({}, getDataForSerializingParamsAsURL()), {}, {
|
|
16004
|
+
const serializeParamsAsURLWithData = _ref18 => {
|
|
16005
|
+
let {
|
|
15993
16006
|
type
|
|
15994
|
-
}
|
|
16007
|
+
} = _ref18;
|
|
16008
|
+
return serializeParamsAsURL({
|
|
16009
|
+
...getDataForSerializingParamsAsURL(),
|
|
16010
|
+
type
|
|
16011
|
+
});
|
|
15995
16012
|
};
|
|
15996
16013
|
const lOption = (key, atts) => {
|
|
15997
16014
|
return ['option', atts, [l(key
|
|
@@ -16047,10 +16064,11 @@ var workDisplay$1 = {
|
|
|
16047
16064
|
}
|
|
16048
16065
|
},
|
|
16049
16066
|
$on: {
|
|
16050
|
-
keydown({
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16067
|
+
keydown(_ref19) {
|
|
16068
|
+
let {
|
|
16069
|
+
key,
|
|
16070
|
+
target
|
|
16071
|
+
} = _ref19;
|
|
16054
16072
|
// Chrome is not having submit event triggered now with enter key
|
|
16055
16073
|
// presses on inputs, despite having a `type=submit` input in the
|
|
16056
16074
|
// form, and despite not using `preventDefault`
|
|
@@ -16101,14 +16119,16 @@ var workDisplay$1 = {
|
|
|
16101
16119
|
$on: {
|
|
16102
16120
|
async click(e) {
|
|
16103
16121
|
e.preventDefault();
|
|
16104
|
-
const paramsCopy = paramsSetter(
|
|
16122
|
+
const paramsCopy = paramsSetter({
|
|
16123
|
+
...getDataForSerializingParamsAsURL(),
|
|
16105
16124
|
workName: work,
|
|
16106
16125
|
// Delete work of current page
|
|
16107
16126
|
type: 'startEndResult'
|
|
16108
|
-
})
|
|
16127
|
+
});
|
|
16109
16128
|
const url = replaceHash(paramsCopy) + `&work=${work}&${work}-startEnd1=%s`; // %s will be escaped if set as param; also add changeable workName here
|
|
16110
16129
|
try {
|
|
16111
16130
|
await navigator.clipboard.writeText(url);
|
|
16131
|
+
// eslint-disable-next-line no-unused-vars -- Okay to ignore
|
|
16112
16132
|
} catch (err) {
|
|
16113
16133
|
// User rejected
|
|
16114
16134
|
}
|
|
@@ -16158,65 +16178,73 @@ var workDisplay$1 = {
|
|
|
16158
16178
|
};
|
|
16159
16179
|
|
|
16160
16180
|
var resultsDisplayServerOrClient$1 = {
|
|
16161
|
-
caption({
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16181
|
+
caption(_ref) {
|
|
16182
|
+
let {
|
|
16183
|
+
heading,
|
|
16184
|
+
ranges
|
|
16185
|
+
} = _ref;
|
|
16165
16186
|
return heading + ' ' + ranges;
|
|
16166
16187
|
},
|
|
16167
|
-
startSeparator({
|
|
16168
|
-
|
|
16169
|
-
|
|
16188
|
+
startSeparator(_ref2) {
|
|
16189
|
+
let {
|
|
16190
|
+
l
|
|
16191
|
+
} = _ref2;
|
|
16170
16192
|
return l('colon');
|
|
16171
16193
|
},
|
|
16172
|
-
innerBrowseFieldSeparator({
|
|
16173
|
-
|
|
16174
|
-
|
|
16194
|
+
innerBrowseFieldSeparator(_ref3) {
|
|
16195
|
+
let {
|
|
16196
|
+
l
|
|
16197
|
+
} = _ref3;
|
|
16175
16198
|
return l('comma-space');
|
|
16176
16199
|
},
|
|
16177
|
-
ranges({
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16200
|
+
ranges(_ref4) {
|
|
16201
|
+
let {
|
|
16202
|
+
l,
|
|
16203
|
+
startRange,
|
|
16204
|
+
endVals,
|
|
16205
|
+
rangeNames
|
|
16206
|
+
} = _ref4;
|
|
16183
16207
|
return startRange +
|
|
16184
16208
|
// l('to').toLowerCase() + ' ' +
|
|
16185
16209
|
'-' + endVals.join(Templates.resultsDisplayServerOrClient.startSeparator({
|
|
16186
16210
|
l
|
|
16187
16211
|
})) + ' (' + rangeNames + ')';
|
|
16188
16212
|
},
|
|
16189
|
-
fieldValueAlias({
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16213
|
+
fieldValueAlias(_ref5) {
|
|
16214
|
+
let {
|
|
16215
|
+
key,
|
|
16216
|
+
value
|
|
16217
|
+
} = _ref5;
|
|
16193
16218
|
return value + ' (' + key + ')';
|
|
16194
16219
|
},
|
|
16195
|
-
interlinearSegment({
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16220
|
+
interlinearSegment(_ref6) {
|
|
16221
|
+
let {
|
|
16222
|
+
lang,
|
|
16223
|
+
dir,
|
|
16224
|
+
html
|
|
16225
|
+
} = _ref6;
|
|
16200
16226
|
return `<span${lang ? ` lang="${lang}"` : ''}${dir ? ` dir="${dir}"` : ''}>${html}</span>`;
|
|
16201
16227
|
},
|
|
16202
|
-
interlinearTitle({
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16228
|
+
interlinearTitle(_ref7) {
|
|
16229
|
+
let {
|
|
16230
|
+
l,
|
|
16231
|
+
val
|
|
16232
|
+
} = _ref7;
|
|
16206
16233
|
const colonSpace = l('colon-space');
|
|
16207
16234
|
return `<span class="interlintitle">${val}</span>${colonSpace}`;
|
|
16208
16235
|
},
|
|
16209
|
-
styles({
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16236
|
+
styles(_ref8) {
|
|
16237
|
+
let {
|
|
16238
|
+
$p,
|
|
16239
|
+
$pRaw,
|
|
16240
|
+
$pRawEsc,
|
|
16241
|
+
$pEscArbitrary,
|
|
16242
|
+
// escapeQuotedCSS,
|
|
16243
|
+
escapeCSS,
|
|
16244
|
+
tableWithFixedHeaderAndFooter,
|
|
16245
|
+
checkedFieldIndexes,
|
|
16246
|
+
hasCaption
|
|
16247
|
+
} = _ref8;
|
|
16220
16248
|
const colorEsc = !$p.has('color', true) || $p.get('color', true) === '#' ? $pRawEsc('colorName') : $pEscArbitrary('color');
|
|
16221
16249
|
const bgcolorEsc = !$p.has('bgcolor', true) || $p.get('bgcolor', true) === '#' ? $pRawEsc('bgcolorName') : $pEscArbitrary('bgcolor');
|
|
16222
16250
|
const tableHeight = '100%';
|
|
@@ -16309,30 +16337,31 @@ body {
|
|
|
16309
16337
|
}
|
|
16310
16338
|
` : '')]];
|
|
16311
16339
|
},
|
|
16312
|
-
main({
|
|
16313
|
-
|
|
16314
|
-
|
|
16315
|
-
|
|
16316
|
-
|
|
16317
|
-
|
|
16318
|
-
|
|
16319
|
-
|
|
16320
|
-
|
|
16321
|
-
|
|
16322
|
-
|
|
16323
|
-
|
|
16324
|
-
|
|
16325
|
-
|
|
16326
|
-
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16340
|
+
main(_ref9) {
|
|
16341
|
+
let {
|
|
16342
|
+
tableData,
|
|
16343
|
+
$p,
|
|
16344
|
+
$pRaw,
|
|
16345
|
+
$pRawEsc,
|
|
16346
|
+
$pEscArbitrary,
|
|
16347
|
+
// Todo: escaping should be done in business logic!
|
|
16348
|
+
escapeQuotedCSS,
|
|
16349
|
+
escapeCSS,
|
|
16350
|
+
escapeHTML,
|
|
16351
|
+
l,
|
|
16352
|
+
localizedFieldNames,
|
|
16353
|
+
fieldLangs,
|
|
16354
|
+
fieldDirs,
|
|
16355
|
+
caption,
|
|
16356
|
+
hasCaption,
|
|
16357
|
+
showInterlinTitles,
|
|
16358
|
+
determineEnd,
|
|
16359
|
+
getCanonicalID,
|
|
16360
|
+
canonicalBrowseFieldSetName,
|
|
16361
|
+
getCellValue,
|
|
16362
|
+
checkedAndInterlinearFieldInfo,
|
|
16363
|
+
interlinearSeparator = '<br /><br />'
|
|
16364
|
+
} = _ref9;
|
|
16336
16365
|
const tableOptions = {
|
|
16337
16366
|
table: [['table', {
|
|
16338
16367
|
class: 'table',
|
|
@@ -16355,7 +16384,6 @@ body {
|
|
|
16355
16384
|
// ['colgroup', {class: 'colgroup'}],
|
|
16356
16385
|
// ['col', {class: 'col'}]
|
|
16357
16386
|
],
|
|
16358
|
-
|
|
16359
16387
|
div: [['div', {
|
|
16360
16388
|
class: 'table',
|
|
16361
16389
|
style: 'display: table;'
|
|
@@ -16384,7 +16412,6 @@ body {
|
|
|
16384
16412
|
// ['div', {class: 'colgroup', style: 'display: table-column-group;'}],
|
|
16385
16413
|
// ['div', {class: 'col', style: 'display: table-column;'}]
|
|
16386
16414
|
],
|
|
16387
|
-
|
|
16388
16415
|
'json-array': 'json',
|
|
16389
16416
|
'json-object': 'json'
|
|
16390
16417
|
};
|
|
@@ -16399,7 +16426,6 @@ body {
|
|
|
16399
16426
|
}
|
|
16400
16427
|
const tableElems = tableOptions[Object.prototype.hasOwnProperty.call(tableOptions, outputmode) ? outputmode : 'table' // Default
|
|
16401
16428
|
];
|
|
16402
|
-
|
|
16403
16429
|
const [tableElem, trElem, tdElem, thElem, captionElem, theadElem, tbodyElem, tfootElem] = tableElems; // colgroupElem, colElem
|
|
16404
16430
|
|
|
16405
16431
|
const [checkedFields, checkedFieldIndexes, allInterlinearColIndexes] = checkedAndInterlinearFieldInfo;
|
|
@@ -16414,11 +16440,18 @@ body {
|
|
|
16414
16440
|
}, children];
|
|
16415
16441
|
};
|
|
16416
16442
|
const addChildren = (el, children) => {
|
|
16443
|
+
// eslint-disable-next-line unicorn/prefer-structured-clone -- Need JSON
|
|
16417
16444
|
el = JSON.parse(JSON.stringify(el));
|
|
16418
16445
|
el.push(children);
|
|
16419
16446
|
return el;
|
|
16420
16447
|
};
|
|
16421
|
-
const addAtts = (
|
|
16448
|
+
const addAtts = (_ref10, newAtts) => {
|
|
16449
|
+
let [el, atts] = _ref10;
|
|
16450
|
+
return [el, {
|
|
16451
|
+
...atts,
|
|
16452
|
+
...newAtts
|
|
16453
|
+
}];
|
|
16454
|
+
};
|
|
16422
16455
|
const foundState = {
|
|
16423
16456
|
start: false,
|
|
16424
16457
|
end: false
|
|
@@ -16527,7 +16560,7 @@ body {
|
|
|
16527
16560
|
class: 'zupa1'
|
|
16528
16561
|
}, [['div', {
|
|
16529
16562
|
class: 'inner-caption'
|
|
16530
|
-
}, [['span', [caption]]]]]] : '']) : '',
|
|
16563
|
+
}, [['span', [caption]]]]]] : '']) : '', (
|
|
16531
16564
|
/*
|
|
16532
16565
|
// Works but quirky, e.g., `color` doesn't work (as also
|
|
16533
16566
|
// confirmed per https://quirksmode.org/css/css2/columns.html)
|
|
@@ -16547,7 +16580,7 @@ body {
|
|
|
16547
16580
|
}, [['div', {
|
|
16548
16581
|
class: 'th-inner'
|
|
16549
16582
|
}, [['span', [cf]]]]]] : '']);
|
|
16550
|
-
}))]) : '', $pRaw('footer') && $pRaw('footer') !== '0' ? addChildren(tfootElem, [addChildren(trElem, checkedFields.map((cf, i) => {
|
|
16583
|
+
}))]) : ''), $pRaw('footer') && $pRaw('footer') !== '0' ? addChildren(tfootElem, [addChildren(trElem, checkedFields.map((cf, i) => {
|
|
16551
16584
|
const interlinearColIndexes = allInterlinearColIndexes[i];
|
|
16552
16585
|
cf = escapeHTML(cf) + (interlinearColIndexes ? l('comma-space') + interlinearColIndexes.map(idx => {
|
|
16553
16586
|
return localizedFieldNames[idx];
|
|
@@ -16562,22 +16595,24 @@ body {
|
|
|
16562
16595
|
};
|
|
16563
16596
|
|
|
16564
16597
|
var resultsDisplayClient$1 = {
|
|
16565
|
-
anchorRowCol({
|
|
16566
|
-
|
|
16567
|
-
|
|
16598
|
+
anchorRowCol(_ref) {
|
|
16599
|
+
let {
|
|
16600
|
+
anchorRowCol
|
|
16601
|
+
} = _ref;
|
|
16568
16602
|
return $$1('#' + anchorRowCol);
|
|
16569
16603
|
},
|
|
16570
|
-
anchors({
|
|
16571
|
-
|
|
16572
|
-
|
|
16573
|
-
|
|
16604
|
+
anchors(_ref2) {
|
|
16605
|
+
let {
|
|
16606
|
+
escapedRow,
|
|
16607
|
+
escapedCol
|
|
16608
|
+
} = _ref2;
|
|
16574
16609
|
const sel = 'tr[data-row="' + escapedRow + '"]' + (escapedCol ? '> td[data-col="' + escapedCol + '"]' : '');
|
|
16575
16610
|
return $$1(sel);
|
|
16576
16611
|
},
|
|
16577
|
-
main(
|
|
16612
|
+
main() {
|
|
16578
16613
|
let html;
|
|
16579
16614
|
try {
|
|
16580
|
-
html = Templates.resultsDisplayServerOrClient.main(...
|
|
16615
|
+
html = Templates.resultsDisplayServerOrClient.main(...arguments);
|
|
16581
16616
|
} catch (err) {
|
|
16582
16617
|
if (err.message === 'JSON support is currently not available') {
|
|
16583
16618
|
dialogs.alert(err.message);
|
|
@@ -16589,7 +16624,6 @@ var resultsDisplayClient$1 = {
|
|
|
16589
16624
|
}
|
|
16590
16625
|
};
|
|
16591
16626
|
|
|
16592
|
-
/* eslint-env browser */
|
|
16593
16627
|
const Templates = {
|
|
16594
16628
|
languageSelect,
|
|
16595
16629
|
workSelect: workSelect$1,
|
|
@@ -16611,14 +16645,16 @@ const Templates = {
|
|
|
16611
16645
|
versionChange() {
|
|
16612
16646
|
$$1('#versionChange').showModal();
|
|
16613
16647
|
},
|
|
16614
|
-
addLogEntry({
|
|
16615
|
-
|
|
16616
|
-
|
|
16648
|
+
addLogEntry(_ref) {
|
|
16649
|
+
let {
|
|
16650
|
+
text
|
|
16651
|
+
} = _ref;
|
|
16617
16652
|
const installationDialog = $$1('#installationLogContainer');
|
|
16618
16653
|
try {
|
|
16619
16654
|
installationDialog.showModal();
|
|
16620
16655
|
const container = $$1('#dialogContainer');
|
|
16621
16656
|
container.hidden = false;
|
|
16657
|
+
// eslint-disable-next-line no-unused-vars -- Ok
|
|
16622
16658
|
} catch (err) {
|
|
16623
16659
|
// May already be open
|
|
16624
16660
|
}
|
|
@@ -16630,10 +16666,11 @@ const Templates = {
|
|
|
16630
16666
|
container.hidden = true;
|
|
16631
16667
|
}
|
|
16632
16668
|
},
|
|
16633
|
-
dbError({
|
|
16634
|
-
|
|
16635
|
-
|
|
16636
|
-
|
|
16669
|
+
dbError(_ref2) {
|
|
16670
|
+
let {
|
|
16671
|
+
type,
|
|
16672
|
+
escapedErrorMessage
|
|
16673
|
+
} = _ref2;
|
|
16637
16674
|
if (type) {
|
|
16638
16675
|
jml('span', [type, ' ', escapedErrorMessage], $$1('#dbError'));
|
|
16639
16676
|
}
|
|
@@ -16660,13 +16697,14 @@ const Templates = {
|
|
|
16660
16697
|
* HTMLDialogElement, HTMLDialogElement, HTMLDialogElement
|
|
16661
16698
|
* ]}
|
|
16662
16699
|
*/
|
|
16663
|
-
main({
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
|
|
16667
|
-
|
|
16668
|
-
|
|
16669
|
-
|
|
16700
|
+
main(_ref3) {
|
|
16701
|
+
let {
|
|
16702
|
+
siteI18n,
|
|
16703
|
+
ok,
|
|
16704
|
+
refuse,
|
|
16705
|
+
close,
|
|
16706
|
+
closeBrowserNotGranting
|
|
16707
|
+
} = _ref3;
|
|
16670
16708
|
const installationDialog = jml('dialog', {
|
|
16671
16709
|
style: 'text-align: center; height: 100%',
|
|
16672
16710
|
id: 'installationLogContainer',
|
|
@@ -16678,7 +16716,6 @@ const Templates = {
|
|
|
16678
16716
|
}, []]]]
|
|
16679
16717
|
// ['textarea', {readonly: true, style: 'width: 80%; height: 80%;'}]
|
|
16680
16718
|
]);
|
|
16681
|
-
|
|
16682
16719
|
let requestPermissionsDialog = '';
|
|
16683
16720
|
if (ok) {
|
|
16684
16721
|
requestPermissionsDialog = jml('dialog', {
|
|
@@ -16754,10 +16791,11 @@ function _prepareParam(param, skip) {
|
|
|
16754
16791
|
return this.l10n(['params', param]);
|
|
16755
16792
|
}
|
|
16756
16793
|
class IntlURLSearchParams {
|
|
16757
|
-
constructor({
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
|
|
16794
|
+
constructor() {
|
|
16795
|
+
let {
|
|
16796
|
+
l10n,
|
|
16797
|
+
params
|
|
16798
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16761
16799
|
this.l10n = l10n;
|
|
16762
16800
|
if (!params) {
|
|
16763
16801
|
params = location.hash.slice(1);
|
|
@@ -16790,15 +16828,15 @@ class IntlURLSearchParams {
|
|
|
16790
16828
|
}
|
|
16791
16829
|
}
|
|
16792
16830
|
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
|
|
16796
|
-
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
}
|
|
16831
|
+
async function workSelect(_ref) {
|
|
16832
|
+
let {
|
|
16833
|
+
files,
|
|
16834
|
+
lang,
|
|
16835
|
+
fallbackLanguages,
|
|
16836
|
+
$p,
|
|
16837
|
+
followParams
|
|
16838
|
+
/* , l, defineFormatter */
|
|
16839
|
+
} = _ref;
|
|
16802
16840
|
// We use getJSON instead of JsonRefs as we do not necessarily need to
|
|
16803
16841
|
// resolve the file contents here
|
|
16804
16842
|
try {
|
|
@@ -16813,10 +16851,11 @@ async function workSelect({
|
|
|
16813
16851
|
locales: lang,
|
|
16814
16852
|
defaultLocales: fallbackLanguages,
|
|
16815
16853
|
// Todo: Could at least share this with `index.js`
|
|
16816
|
-
localeStringFinder({
|
|
16817
|
-
|
|
16818
|
-
|
|
16819
|
-
|
|
16854
|
+
localeStringFinder(_ref2) {
|
|
16855
|
+
let {
|
|
16856
|
+
locales,
|
|
16857
|
+
defaultLocales
|
|
16858
|
+
} = _ref2;
|
|
16820
16859
|
const locale = [...locales, ...defaultLocales].find(language => {
|
|
16821
16860
|
return language in localizationStrings;
|
|
16822
16861
|
});
|
|
@@ -16864,33 +16903,34 @@ async function workSelect({
|
|
|
16864
16903
|
}
|
|
16865
16904
|
}
|
|
16866
16905
|
|
|
16867
|
-
/* eslint-env browser */
|
|
16868
16906
|
// Todo: Reimplement this with `formSerialize.deserialize` as possible
|
|
16869
16907
|
const replaceHash = paramsCopy => {
|
|
16870
16908
|
return location.href.replace(/#.*$/, '') + '#' + paramsCopy.toString();
|
|
16871
16909
|
};
|
|
16872
|
-
const getSerializeParamsAsURL = function (
|
|
16873
|
-
const setter = getParamsSetter(...
|
|
16874
|
-
return function (
|
|
16875
|
-
const paramsCopy = setter(...
|
|
16910
|
+
const getSerializeParamsAsURL = function () {
|
|
16911
|
+
const setter = getParamsSetter(...arguments);
|
|
16912
|
+
return function () {
|
|
16913
|
+
const paramsCopy = setter(...arguments);
|
|
16876
16914
|
return replaceHash(paramsCopy);
|
|
16877
16915
|
};
|
|
16878
16916
|
};
|
|
16879
|
-
const getParamsSetter = function ({
|
|
16880
|
-
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
16885
|
-
|
|
16886
|
-
|
|
16887
|
-
|
|
16888
|
-
|
|
16889
|
-
|
|
16890
|
-
|
|
16891
|
-
|
|
16892
|
-
|
|
16893
|
-
|
|
16917
|
+
const getParamsSetter = function (_ref) {
|
|
16918
|
+
let {
|
|
16919
|
+
l,
|
|
16920
|
+
lParam,
|
|
16921
|
+
$p
|
|
16922
|
+
} = _ref;
|
|
16923
|
+
return function (_ref2) {
|
|
16924
|
+
let {
|
|
16925
|
+
form,
|
|
16926
|
+
random = {
|
|
16927
|
+
checked: false
|
|
16928
|
+
},
|
|
16929
|
+
checkboxes,
|
|
16930
|
+
type,
|
|
16931
|
+
fieldAliasOrNames = [],
|
|
16932
|
+
workName
|
|
16933
|
+
} = _ref2;
|
|
16894
16934
|
const paramsCopy = new URLSearchParams($p.params);
|
|
16895
16935
|
const formParamsHash = serialize(form, {
|
|
16896
16936
|
hash: true,
|
|
@@ -16994,16 +17034,16 @@ const getParamsSetter = function ({
|
|
|
16994
17034
|
};
|
|
16995
17035
|
};
|
|
16996
17036
|
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
}
|
|
17037
|
+
async function workDisplay(_ref) {
|
|
17038
|
+
let {
|
|
17039
|
+
l,
|
|
17040
|
+
languageParam,
|
|
17041
|
+
lang,
|
|
17042
|
+
preferredLocale,
|
|
17043
|
+
languages,
|
|
17044
|
+
fallbackLanguages,
|
|
17045
|
+
$p
|
|
17046
|
+
} = _ref;
|
|
17007
17047
|
const {
|
|
17008
17048
|
preferencesPlugin
|
|
17009
17049
|
} = this;
|
|
@@ -17013,23 +17053,25 @@ async function workDisplay({
|
|
|
17013
17053
|
const localizeParamNames = $p.localizeParamNames = $p.has('i18n', true) ? $p.get('i18n', true) === '1' : prefI18n === 'true' || prefI18n !== 'false' && this.localizeParamNames;
|
|
17014
17054
|
const prefFormatting = localStorage.getItem(this.namespace + '-hideFormattingSection');
|
|
17015
17055
|
const hideFormattingSection = $p.has('formatting', true) ? $p.get('formatting', true) === '0' : prefFormatting === 'true' || prefFormatting !== 'false' && this.hideFormattingSection;
|
|
17016
|
-
async function _displayWork({
|
|
17017
|
-
|
|
17018
|
-
|
|
17019
|
-
|
|
17020
|
-
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
|
|
17024
|
-
|
|
17025
|
-
|
|
17026
|
-
|
|
17056
|
+
async function _displayWork(_ref2) {
|
|
17057
|
+
let {
|
|
17058
|
+
workI18n,
|
|
17059
|
+
metadataObj,
|
|
17060
|
+
getFieldAliasOrName,
|
|
17061
|
+
schemaItems,
|
|
17062
|
+
// schemaObj,
|
|
17063
|
+
fieldInfo,
|
|
17064
|
+
metadata,
|
|
17065
|
+
pluginsForWork,
|
|
17066
|
+
groupsToWorks
|
|
17067
|
+
} = _ref2;
|
|
17027
17068
|
const lParam = localizeParamNames ? key => l(['params', key]) : key => key;
|
|
17028
17069
|
const lIndexedParam = localizeParamNames ? key => l(['params', 'indexed', key]) : key => key;
|
|
17029
17070
|
|
|
17030
17071
|
// Returns element with localized option text (as Jamilih), with
|
|
17031
17072
|
// optional fallback direction
|
|
17032
|
-
const lElement = (key, el, attToLocalize, atts
|
|
17073
|
+
const lElement = function (key, el, attToLocalize, atts) {
|
|
17074
|
+
let children = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
17033
17075
|
atts[attToLocalize] = l(key
|
|
17034
17076
|
// Restore this if `intl-dom` supports
|
|
17035
17077
|
// fallback ({message}) {
|
|
@@ -17037,7 +17079,6 @@ async function workDisplay({
|
|
|
17037
17079
|
// return message;
|
|
17038
17080
|
// }
|
|
17039
17081
|
);
|
|
17040
|
-
|
|
17041
17082
|
return [el, atts, children];
|
|
17042
17083
|
};
|
|
17043
17084
|
|
|
@@ -17048,7 +17089,6 @@ async function workDisplay({
|
|
|
17048
17089
|
// fallback: ({message}) =>
|
|
17049
17090
|
// Templates.workDisplay.bdo({fallbackDirection, message})
|
|
17050
17091
|
);
|
|
17051
|
-
|
|
17052
17092
|
const fieldMatchesLocale = metadata.getFieldMatchesLocale({
|
|
17053
17093
|
namespace: this.namespace,
|
|
17054
17094
|
preferredLocale,
|
|
@@ -17060,10 +17100,11 @@ async function workDisplay({
|
|
|
17060
17100
|
metadataObj,
|
|
17061
17101
|
schemaItems,
|
|
17062
17102
|
getFieldAliasOrName,
|
|
17063
|
-
callback({
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17103
|
+
callback(_ref3) {
|
|
17104
|
+
let {
|
|
17105
|
+
browseFields,
|
|
17106
|
+
i
|
|
17107
|
+
} = _ref3;
|
|
17067
17108
|
Templates.workDisplay.addBrowseFields({
|
|
17068
17109
|
browseFields,
|
|
17069
17110
|
fieldInfo,
|
|
@@ -17100,11 +17141,12 @@ async function workDisplay({
|
|
|
17100
17141
|
const getFieldAliasOrNames = (() => {
|
|
17101
17142
|
// Avoid blocking but start now
|
|
17102
17143
|
// Let this run in the background to avoid blocking
|
|
17103
|
-
const all = Promise.all(groupsToWorks.map(async
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17144
|
+
const all = Promise.all(groupsToWorks.map(async _ref4 => {
|
|
17145
|
+
let {
|
|
17146
|
+
name,
|
|
17147
|
+
workNames,
|
|
17148
|
+
shortcuts
|
|
17149
|
+
} = _ref4;
|
|
17108
17150
|
const worksToFields = await Promise.all(workNames.map(async (workName, i) => {
|
|
17109
17151
|
return {
|
|
17110
17152
|
workName,
|
|
@@ -17115,9 +17157,12 @@ async function workDisplay({
|
|
|
17115
17157
|
preferredLocale,
|
|
17116
17158
|
languages,
|
|
17117
17159
|
work: workName
|
|
17118
|
-
})).fieldInfo.map(
|
|
17119
|
-
|
|
17120
|
-
|
|
17160
|
+
})).fieldInfo.map(_ref5 => {
|
|
17161
|
+
let {
|
|
17162
|
+
fieldAliasOrName
|
|
17163
|
+
} = _ref5;
|
|
17164
|
+
return fieldAliasOrName;
|
|
17165
|
+
})
|
|
17121
17166
|
};
|
|
17122
17167
|
}));
|
|
17123
17168
|
return {
|
|
@@ -17129,14 +17174,12 @@ async function workDisplay({
|
|
|
17129
17174
|
return all; // May not be finished by now
|
|
17130
17175
|
};
|
|
17131
17176
|
})();
|
|
17132
|
-
|
|
17133
17177
|
const displayNames = new Intl.DisplayNames([...lang, ...fallbackLanguages], {
|
|
17134
17178
|
type: 'language',
|
|
17135
17179
|
// Dialect: "American English"
|
|
17136
17180
|
// Standard: "English (United States)"
|
|
17137
17181
|
languageDisplay: 'standard' // 'dialect'
|
|
17138
17182
|
});
|
|
17139
|
-
|
|
17140
17183
|
const languageI18n = code => {
|
|
17141
17184
|
return displayNames.of(code);
|
|
17142
17185
|
};
|
|
@@ -17172,26 +17215,26 @@ async function workDisplay({
|
|
|
17172
17215
|
});
|
|
17173
17216
|
}
|
|
17174
17217
|
try {
|
|
17175
|
-
const
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
args = _objectWithoutProperties(_await$this$getWorkDa, _excluded);
|
|
17218
|
+
const {
|
|
17219
|
+
workI18n,
|
|
17220
|
+
fileData,
|
|
17221
|
+
metadataObj,
|
|
17222
|
+
...args
|
|
17223
|
+
} = await this.getWorkData({
|
|
17224
|
+
lang,
|
|
17225
|
+
fallbackLanguages,
|
|
17226
|
+
preferredLocale,
|
|
17227
|
+
languages,
|
|
17228
|
+
work: $p.get('work')
|
|
17229
|
+
});
|
|
17188
17230
|
document.title = workI18n('browserfile-workdisplay', {
|
|
17189
17231
|
work: fileData ? getMetaProp(lang, metadataObj, 'alias') : ''
|
|
17190
17232
|
});
|
|
17191
|
-
await _displayWork.call(this,
|
|
17233
|
+
await _displayWork.call(this, {
|
|
17192
17234
|
workI18n,
|
|
17193
|
-
metadataObj
|
|
17194
|
-
|
|
17235
|
+
metadataObj,
|
|
17236
|
+
...args
|
|
17237
|
+
});
|
|
17195
17238
|
} catch (err) {
|
|
17196
17239
|
console.log('err', err);
|
|
17197
17240
|
dialogs.alert(err);
|
|
@@ -17395,7 +17438,6 @@ class Locale {
|
|
|
17395
17438
|
|
|
17396
17439
|
// Public functions - End
|
|
17397
17440
|
}
|
|
17398
|
-
|
|
17399
17441
|
Locale._RTL_SCRIPTS = ['adlm', 'arab', 'armi', 'avst', 'chrs', 'cprt', 'elym', 'hatr', 'hebr', 'hung', 'khar', 'lydi', 'mand', 'mani', 'mend', 'merc', 'mero', 'narb', 'nbat', 'nkoo', 'orkh', 'ougr', 'palm', 'phli', 'phlp', 'phnx', 'prti', 'rohg', 'samr', 'sarb', 'sogd', 'sogo', 'syrc', 'thaa', 'yezi'];
|
|
17400
17442
|
|
|
17401
17443
|
// Why not working as static property
|
|
@@ -17640,14 +17682,15 @@ const fieldValueAliasRegex = /^.* \((.*?)\)$/;
|
|
|
17640
17682
|
const getRawFieldValue = v => {
|
|
17641
17683
|
return typeof v === 'string' ? v.replace(fieldValueAliasRegex, '$1') : v;
|
|
17642
17684
|
};
|
|
17643
|
-
const setAnchor =
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
|
|
17685
|
+
const setAnchor = _ref => {
|
|
17686
|
+
let {
|
|
17687
|
+
applicableBrowseFieldSet,
|
|
17688
|
+
fieldValueAliasMapPreferred,
|
|
17689
|
+
lParamRaw,
|
|
17690
|
+
lIndexedParam,
|
|
17691
|
+
max,
|
|
17692
|
+
$p
|
|
17693
|
+
} = _ref;
|
|
17651
17694
|
const applicableBrowseFieldSchemaIndexes = applicableBrowseFieldSet.map(abfs => {
|
|
17652
17695
|
return abfs.fieldSchemaIndex;
|
|
17653
17696
|
});
|
|
@@ -17664,6 +17707,7 @@ const setAnchor = ({
|
|
|
17664
17707
|
if (!anchor) {
|
|
17665
17708
|
const anchors = [];
|
|
17666
17709
|
let anchorField = '';
|
|
17710
|
+
// eslint-disable-next-line sonarjs/misplaced-loop-counter -- Ok
|
|
17667
17711
|
for (let i = 1, breakout; !breakout && !anchors.length; i++) {
|
|
17668
17712
|
for (let j = 1;; j++) {
|
|
17669
17713
|
const anchorText = work + '-' + 'anchor' + i + '-' + j;
|
|
@@ -17685,9 +17729,8 @@ const setAnchor = ({
|
|
|
17685
17729
|
// anchors.push({anchorText, anchor});
|
|
17686
17730
|
}
|
|
17687
17731
|
}
|
|
17688
|
-
|
|
17689
17732
|
if (anchors.length) {
|
|
17690
|
-
const escapeSelectorAttValue = str => (str || '').replaceAll(/["\\]/g,
|
|
17733
|
+
const escapeSelectorAttValue = str => (str || '').replaceAll(/["\\]/g, String.raw`\$&`);
|
|
17691
17734
|
const escapedRow = escapeSelectorAttValue(anchors.join('-'));
|
|
17692
17735
|
const escapedCol = anchorField ? escapeSelectorAttValue(anchorField) : undefined;
|
|
17693
17736
|
anchor = Templates.resultsDisplayClient.anchors({
|
|
@@ -17717,10 +17760,11 @@ const resultsDisplayClient = async function resultsDisplayClient(args) {
|
|
|
17717
17760
|
lIndexedParam,
|
|
17718
17761
|
lParamRaw,
|
|
17719
17762
|
templateArgs
|
|
17720
|
-
} = await resultsDisplayServerOrClient.call(this,
|
|
17763
|
+
} = await resultsDisplayServerOrClient.call(this, {
|
|
17764
|
+
...args,
|
|
17721
17765
|
skipIndexedDB,
|
|
17722
17766
|
prefI18n
|
|
17723
|
-
})
|
|
17767
|
+
});
|
|
17724
17768
|
document.title = workI18n('browserfile-resultsdisplay', {
|
|
17725
17769
|
work: fileData ? getMetaProp(lang, metadataObj, 'alias') : ''
|
|
17726
17770
|
});
|
|
@@ -17733,12 +17777,13 @@ const resultsDisplayClient = async function resultsDisplayClient(args) {
|
|
|
17733
17777
|
$p: args.$p,
|
|
17734
17778
|
max: browseFieldSets.length
|
|
17735
17779
|
});
|
|
17736
|
-
fieldInfo.forEach(
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17780
|
+
fieldInfo.forEach(_ref2 => {
|
|
17781
|
+
let {
|
|
17782
|
+
plugin,
|
|
17783
|
+
applicableField,
|
|
17784
|
+
meta,
|
|
17785
|
+
j
|
|
17786
|
+
} = _ref2;
|
|
17742
17787
|
if (!plugin) {
|
|
17743
17788
|
return;
|
|
17744
17789
|
}
|
|
@@ -17753,131 +17798,143 @@ const resultsDisplayClient = async function resultsDisplayClient(args) {
|
|
|
17753
17798
|
}
|
|
17754
17799
|
});
|
|
17755
17800
|
};
|
|
17756
|
-
const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient({
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17801
|
+
const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient(_ref3) {
|
|
17802
|
+
let {
|
|
17803
|
+
l,
|
|
17804
|
+
lang,
|
|
17805
|
+
fallbackLanguages,
|
|
17806
|
+
locales,
|
|
17807
|
+
$p,
|
|
17808
|
+
skipIndexedDB,
|
|
17809
|
+
noIndexedDB,
|
|
17810
|
+
prefI18n,
|
|
17811
|
+
files,
|
|
17812
|
+
allowPlugins,
|
|
17813
|
+
langData,
|
|
17814
|
+
basePath = '',
|
|
17815
|
+
dynamicBasePath = ''
|
|
17816
|
+
} = _ref3;
|
|
17771
17817
|
const languages = new Languages({
|
|
17772
17818
|
langData
|
|
17773
17819
|
});
|
|
17774
|
-
const getCellValue =
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
|
|
17820
|
+
const getCellValue = _ref4 => {
|
|
17821
|
+
let {
|
|
17822
|
+
fieldValueAliasMapPreferred,
|
|
17823
|
+
escapeColumnIndexes
|
|
17824
|
+
} = _ref4;
|
|
17825
|
+
return _ref5 => {
|
|
17826
|
+
let {
|
|
17827
|
+
tr,
|
|
17828
|
+
idx
|
|
17829
|
+
} = _ref5;
|
|
17830
|
+
let tdVal = fieldValueAliasMapPreferred[idx] !== undefined ? fieldValueAliasMapPreferred[idx][tr[idx]] : tr[idx];
|
|
17831
|
+
if (tdVal && typeof tdVal === 'object') {
|
|
17832
|
+
tdVal = Object.values(tdVal);
|
|
17833
|
+
}
|
|
17834
|
+
if (Array.isArray(tdVal)) {
|
|
17835
|
+
tdVal = tdVal.join(l('comma-space'));
|
|
17836
|
+
}
|
|
17837
|
+
return (escapeColumnIndexes[idx] || !this.trustFormatHTML) && typeof tdVal === 'string' ? {
|
|
17838
|
+
tdVal: escapeHTML(tdVal),
|
|
17839
|
+
htmlEscaped: true
|
|
17840
|
+
} : {
|
|
17841
|
+
tdVal
|
|
17842
|
+
};
|
|
17793
17843
|
};
|
|
17794
17844
|
};
|
|
17795
|
-
const getCanonicalID =
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17845
|
+
const getCanonicalID = _ref6 => {
|
|
17846
|
+
let {
|
|
17847
|
+
fieldValueAliasMap,
|
|
17848
|
+
fieldValueAliasMapPreferred,
|
|
17849
|
+
localizedFieldNames,
|
|
17850
|
+
canonicalBrowseFieldNames
|
|
17851
|
+
} = _ref6;
|
|
17852
|
+
return _ref7 => {
|
|
17853
|
+
let {
|
|
17854
|
+
tr // , foundState
|
|
17855
|
+
} = _ref7;
|
|
17856
|
+
return canonicalBrowseFieldNames.map(fieldName => {
|
|
17857
|
+
const idx = localizedFieldNames.indexOf(fieldName);
|
|
17858
|
+
// This works to put alias in anchor but this includes
|
|
17859
|
+
// our ending parenthetical, the alias may be harder
|
|
17860
|
+
// to remember and/or automated than original (e.g.,
|
|
17861
|
+
// for a number representing a book); we may wish to
|
|
17862
|
+
// switch this (and also for other browse field-based
|
|
17863
|
+
// items).
|
|
17864
|
+
if (fieldValueAliasMap[idx] !== undefined &&
|
|
17865
|
+
// Added this condition after imf->intl-dom conversion; concealing a
|
|
17866
|
+
// bug?
|
|
17867
|
+
fieldValueAliasMap[idx] !== null) {
|
|
17868
|
+
return fieldValueAliasMapPreferred[idx][tr[idx]];
|
|
17869
|
+
}
|
|
17870
|
+
return tr[idx];
|
|
17871
|
+
}).join('-'); // rowID;
|
|
17872
|
+
};
|
|
17819
17873
|
};
|
|
17874
|
+
const determineEnd = _ref8 => {
|
|
17875
|
+
let {
|
|
17876
|
+
fieldValueAliasMap,
|
|
17877
|
+
fieldValueAliasMapPreferred,
|
|
17878
|
+
localizedFieldNames,
|
|
17879
|
+
applicableBrowseFieldNames,
|
|
17880
|
+
startsRaw,
|
|
17881
|
+
endsRaw
|
|
17882
|
+
} = _ref8;
|
|
17883
|
+
return _ref9 => {
|
|
17884
|
+
let {
|
|
17885
|
+
tr,
|
|
17886
|
+
foundState
|
|
17887
|
+
} = _ref9;
|
|
17888
|
+
const rowIDPartsPreferred = [];
|
|
17889
|
+
const rowIDParts = applicableBrowseFieldNames.map(fieldName => {
|
|
17890
|
+
const idx = localizedFieldNames.indexOf(fieldName);
|
|
17891
|
+
// This works to put alias in anchor but this includes
|
|
17892
|
+
// our ending parenthetical, the alias may be harder
|
|
17893
|
+
// to remember and/or automated than original (e.g.,
|
|
17894
|
+
// for a number representing a book), and there could
|
|
17895
|
+
// be multiple aliases for a value; we may wish to
|
|
17896
|
+
// switch this (and also for other browse field-based
|
|
17897
|
+
// items).
|
|
17898
|
+
if (fieldValueAliasMap[idx] !== undefined &&
|
|
17899
|
+
// Added this condition after imf->intl-dom conversion; concealing a
|
|
17900
|
+
// bug?
|
|
17901
|
+
fieldValueAliasMap[idx] !== null) {
|
|
17902
|
+
rowIDPartsPreferred.push(fieldValueAliasMapPreferred[idx][tr[idx]]);
|
|
17903
|
+
} else {
|
|
17904
|
+
rowIDPartsPreferred.push(tr[idx]);
|
|
17905
|
+
}
|
|
17906
|
+
return tr[idx];
|
|
17907
|
+
});
|
|
17820
17908
|
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
|
|
17832
|
-
const rowIDPartsPreferred = [];
|
|
17833
|
-
const rowIDParts = applicableBrowseFieldNames.map(fieldName => {
|
|
17834
|
-
const idx = localizedFieldNames.indexOf(fieldName);
|
|
17835
|
-
// This works to put alias in anchor but this includes
|
|
17836
|
-
// our ending parenthetical, the alias may be harder
|
|
17837
|
-
// to remember and/or automated than original (e.g.,
|
|
17838
|
-
// for a number representing a book), and there could
|
|
17839
|
-
// be multiple aliases for a value; we may wish to
|
|
17840
|
-
// switch this (and also for other browse field-based
|
|
17841
|
-
// items).
|
|
17842
|
-
if (fieldValueAliasMap[idx] !== undefined &&
|
|
17843
|
-
// Added this condition after imf->intl-dom conversion; concealing a
|
|
17844
|
-
// bug?
|
|
17845
|
-
fieldValueAliasMap[idx] !== null) {
|
|
17846
|
-
rowIDPartsPreferred.push(fieldValueAliasMapPreferred[idx][tr[idx]]);
|
|
17847
|
-
} else {
|
|
17848
|
-
rowIDPartsPreferred.push(tr[idx]);
|
|
17909
|
+
// Todo: Use schema to determine field type and use `Number.parseInt`
|
|
17910
|
+
// on other value instead of `String` conversions
|
|
17911
|
+
if (!foundState.start) {
|
|
17912
|
+
if (startsRaw.some((part, i) => {
|
|
17913
|
+
const rowIDPart = rowIDParts[i];
|
|
17914
|
+
return part !== rowIDPart;
|
|
17915
|
+
})) {
|
|
17916
|
+
// Trigger skip of this row
|
|
17917
|
+
return false;
|
|
17918
|
+
}
|
|
17919
|
+
foundState.start = true;
|
|
17849
17920
|
}
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
// Todo: Use schema to determine field type and use `Number.parseInt`
|
|
17854
|
-
// on other value instead of `String` conversions
|
|
17855
|
-
if (!foundState.start) {
|
|
17856
|
-
if (startsRaw.some((part, i) => {
|
|
17921
|
+
// This doesn't go in an `else` for the above in case the start is the end
|
|
17922
|
+
if (endsRaw.every((part, i) => {
|
|
17857
17923
|
const rowIDPart = rowIDParts[i];
|
|
17858
|
-
return part
|
|
17924
|
+
return part === rowIDPart;
|
|
17859
17925
|
})) {
|
|
17860
|
-
|
|
17861
|
-
|
|
17926
|
+
foundState.end = true;
|
|
17927
|
+
} else if (foundState.end) {
|
|
17928
|
+
// If no longer matching, trigger end of the table
|
|
17929
|
+
return true;
|
|
17862
17930
|
}
|
|
17863
|
-
|
|
17864
|
-
}
|
|
17865
|
-
// This doesn't go in an `else` for the above in case the start is the end
|
|
17866
|
-
if (endsRaw.every((part, i) => {
|
|
17867
|
-
const rowIDPart = rowIDParts[i];
|
|
17868
|
-
return part === rowIDPart;
|
|
17869
|
-
})) {
|
|
17870
|
-
foundState.end = true;
|
|
17871
|
-
} else if (foundState.end) {
|
|
17872
|
-
// If no longer matching, trigger end of the table
|
|
17873
|
-
return true;
|
|
17874
|
-
}
|
|
17875
|
-
return rowIDPartsPreferred.join('-'); // rowID;
|
|
17931
|
+
return rowIDPartsPreferred.join('-'); // rowID;
|
|
17932
|
+
};
|
|
17876
17933
|
};
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
|
|
17934
|
+
const getCheckedAndInterlinearFieldInfo = _ref10 => {
|
|
17935
|
+
let {
|
|
17936
|
+
localizedFieldNames
|
|
17937
|
+
} = _ref10;
|
|
17881
17938
|
let i = 1;
|
|
17882
17939
|
let field, checked;
|
|
17883
17940
|
let checkedFields = [];
|
|
@@ -17902,12 +17959,13 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
17902
17959
|
});
|
|
17903
17960
|
return [checkedFields, checkedFieldIndexes, allInterlinearColIndexes];
|
|
17904
17961
|
};
|
|
17905
|
-
const getCaption =
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17962
|
+
const getCaption = _ref11 => {
|
|
17963
|
+
let {
|
|
17964
|
+
starts,
|
|
17965
|
+
ends,
|
|
17966
|
+
applicableBrowseFieldNames,
|
|
17967
|
+
heading
|
|
17968
|
+
} = _ref11;
|
|
17911
17969
|
let caption;
|
|
17912
17970
|
const hasCaption = $pRaw('caption') !== '0';
|
|
17913
17971
|
if (hasCaption) {
|
|
@@ -17947,7 +18005,6 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
17947
18005
|
: ' ' // e.g., for 2nd space in "Surah 2 5-8"
|
|
17948
18006
|
);
|
|
17949
18007
|
}
|
|
17950
|
-
|
|
17951
18008
|
endVals.push(ends[i]);
|
|
17952
18009
|
return ret + startSep;
|
|
17953
18010
|
}, '').slice(0, -startSep.length);
|
|
@@ -17967,12 +18024,13 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
17967
18024
|
}
|
|
17968
18025
|
return [hasCaption, caption];
|
|
17969
18026
|
};
|
|
17970
|
-
const runPresort =
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
18027
|
+
const runPresort = _ref12 => {
|
|
18028
|
+
let {
|
|
18029
|
+
presort,
|
|
18030
|
+
tableData,
|
|
18031
|
+
applicableBrowseFieldNames,
|
|
18032
|
+
localizedFieldNames
|
|
18033
|
+
} = _ref12;
|
|
17976
18034
|
// Todo: Ought to be checking against an aliased table
|
|
17977
18035
|
if (presort) {
|
|
17978
18036
|
tableData.sort((rowA, rowB) => {
|
|
@@ -17984,22 +18042,23 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
17984
18042
|
precedence = rowBFirst ? 1 : -1;
|
|
17985
18043
|
return rowAFirst || rowBFirst; // Keep going if 0
|
|
17986
18044
|
});
|
|
17987
|
-
|
|
17988
18045
|
return precedence;
|
|
17989
18046
|
});
|
|
17990
18047
|
}
|
|
17991
18048
|
};
|
|
17992
|
-
const getFieldValueAliasMap =
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18049
|
+
const getFieldValueAliasMap = _ref13 => {
|
|
18050
|
+
let {
|
|
18051
|
+
schemaItems,
|
|
18052
|
+
fieldInfo,
|
|
18053
|
+
metadataObj,
|
|
18054
|
+
getFieldAliasOrName,
|
|
18055
|
+
usePreferAlias
|
|
18056
|
+
} = _ref13;
|
|
18057
|
+
return fieldInfo.map(_ref14 => {
|
|
18058
|
+
let {
|
|
18059
|
+
field,
|
|
18060
|
+
plugin
|
|
18061
|
+
} = _ref14;
|
|
18003
18062
|
if (plugin) {
|
|
18004
18063
|
return undefined;
|
|
18005
18064
|
}
|
|
@@ -18017,7 +18076,8 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18017
18076
|
return preferAlias !== false ? fieldValueAliasMap : undefined;
|
|
18018
18077
|
}
|
|
18019
18078
|
if (fieldValueAliasMap) {
|
|
18020
|
-
Object.entries(fieldValueAliasMap).forEach(
|
|
18079
|
+
Object.entries(fieldValueAliasMap).forEach(_ref15 => {
|
|
18080
|
+
let [key, val] = _ref15;
|
|
18021
18081
|
if (Array.isArray(val)) {
|
|
18022
18082
|
fieldValueAliasMap[key] = val.map(value => {
|
|
18023
18083
|
return Templates.resultsDisplayServerOrClient.fieldValueAlias({
|
|
@@ -18034,7 +18094,8 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18034
18094
|
value: val[preferAlias]
|
|
18035
18095
|
});
|
|
18036
18096
|
} else {
|
|
18037
|
-
Object.entries(val).forEach(
|
|
18097
|
+
Object.entries(val).forEach(_ref16 => {
|
|
18098
|
+
let [k, value] = _ref16;
|
|
18038
18099
|
fieldValueAliasMap[key][k] = Templates.resultsDisplayServerOrClient.fieldValueAlias({
|
|
18039
18100
|
key,
|
|
18040
18101
|
value
|
|
@@ -18084,13 +18145,12 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18084
18145
|
}
|
|
18085
18146
|
return key; // || p; // $p.get(param, true);
|
|
18086
18147
|
};
|
|
18087
|
-
|
|
18088
18148
|
const escapeCSS = escapeHTML;
|
|
18089
18149
|
const $pRawEsc = param => escapeHTML($pRaw(param));
|
|
18090
18150
|
const $pEscArbitrary = param => escapeHTML($p.get(param, true));
|
|
18091
18151
|
|
|
18092
18152
|
// Not currently in use
|
|
18093
|
-
const escapeQuotedCSS = s => s.replaceAll('\\', '\\\\').replaceAll('"',
|
|
18153
|
+
const escapeQuotedCSS = s => s.replaceAll('\\', '\\\\').replaceAll('"', String.raw`\"`);
|
|
18094
18154
|
const {
|
|
18095
18155
|
fileData,
|
|
18096
18156
|
workI18n,
|
|
@@ -18117,20 +18177,22 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18117
18177
|
schemaItems,
|
|
18118
18178
|
getFieldAliasOrName,
|
|
18119
18179
|
lang,
|
|
18120
|
-
callback({
|
|
18121
|
-
|
|
18122
|
-
|
|
18123
|
-
|
|
18124
|
-
|
|
18180
|
+
callback(_ref17) {
|
|
18181
|
+
let {
|
|
18182
|
+
setName,
|
|
18183
|
+
browseFields,
|
|
18184
|
+
presort
|
|
18185
|
+
} = _ref17;
|
|
18125
18186
|
setNames.push(setName);
|
|
18126
18187
|
presorts.push(presort);
|
|
18127
18188
|
browseFieldSets.push(browseFields);
|
|
18128
18189
|
}
|
|
18129
18190
|
});
|
|
18130
|
-
const fieldInfo = schemaItems.map(
|
|
18131
|
-
|
|
18132
|
-
|
|
18133
|
-
|
|
18191
|
+
const fieldInfo = schemaItems.map(_ref18 => {
|
|
18192
|
+
let {
|
|
18193
|
+
title: field,
|
|
18194
|
+
format
|
|
18195
|
+
} = _ref18;
|
|
18134
18196
|
return {
|
|
18135
18197
|
field,
|
|
18136
18198
|
fieldAliasOrName: getFieldAliasOrName(field) || field,
|
|
@@ -18147,23 +18209,25 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18147
18209
|
const {
|
|
18148
18210
|
lang
|
|
18149
18211
|
} = this; // array with first item as preferred
|
|
18150
|
-
pluginsForWork.iterateMappings(
|
|
18151
|
-
|
|
18152
|
-
|
|
18153
|
-
|
|
18154
|
-
|
|
18155
|
-
|
|
18156
|
-
|
|
18157
|
-
|
|
18158
|
-
|
|
18212
|
+
pluginsForWork.iterateMappings(_ref19 => {
|
|
18213
|
+
let {
|
|
18214
|
+
// plugin,
|
|
18215
|
+
pluginName,
|
|
18216
|
+
pluginLang,
|
|
18217
|
+
onByDefaultDefault,
|
|
18218
|
+
placement,
|
|
18219
|
+
applicableFields,
|
|
18220
|
+
meta
|
|
18221
|
+
} = _ref19;
|
|
18159
18222
|
placement = placement === 'end' ? Number.POSITIVE_INFINITY // push
|
|
18160
18223
|
: placement;
|
|
18161
|
-
const processField = ({
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18165
|
-
|
|
18166
|
-
|
|
18224
|
+
const processField = function () {
|
|
18225
|
+
let {
|
|
18226
|
+
applicableField,
|
|
18227
|
+
targetLanguage,
|
|
18228
|
+
onByDefault,
|
|
18229
|
+
metaApplicableField
|
|
18230
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18167
18231
|
const plugin = pluginsForWork.getPluginObject(pluginName) || {};
|
|
18168
18232
|
const applicableFieldLang = metadata.getFieldLang(applicableField);
|
|
18169
18233
|
if (plugin.getTargetLanguage) {
|
|
@@ -18229,9 +18293,10 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18229
18293
|
}
|
|
18230
18294
|
const localizedFieldNames = fieldInfo.map(fi => fi.fieldAliasOrName);
|
|
18231
18295
|
const escapeColumnIndexes = fieldInfo.map(fi => fi.escapeColumn);
|
|
18232
|
-
const fieldLangs = fieldInfo.map(
|
|
18233
|
-
|
|
18234
|
-
|
|
18296
|
+
const fieldLangs = fieldInfo.map(_ref20 => {
|
|
18297
|
+
let {
|
|
18298
|
+
fieldLang
|
|
18299
|
+
} = _ref20;
|
|
18235
18300
|
return fieldLang !== preferredLocale ? fieldLang : null;
|
|
18236
18301
|
});
|
|
18237
18302
|
const fieldValueAliasMap = getFieldValueAliasMap({
|
|
@@ -18254,8 +18319,20 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18254
18319
|
const localizeParamNames = $p.localizeParamNames = $p.has('i18n', true) ? $p.get('i18n', true) === '1' : prefI18n === 'true' || prefI18n !== 'false' && this.localizeParamNames;
|
|
18255
18320
|
const lParam = localizeParamNames ? key => l(['params', key]) : key => key;
|
|
18256
18321
|
const lIndexedParam = localizeParamNames ? key => l(['params', 'indexed', key]) : key => key;
|
|
18257
|
-
const lParamRaw = localizeParamNames ?
|
|
18258
|
-
|
|
18322
|
+
const lParamRaw = localizeParamNames ? function (key) {
|
|
18323
|
+
let suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
18324
|
+
return $p.get(lParam(key) + suffix, true);
|
|
18325
|
+
} : function (key) {
|
|
18326
|
+
let suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
18327
|
+
return $p.get(key + suffix, true);
|
|
18328
|
+
};
|
|
18329
|
+
const lIndexedParamRaw = localizeParamNames ? function (key) {
|
|
18330
|
+
let suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
18331
|
+
return $p.get($p.get('work') + '-' + lIndexedParam(key) + suffix, true);
|
|
18332
|
+
} : function (key) {
|
|
18333
|
+
let suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
18334
|
+
return $p.get($p.get('work') + '-' + key + suffix, true);
|
|
18335
|
+
};
|
|
18259
18336
|
|
|
18260
18337
|
// Now that we know `browseFieldSets`, we can parse `startEnd`
|
|
18261
18338
|
const browseFieldSetStartEndIdx = browseFieldSets.findIndex((item, i) => {
|
|
@@ -18340,7 +18417,8 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18340
18417
|
// Look to dealias
|
|
18341
18418
|
const fvEntries = Object.entries(rawFieldValueAliasMap);
|
|
18342
18419
|
if (Array.isArray(fvEntries[0][1])) {
|
|
18343
|
-
fvEntries.some(
|
|
18420
|
+
fvEntries.some(_ref21 => {
|
|
18421
|
+
let [key, arr] = _ref21;
|
|
18344
18422
|
if (arr.includes(v)) {
|
|
18345
18423
|
dealiased = key;
|
|
18346
18424
|
return true;
|
|
@@ -18348,7 +18426,8 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18348
18426
|
return false;
|
|
18349
18427
|
});
|
|
18350
18428
|
} else {
|
|
18351
|
-
fvEntries.some(
|
|
18429
|
+
fvEntries.some(_ref22 => {
|
|
18430
|
+
let [key, obj] = _ref22;
|
|
18352
18431
|
const arr = Object.values(obj);
|
|
18353
18432
|
if (arr.includes(v)) {
|
|
18354
18433
|
dealiased = key;
|
|
@@ -18379,11 +18458,12 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18379
18458
|
// Todo: Fetch the work in code based on the non-localized `datafileName`
|
|
18380
18459
|
const dbName = this.namespace + '-textbrowser-cache-data';
|
|
18381
18460
|
const req = indexedDB.open(dbName);
|
|
18382
|
-
req.onsuccess =
|
|
18383
|
-
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18461
|
+
req.onsuccess = _ref23 => {
|
|
18462
|
+
let {
|
|
18463
|
+
target: {
|
|
18464
|
+
result: db
|
|
18465
|
+
}
|
|
18466
|
+
} = _ref23;
|
|
18387
18467
|
const storeName = 'files-to-cache-' + unlocalizedWorkName;
|
|
18388
18468
|
const trans = db.transaction(storeName);
|
|
18389
18469
|
const store = trans.objectStore(storeName);
|
|
@@ -18395,11 +18475,12 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18395
18475
|
// console.log('applicableBrowseFieldSetName', 'browseFields-' + applicableBrowseFieldSetName);
|
|
18396
18476
|
|
|
18397
18477
|
const r = index.getAll(IDBKeyRange.bound(startsRaw, endsRaw));
|
|
18398
|
-
r.onsuccess =
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18478
|
+
r.onsuccess = _ref24 => {
|
|
18479
|
+
let {
|
|
18480
|
+
target: {
|
|
18481
|
+
result
|
|
18482
|
+
}
|
|
18483
|
+
} = _ref24;
|
|
18403
18484
|
const converted = result.map(r => r.value);
|
|
18404
18485
|
resolve(converted);
|
|
18405
18486
|
};
|
|
@@ -18439,10 +18520,11 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18439
18520
|
}
|
|
18440
18521
|
}
|
|
18441
18522
|
if (!usingServerData && pluginsForWork) {
|
|
18442
|
-
fieldInfo.forEach(
|
|
18443
|
-
|
|
18444
|
-
|
|
18445
|
-
|
|
18523
|
+
fieldInfo.forEach(_ref25 => {
|
|
18524
|
+
let {
|
|
18525
|
+
plugin,
|
|
18526
|
+
placement
|
|
18527
|
+
} = _ref25;
|
|
18446
18528
|
if (!plugin) {
|
|
18447
18529
|
return;
|
|
18448
18530
|
}
|
|
@@ -18452,20 +18534,21 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18452
18534
|
);
|
|
18453
18535
|
});
|
|
18454
18536
|
});
|
|
18455
|
-
|
|
18456
|
-
|
|
18457
|
-
|
|
18458
|
-
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18537
|
+
fieldInfo.forEach((_ref26, j) => {
|
|
18538
|
+
let {
|
|
18539
|
+
plugin,
|
|
18540
|
+
applicableField,
|
|
18541
|
+
fieldLang,
|
|
18542
|
+
meta,
|
|
18543
|
+
metaApplicableField
|
|
18544
|
+
} = _ref26;
|
|
18463
18545
|
if (!plugin) {
|
|
18464
18546
|
return;
|
|
18465
18547
|
}
|
|
18466
|
-
const applicableFieldIdx = fieldInfo.findIndex(
|
|
18467
|
-
|
|
18468
|
-
|
|
18548
|
+
const applicableFieldIdx = fieldInfo.findIndex(_ref27 => {
|
|
18549
|
+
let {
|
|
18550
|
+
field
|
|
18551
|
+
} = _ref27;
|
|
18469
18552
|
return field === applicableField;
|
|
18470
18553
|
});
|
|
18471
18554
|
// Now safe to pass (and set) `j` value as tr array expanded
|
|
@@ -18556,8 +18639,6 @@ const resultsDisplayServerOrClient = async function resultsDisplayServerOrClient
|
|
|
18556
18639
|
};
|
|
18557
18640
|
};
|
|
18558
18641
|
|
|
18559
|
-
/* eslint-enable no-unused-vars, @stylistic/brace-style */
|
|
18560
|
-
|
|
18561
18642
|
/**
|
|
18562
18643
|
*
|
|
18563
18644
|
* @returns {Promise<void>}
|
|
@@ -18660,7 +18741,7 @@ async function requestPermissions(langs, l) {
|
|
|
18660
18741
|
// rememberRefusal();
|
|
18661
18742
|
resolve();
|
|
18662
18743
|
return;
|
|
18663
|
-
// eslint-disable-next-line sonarjs/no-duplicated-branches
|
|
18744
|
+
// eslint-disable-next-line sonarjs/no-duplicated-branches -- Ease of maintenance
|
|
18664
18745
|
case 'default':
|
|
18665
18746
|
resolve();
|
|
18666
18747
|
return;
|
|
@@ -18695,7 +18776,7 @@ class TextBrowser {
|
|
|
18695
18776
|
const stylesheets = options.stylesheets || ['@builtin'];
|
|
18696
18777
|
const builtinIndex = stylesheets.indexOf('@builtin');
|
|
18697
18778
|
if (builtinIndex !== -1) {
|
|
18698
|
-
stylesheets.splice(builtinIndex, 1, new URL(new URL('assets/index-
|
|
18779
|
+
stylesheets.splice(builtinIndex, 1, new URL(new URL('assets/index-D_XVedS3.css', import.meta.url).href, import.meta.url).href);
|
|
18699
18780
|
}
|
|
18700
18781
|
this.stylesheets = stylesheets;
|
|
18701
18782
|
setServiceWorkerDefaults(this, options);
|
|
@@ -18735,10 +18816,11 @@ class TextBrowser {
|
|
|
18735
18816
|
}
|
|
18736
18817
|
getWorkData(opts) {
|
|
18737
18818
|
try {
|
|
18738
|
-
return getWorkData.call(this,
|
|
18819
|
+
return getWorkData.call(this, {
|
|
18820
|
+
...opts,
|
|
18739
18821
|
files: this.files,
|
|
18740
18822
|
allowPlugins: this.allowPlugins
|
|
18741
|
-
})
|
|
18823
|
+
});
|
|
18742
18824
|
} catch (err) {
|
|
18743
18825
|
console.log('err', err);
|
|
18744
18826
|
dialogs.alert('catch:' + err);
|
|
@@ -18758,14 +18840,16 @@ class TextBrowser {
|
|
|
18758
18840
|
});
|
|
18759
18841
|
}
|
|
18760
18842
|
getFieldNameAndValueAliases(args) {
|
|
18761
|
-
return getFieldNameAndValueAliases(
|
|
18843
|
+
return getFieldNameAndValueAliases({
|
|
18844
|
+
...args,
|
|
18762
18845
|
lang: this.lang
|
|
18763
|
-
})
|
|
18846
|
+
});
|
|
18764
18847
|
}
|
|
18765
18848
|
getBrowseFieldData(args) {
|
|
18766
|
-
return getBrowseFieldData(
|
|
18849
|
+
return getBrowseFieldData({
|
|
18850
|
+
...args,
|
|
18767
18851
|
lang: this.lang
|
|
18768
|
-
})
|
|
18852
|
+
});
|
|
18769
18853
|
}
|
|
18770
18854
|
async paramChange() {
|
|
18771
18855
|
Templates.defaultBody();
|
|
@@ -18784,7 +18868,6 @@ class TextBrowser {
|
|
|
18784
18868
|
empty: true
|
|
18785
18869
|
}), document.title, url);
|
|
18786
18870
|
// Get and set new state within URL
|
|
18787
|
-
// eslint-disable-next-line n/callback-return
|
|
18788
18871
|
cb();
|
|
18789
18872
|
location.hash = '#' + $p.toString();
|
|
18790
18873
|
};
|
|
@@ -18809,10 +18892,11 @@ class TextBrowser {
|
|
|
18809
18892
|
messageStyle: 'plainNested',
|
|
18810
18893
|
locales: lang,
|
|
18811
18894
|
defaultLocales: fallbackLanguages,
|
|
18812
|
-
localeStringFinder({
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18895
|
+
localeStringFinder(_ref) {
|
|
18896
|
+
let {
|
|
18897
|
+
locales,
|
|
18898
|
+
defaultLocales
|
|
18899
|
+
} = _ref;
|
|
18816
18900
|
const locale = [...locales, ...defaultLocales].find(language => {
|
|
18817
18901
|
return language in localizationStrings;
|
|
18818
18902
|
});
|