unicode-input-toolconverter 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/out.json +8980 -1849
- package/CHANGES.md +15 -1
- package/README.md +6 -11
- package/_locales/en-US/messages.json +153 -6
- package/_locales/hu-HU/messages.json +153 -6
- package/_locales/pt-BR/messages.json +153 -6
- package/_locales/sv-SE/messages.json +153 -6
- package/babel.config.json +0 -1
- package/browser_action/characterSelection.js +18 -11
- package/browser_action/charrefConverters.js +286 -79
- package/browser_action/chartBuild.js +97 -27
- package/browser_action/encodingBehaviors.js +10 -7
- package/browser_action/entityBehaviors.js +42 -16
- package/browser_action/index-es.html +13 -1
- package/browser_action/index-instrumented.html +13 -1
- package/browser_action/index-pages.html +13 -1
- package/browser_action/index.html +13 -1
- package/browser_action/index.iife.min.js +9 -1
- package/browser_action/index.iife.min.js.map +1 -1
- package/browser_action/index.instrumented.iife.min.js +1 -1
- package/browser_action/index.instrumented.iife.min.js.map +1 -1
- package/browser_action/index.js +5 -5
- package/browser_action/preferences/prefDefaults.js +12 -3
- package/browser_action/service-worker/sw-activateCallback.js +1 -2
- package/browser_action/service-worker/sw-resources.json +6 -4
- package/browser_action/templateUtils/elements.js +12 -1
- package/browser_action/templateUtils/fill.js +6 -0
- package/browser_action/templateUtils/validation.js +4 -1
- package/browser_action/templates/chartBuild.js +167 -102
- package/browser_action/templates/index.js +227 -53
- package/browser_action/templatesElementCustomization/widgets.js +40 -15
- package/browser_action/unicode/UnicodeConverter.js +99 -73
- package/browser_action/unicode/charrefunicodeDb.js +100 -50
- package/browser_action/unicode/getScriptInfoForCodePoint.js +13 -4
- package/browser_action/unicode/hangul.js +27 -20
- package/browser_action/unicode/lastScriptNames.json +1 -1
- package/browser_action/unicode/parseUnihanFromTextFileStrings.js +44 -25
- package/browser_action/unicode/unicodeFieldInfo.js +112 -90
- package/browser_action/unicode/unicodeScripts.js +409 -35
- package/browser_action/unicode/unihan.js +4 -3
- package/browser_action/unicode/unihanDbPopulate.js +7 -2
- package/browser_action/unicode/unihanFields.js +34 -0
- package/browser_action/unicodecharref.js +353 -190
- package/browser_action/utils/DOMUtils.js +95 -34
- package/browser_action/utils/FetchUtils.js +7 -6
- package/browser_action/utils/TextUtils.js +4 -4
- package/browser_action/utils/TypedArrayUtils.js +9 -5
- package/browser_action/utils/semicolonSeparatedToArray.js +3 -3
- package/browser_action/utils/setupServiceWorker.js +2 -2
- package/eslint.config.js +11 -0
- package/icons/openWindow16.png +0 -0
- package/icons/openWindow24.png +0 -0
- package/lib/background.html +7 -0
- package/lib/background.js +2 -2
- package/package.json +80 -70
- package/pnpm-workspace.yaml +8 -0
- package/server.js +66 -51
- package/sw.js +97 -56
- package/tools/entities-import.js +4 -1
- package/tools/findEsResources.js +33 -10
- package/tools/fix-sw-resources-vendor-paths.js +60 -0
- package/tools/list-locales.js +2 -2
- package/tools/parseUnicodeCharts.js +126 -60
- package/tools/ucd-import.js +1 -10
- package/tools/unicode-charts.html +49 -20
- package/tools/unihan-import.js +45 -15
- package/tools/write-sw-version.js +16 -0
- package/tsconfig.json +23 -0
- package/typings/__coverage__.d.ts +5 -0
- package/typings/apple-system-profiler.d.ts +17 -0
- package/typings/commands.d.ts +19 -0
- package/typings/json-6.d.ts +4 -0
- package/typings/rollup-plugin-istanbul.d.ts +3 -0
- package/vendor/camelcase/index.d.ts +154 -0
- package/vendor/camelcase/index.js +137 -23
- package/vendor/fflate/esm/browser.d.ts +1539 -0
- package/vendor/fflate/esm/browser.js +82 -55
- package/vendor/intl-dom/dist/Formatter.d.ts +120 -0
- package/vendor/intl-dom/dist/Formatter.d.ts.map +1 -0
- package/vendor/intl-dom/dist/collation.d.ts +42 -0
- package/vendor/intl-dom/dist/collation.d.ts.map +1 -0
- package/vendor/intl-dom/dist/defaultAllSubstitutions.d.ts +52 -0
- package/vendor/intl-dom/dist/defaultAllSubstitutions.d.ts.map +1 -0
- package/vendor/intl-dom/dist/defaultInsertNodes.d.ts +96 -0
- package/vendor/intl-dom/dist/defaultInsertNodes.d.ts.map +1 -0
- package/vendor/intl-dom/dist/defaultKeyCheckerConverter.d.ts +17 -0
- package/vendor/intl-dom/dist/defaultKeyCheckerConverter.d.ts.map +1 -0
- package/vendor/intl-dom/dist/defaultLocaleResolver.d.ts +285 -0
- package/vendor/intl-dom/dist/defaultLocaleResolver.d.ts.map +1 -0
- package/vendor/intl-dom/dist/findLocaleStrings.d.ts +88 -0
- package/vendor/intl-dom/dist/findLocaleStrings.d.ts.map +1 -0
- package/vendor/intl-dom/dist/getDOMForLocaleString.d.ts +67 -0
- package/vendor/intl-dom/dist/getDOMForLocaleString.d.ts.map +1 -0
- package/vendor/intl-dom/dist/getMessageForKeyByStyle.d.ts +73 -0
- package/vendor/intl-dom/dist/getMessageForKeyByStyle.d.ts.map +1 -0
- package/vendor/intl-dom/dist/getStringFromMessageAndDefaults.d.ts +26 -0
- package/vendor/intl-dom/dist/getStringFromMessageAndDefaults.d.ts.map +1 -0
- package/vendor/intl-dom/dist/i18n.d.ts +113 -0
- package/vendor/intl-dom/dist/i18n.d.ts.map +1 -0
- package/vendor/intl-dom/dist/index.d.ts +92 -0
- package/vendor/intl-dom/dist/index.d.ts.map +1 -0
- package/vendor/intl-dom/dist/index.esm.d.ts +34 -0
- package/vendor/intl-dom/dist/index.esm.js +854 -896
- package/vendor/intl-dom/dist/index.esm.min.js +4 -0
- package/vendor/intl-dom/dist/index.esm.min.js.map +1 -0
- package/vendor/intl-dom/dist/index.umd.js +2953 -0
- package/vendor/intl-dom/dist/index.umd.min.js +4 -0
- package/vendor/intl-dom/dist/index.umd.min.js.map +1 -0
- package/vendor/intl-dom/dist/promiseChainForValues.d.ts +34 -0
- package/vendor/intl-dom/dist/promiseChainForValues.d.ts.map +1 -0
- package/vendor/intl-dom/dist/shared.d.ts +20 -0
- package/vendor/intl-dom/dist/shared.d.ts.map +1 -0
- package/vendor/intl-dom/dist/utils.d.ts +53 -0
- package/vendor/intl-dom/dist/utils.d.ts.map +1 -0
- package/vendor/jamilih/dist/jml.d.mts +468 -0
- package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +1489 -343
- package/vendor/jquery/dist/jquery.js +1677 -2713
- package/vendor/json-6/dist/index.mjs +2 -0
- package/vendor/miller-columns/CHANGES.md +185 -0
- package/vendor/miller-columns/LICENSE-MIT.txt +21 -0
- package/vendor/miller-columns/README.md +249 -0
- package/vendor/miller-columns/demos/index.html +69 -0
- package/vendor/miller-columns/demos/index.js +72 -0
- package/vendor/miller-columns/dist/index-es.js +748 -0
- package/vendor/miller-columns/dist/index-es.min.d.ts +25 -0
- package/vendor/miller-columns/dist/index-es.min.js +7 -1
- package/vendor/miller-columns/dist/index-umd.js +757 -0
- package/vendor/miller-columns/dist/index-umd.min.js +7 -0
- package/vendor/miller-columns/dist/index.d.ts +25 -0
- package/vendor/miller-columns/dist/millerColumns.d.ts +10 -0
- package/vendor/miller-columns/eslint.config.js +46 -0
- package/vendor/miller-columns/fix-declarations.js +18 -0
- package/vendor/miller-columns/miller-columns.css +24 -1
- package/vendor/miller-columns/package.json +73 -0
- package/vendor/miller-columns/pnpm-workspace.yaml +2 -0
- package/vendor/miller-columns/src/index.js +642 -0
- package/vendor/miller-columns/src/millerColumns.ts +12 -0
- package/vendor/miller-columns/tsconfig-prod.json +23 -0
- package/vendor/miller-columns/tsconfig.json +21 -0
- package/vendor/simple-prefs/dist/index.esm.d.ts +1 -0
- package/vendor/simple-prefs/dist/index.esm.js +164 -216
- package/vendor/simple-prefs/dist/simple-prefs.d.ts +117 -0
- package/lgtm.yml +0 -5
|
@@ -1,7 +1,38 @@
|
|
|
1
|
-
import {$} from '
|
|
1
|
+
// import {$} from 'jamilih/dist/jml.js';
|
|
2
2
|
import {getUnicodeDefaults} from './preferences/prefDefaults.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} sel
|
|
6
|
+
*/
|
|
7
|
+
const $ = (sel) => {
|
|
8
|
+
return /** @type {HTMLElement} */ (document.querySelector(sel));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} sel
|
|
13
|
+
*/
|
|
14
|
+
const $i = (sel) => {
|
|
15
|
+
return /** @type {HTMLInputElement} */ (document.querySelector(sel));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @type {InstanceType<ReturnType<
|
|
20
|
+
* typeof import('./unicode/UnicodeConverter.js').getUnicodeConverter
|
|
21
|
+
* >>}
|
|
22
|
+
*/
|
|
23
|
+
let charrefunicodeConverter;
|
|
24
|
+
|
|
25
|
+
/** @type {ReturnType<typeof getUnicodeDefaults>['getPref']} */
|
|
26
|
+
let getPref;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {{
|
|
30
|
+
* charrefunicodeConverter: InstanceType<ReturnType<
|
|
31
|
+
* typeof import('./unicode/UnicodeConverter.js').getUnicodeConverter
|
|
32
|
+
* >>
|
|
33
|
+
* }} cfg
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*/
|
|
5
36
|
export const shareVars = ({
|
|
6
37
|
// _: l10n,
|
|
7
38
|
charrefunicodeConverter: _uc
|
|
@@ -24,113 +55,201 @@ function classChange (el) {
|
|
|
24
55
|
}
|
|
25
56
|
|
|
26
57
|
const CharrefConverterBridges = {
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} out
|
|
60
|
+
* @param {HTMLElement} el
|
|
61
|
+
*/
|
|
27
62
|
charref2unicodeval (out, el) {
|
|
28
63
|
classChange(el);
|
|
29
64
|
return charrefunicodeConverter.charref2unicodeval(out);
|
|
30
65
|
},
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} out
|
|
68
|
+
* @param {HTMLElement} el
|
|
69
|
+
*/
|
|
31
70
|
async charref2htmlentsval (out, el) {
|
|
32
71
|
classChange(el);
|
|
33
72
|
return await charrefunicodeConverter.charref2htmlentsval(out);
|
|
34
73
|
},
|
|
74
|
+
/**
|
|
75
|
+
* @param {string} unicodeToConvert
|
|
76
|
+
* @param {HTMLElement} el
|
|
77
|
+
* @param {boolean} [leaveSurrogates]
|
|
78
|
+
*/
|
|
35
79
|
async unicode2charrefDecval (unicodeToConvert, el, leaveSurrogates) {
|
|
36
80
|
classChange(el);
|
|
37
81
|
return await charrefunicodeConverter.unicode2charrefDecval(
|
|
38
82
|
unicodeToConvert, leaveSurrogates
|
|
39
83
|
);
|
|
40
84
|
},
|
|
85
|
+
/**
|
|
86
|
+
* @param {string} unicodeToConvert
|
|
87
|
+
* @param {HTMLElement} el
|
|
88
|
+
* @param {boolean} [leaveSurrogates]
|
|
89
|
+
* @param {import('./unicode/UnicodeConverter.js').UnicodeEscapeMode} [type]
|
|
90
|
+
*/
|
|
41
91
|
async unicode2charrefHexval (unicodeToConvert, el, leaveSurrogates, type) {
|
|
42
92
|
classChange(el);
|
|
43
93
|
return await charrefunicodeConverter.unicode2charrefHexval(
|
|
44
94
|
unicodeToConvert, leaveSurrogates, type
|
|
45
95
|
);
|
|
46
96
|
},
|
|
97
|
+
/**
|
|
98
|
+
* @param {string} unicodeToConvert
|
|
99
|
+
* @param {HTMLElement} el
|
|
100
|
+
*/
|
|
47
101
|
async unicode2htmlentsval (unicodeToConvert, el) {
|
|
48
102
|
classChange(el);
|
|
49
103
|
return await charrefunicodeConverter.unicode2htmlentsval(
|
|
50
104
|
unicodeToConvert
|
|
51
105
|
);
|
|
52
106
|
},
|
|
107
|
+
/**
|
|
108
|
+
* @param {string} out
|
|
109
|
+
* @param {HTMLElement} el
|
|
110
|
+
*/
|
|
53
111
|
async htmlents2charrefDecval (out, el) {
|
|
54
112
|
classChange(el);
|
|
55
113
|
return await charrefunicodeConverter.htmlents2charrefDecval(out);
|
|
56
114
|
},
|
|
115
|
+
/**
|
|
116
|
+
* @param {string} out
|
|
117
|
+
* @param {HTMLElement} el
|
|
118
|
+
*/
|
|
57
119
|
async htmlents2charrefHexval (out, el) {
|
|
58
120
|
classChange(el);
|
|
59
121
|
return await charrefunicodeConverter.htmlents2charrefHexval(out);
|
|
60
122
|
},
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} out
|
|
125
|
+
* @param {HTMLElement} el
|
|
126
|
+
*/
|
|
61
127
|
async htmlents2unicodeval (out, el) {
|
|
62
128
|
classChange(el);
|
|
63
129
|
return await charrefunicodeConverter.htmlents2unicodeval(out);
|
|
64
130
|
},
|
|
131
|
+
/**
|
|
132
|
+
* @param {string} out
|
|
133
|
+
* @param {HTMLElement} el
|
|
134
|
+
*/
|
|
65
135
|
hex2decval (out, el) {
|
|
66
136
|
classChange(el);
|
|
67
137
|
return charrefunicodeConverter.hex2decval(out);
|
|
68
138
|
},
|
|
139
|
+
/**
|
|
140
|
+
* @param {string} out
|
|
141
|
+
* @param {HTMLElement} el
|
|
142
|
+
*/
|
|
69
143
|
async dec2hexval (out, el) {
|
|
70
144
|
classChange(el);
|
|
71
145
|
return await charrefunicodeConverter.dec2hexval(out);
|
|
72
146
|
},
|
|
147
|
+
/**
|
|
148
|
+
* @param {Event} e
|
|
149
|
+
*/
|
|
73
150
|
async unicodeTo6Digit (e) {
|
|
74
|
-
const toconvert = $('#toconvert').value;
|
|
75
|
-
await this.unicodeTo6DigitVal(
|
|
151
|
+
const toconvert = /** @type {HTMLInputElement} */ ($i('#toconvert')).value;
|
|
152
|
+
await this.unicodeTo6DigitVal(
|
|
153
|
+
toconvert,
|
|
154
|
+
/** @type {HTMLElement} */ (e.target)
|
|
155
|
+
);
|
|
76
156
|
return false;
|
|
77
157
|
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @param {string} toconvert
|
|
161
|
+
* @param {HTMLElement} el
|
|
162
|
+
*/
|
|
78
163
|
async unicodeTo6DigitVal (toconvert, el) {
|
|
79
164
|
classChange(el);
|
|
80
165
|
const val = await charrefunicodeConverter.unicodeTo6DigitVal(
|
|
81
166
|
toconvert
|
|
82
167
|
);
|
|
83
|
-
$('#converted').value = val;
|
|
168
|
+
$i('#converted').value = val;
|
|
84
169
|
return val;
|
|
85
170
|
},
|
|
171
|
+
/**
|
|
172
|
+
* @param {Event} e
|
|
173
|
+
*/
|
|
86
174
|
async charref2unicode (e) {
|
|
87
|
-
let toconvert = $('#toconvert').value;
|
|
175
|
+
let toconvert = $i('#toconvert').value;
|
|
88
176
|
if (await getPref('ampspace')) {
|
|
89
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
177
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
90
178
|
}
|
|
91
|
-
$('#converted').value = this.charref2unicodeval(
|
|
179
|
+
$i('#converted').value = this.charref2unicodeval(
|
|
180
|
+
toconvert,
|
|
181
|
+
/** @type {HTMLElement} */
|
|
182
|
+
(e.target)
|
|
183
|
+
);
|
|
92
184
|
return false;
|
|
93
185
|
},
|
|
186
|
+
/**
|
|
187
|
+
* @param {Event} e
|
|
188
|
+
*/
|
|
94
189
|
async charref2htmlents (e) {
|
|
95
|
-
let toconvert = $('#toconvert').value;
|
|
190
|
+
let toconvert = $i('#toconvert').value;
|
|
96
191
|
if (await getPref('ampspace')) {
|
|
97
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
192
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
98
193
|
}
|
|
99
|
-
$('#converted').value = await this.charref2htmlentsval(
|
|
194
|
+
$i('#converted').value = await this.charref2htmlentsval(
|
|
195
|
+
toconvert,
|
|
196
|
+
/** @type {HTMLElement} */ (e.target)
|
|
197
|
+
);
|
|
100
198
|
return false;
|
|
101
199
|
},
|
|
200
|
+
/**
|
|
201
|
+
* @param {Event} e
|
|
202
|
+
* @param {boolean} [leaveSurrogates]
|
|
203
|
+
* @returns {Promise<false>}
|
|
204
|
+
*/
|
|
102
205
|
async unicode2charrefDec (e, leaveSurrogates) {
|
|
103
|
-
let toconvert = $('#toconvert').value;
|
|
206
|
+
let toconvert = $i('#toconvert').value;
|
|
104
207
|
if (await getPref('ampspace')) {
|
|
105
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
208
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
106
209
|
}
|
|
107
|
-
$('#converted').value = await this.unicode2charrefDecval(
|
|
108
|
-
toconvert, e.target, leaveSurrogates
|
|
210
|
+
$i('#converted').value = await this.unicode2charrefDecval(
|
|
211
|
+
toconvert, /** @type {HTMLElement} */ (e.target), leaveSurrogates
|
|
109
212
|
);
|
|
110
213
|
return false;
|
|
111
214
|
},
|
|
215
|
+
/**
|
|
216
|
+
* @param {Event} e
|
|
217
|
+
*/
|
|
112
218
|
async unicode2charrefDecSurrogate (e) {
|
|
113
219
|
return await this.unicode2charrefDec(e, true);
|
|
114
220
|
},
|
|
221
|
+
/**
|
|
222
|
+
* @param {Event} e
|
|
223
|
+
* @param {boolean} [leaveSurrogates]
|
|
224
|
+
*/
|
|
115
225
|
async unicode2charrefHex (e, leaveSurrogates) {
|
|
116
|
-
let toconvert = $('#toconvert').value;
|
|
226
|
+
let toconvert = $i('#toconvert').value;
|
|
117
227
|
if (await getPref('ampspace')) {
|
|
118
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
228
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/v, '&$1');
|
|
119
229
|
}
|
|
120
|
-
$('#converted').value = await this.unicode2charrefHexval(
|
|
121
|
-
toconvert, e.target, leaveSurrogates
|
|
230
|
+
$i('#converted').value = await this.unicode2charrefHexval(
|
|
231
|
+
toconvert, /** @type {HTMLElement} */ (e.target), leaveSurrogates
|
|
122
232
|
);
|
|
123
233
|
return false;
|
|
124
234
|
},
|
|
235
|
+
/**
|
|
236
|
+
* @param {Event} e
|
|
237
|
+
*/
|
|
125
238
|
async unicode2charrefHexSurrogate (e) {
|
|
126
239
|
return await this.unicode2charrefHex(e, true);
|
|
127
240
|
},
|
|
241
|
+
/**
|
|
242
|
+
* @param {Event} e
|
|
243
|
+
*/
|
|
128
244
|
async unicode2htmlents (e) {
|
|
129
|
-
let toconvert = $('#toconvert').value;
|
|
245
|
+
let toconvert = $i('#toconvert').value;
|
|
130
246
|
if (await getPref('ampspace')) {
|
|
131
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
247
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
132
248
|
}
|
|
133
|
-
$('#converted').value =
|
|
249
|
+
$i('#converted').value =
|
|
250
|
+
await this.unicode2htmlentsval(
|
|
251
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
252
|
+
);
|
|
134
253
|
return false;
|
|
135
254
|
},
|
|
136
255
|
/**
|
|
@@ -139,13 +258,13 @@ const CharrefConverterBridges = {
|
|
|
139
258
|
* replaced
|
|
140
259
|
* @param {HTMLElement} el The (button) element whose class will be changed to
|
|
141
260
|
* reflect that the action has been activated
|
|
142
|
-
* @returns {string} The passed-in string with Unicode replaced with
|
|
261
|
+
* @returns {Promise<string>} The passed-in string with Unicode replaced with
|
|
143
262
|
* description escape sequences
|
|
144
263
|
*/
|
|
145
264
|
async unicode2CharDescVal (toconvert, el) {
|
|
146
265
|
classChange(el);
|
|
147
266
|
const val = await charrefunicodeConverter.unicode2CharDescVal(toconvert);
|
|
148
|
-
$('#converted').value = val;
|
|
267
|
+
$i('#converted').value = val;
|
|
149
268
|
return val;
|
|
150
269
|
},
|
|
151
270
|
/**
|
|
@@ -159,57 +278,106 @@ const CharrefConverterBridges = {
|
|
|
159
278
|
async charDesc2UnicodeVal (toconvert, el) {
|
|
160
279
|
classChange(el);
|
|
161
280
|
const val = await charrefunicodeConverter.charDesc2UnicodeVal(toconvert);
|
|
162
|
-
$('#converted').value = val;
|
|
281
|
+
$i('#converted').value = val;
|
|
163
282
|
return val;
|
|
164
283
|
},
|
|
284
|
+
/**
|
|
285
|
+
* @param {Event} e
|
|
286
|
+
*/
|
|
165
287
|
async charDesc2Unicode (e) {
|
|
166
|
-
const toconvert = $('#toconvert').value;
|
|
167
|
-
await this.charDesc2UnicodeVal(
|
|
288
|
+
const toconvert = $i('#toconvert').value;
|
|
289
|
+
await this.charDesc2UnicodeVal(
|
|
290
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
291
|
+
);
|
|
168
292
|
return false;
|
|
169
293
|
},
|
|
294
|
+
/**
|
|
295
|
+
* @param {Event} e
|
|
296
|
+
*/
|
|
170
297
|
async unicode2CharDesc (e) {
|
|
171
|
-
const toconvert = $('#toconvert').value;
|
|
172
|
-
await this.unicode2CharDescVal(
|
|
298
|
+
const toconvert = $i('#toconvert').value;
|
|
299
|
+
await this.unicode2CharDescVal(
|
|
300
|
+
toconvert,
|
|
301
|
+
/** @type {HTMLElement} */ (e.target)
|
|
302
|
+
);
|
|
173
303
|
return false;
|
|
174
304
|
},
|
|
305
|
+
/**
|
|
306
|
+
* @param {string} toconvert
|
|
307
|
+
* @param {HTMLElement} el
|
|
308
|
+
*/
|
|
175
309
|
async unicode2jsescapeval (toconvert, el) {
|
|
176
310
|
classChange(el);
|
|
177
311
|
const val = await charrefunicodeConverter.unicode2jsescapeval(toconvert);
|
|
178
|
-
$('#converted').value = val;
|
|
312
|
+
$i('#converted').value = val;
|
|
179
313
|
return val;
|
|
180
314
|
},
|
|
315
|
+
/**
|
|
316
|
+
* @param {Event} e
|
|
317
|
+
*/
|
|
181
318
|
async unicode2jsescape (e) {
|
|
182
|
-
const toconvert = $('#toconvert').value;
|
|
183
|
-
await this.unicode2jsescapeval(
|
|
319
|
+
const toconvert = $i('#toconvert').value;
|
|
320
|
+
await this.unicode2jsescapeval(
|
|
321
|
+
toconvert,
|
|
322
|
+
/** @type {HTMLElement} */ (e.target)
|
|
323
|
+
);
|
|
184
324
|
return false;
|
|
185
325
|
},
|
|
326
|
+
/**
|
|
327
|
+
* @param {Event} e
|
|
328
|
+
*/
|
|
186
329
|
cssescape2unicode (e) {
|
|
187
|
-
const toconvert = $('#toconvert').value;
|
|
188
|
-
$('#converted').value = this.cssescape2unicodeval(
|
|
330
|
+
const toconvert = $i('#toconvert').value;
|
|
331
|
+
$i('#converted').value = this.cssescape2unicodeval(
|
|
332
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
333
|
+
);
|
|
189
334
|
return false;
|
|
190
335
|
},
|
|
336
|
+
/**
|
|
337
|
+
* @param {string} toconvert
|
|
338
|
+
* @param {HTMLElement} el
|
|
339
|
+
*/
|
|
191
340
|
sixDigit2UnicodeVal (toconvert, el) {
|
|
192
341
|
classChange(el);
|
|
193
342
|
const val = charrefunicodeConverter.sixDigit2UnicodeVal(toconvert);
|
|
194
|
-
$('#converted').value = val;
|
|
343
|
+
$i('#converted').value = val;
|
|
195
344
|
return val;
|
|
196
345
|
},
|
|
346
|
+
/**
|
|
347
|
+
* @param {Event} e
|
|
348
|
+
*/
|
|
197
349
|
sixDigit2Unicode (e) {
|
|
198
|
-
const toconvert = $('#toconvert').value;
|
|
199
|
-
this.sixDigit2UnicodeVal(
|
|
350
|
+
const toconvert = $i('#toconvert').value;
|
|
351
|
+
this.sixDigit2UnicodeVal(
|
|
352
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
353
|
+
);
|
|
200
354
|
return false;
|
|
201
355
|
},
|
|
356
|
+
/**
|
|
357
|
+
* @param {Event} e
|
|
358
|
+
*/
|
|
202
359
|
jsescape2unicode (e) {
|
|
203
|
-
const toconvert = $('#toconvert').value;
|
|
204
|
-
$('#converted').value = this.jsescape2unicodeval(
|
|
360
|
+
const toconvert = $i('#toconvert').value;
|
|
361
|
+
$i('#converted').value = this.jsescape2unicodeval(
|
|
362
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
363
|
+
);
|
|
205
364
|
return false;
|
|
206
365
|
},
|
|
366
|
+
/**
|
|
367
|
+
* @param {string} toconvert
|
|
368
|
+
* @param {HTMLElement} el
|
|
369
|
+
*/
|
|
207
370
|
cssescape2unicodeval (toconvert, el) {
|
|
208
371
|
classChange(el);
|
|
209
372
|
const unicode = charrefunicodeConverter.cssescape2unicodeval(toconvert);
|
|
210
373
|
return unicode;
|
|
211
374
|
},
|
|
212
375
|
// Fix: make option to avoid converting \r, etc. for javascript
|
|
376
|
+
/**
|
|
377
|
+
* @param {string} toconvert
|
|
378
|
+
* @param {HTMLElement} el
|
|
379
|
+
* @param {import('./unicode/UnicodeConverter.js').UnicodeEscapeMode} [mode]
|
|
380
|
+
*/
|
|
213
381
|
jsescape2unicodeval (toconvert, el, mode) {
|
|
214
382
|
classChange(el);
|
|
215
383
|
const unicode = charrefunicodeConverter.jsescape2unicodeval(
|
|
@@ -217,136 +385,175 @@ const CharrefConverterBridges = {
|
|
|
217
385
|
);
|
|
218
386
|
return unicode;
|
|
219
387
|
},
|
|
388
|
+
/**
|
|
389
|
+
* @param {string} toconvert
|
|
390
|
+
* @param {HTMLElement} el
|
|
391
|
+
*/
|
|
220
392
|
async unicode2cssescapeval (toconvert, el) {
|
|
221
393
|
classChange(el);
|
|
222
394
|
const val = await charrefunicodeConverter.unicode2cssescapeval(
|
|
223
395
|
toconvert
|
|
224
396
|
);
|
|
225
|
-
$('#converted').value = val;
|
|
397
|
+
$i('#converted').value = val;
|
|
226
398
|
return val;
|
|
227
399
|
},
|
|
400
|
+
/**
|
|
401
|
+
* @param {Event} e
|
|
402
|
+
*/
|
|
228
403
|
async unicode2cssescape (e) {
|
|
229
|
-
const toconvert = $('#toconvert').value;
|
|
230
|
-
await this.unicode2cssescapeval(
|
|
404
|
+
const toconvert = $i('#toconvert').value;
|
|
405
|
+
await this.unicode2cssescapeval(
|
|
406
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
407
|
+
);
|
|
231
408
|
return false;
|
|
232
409
|
},
|
|
233
410
|
// In this method and others like it, boolpref should be moved instead to
|
|
234
411
|
// converter function since it should be consistent across the app
|
|
412
|
+
/**
|
|
413
|
+
* @param {Event} e
|
|
414
|
+
*/
|
|
235
415
|
async htmlents2charrefDec (e) {
|
|
236
|
-
let toconvert = $('#toconvert').value;
|
|
416
|
+
let toconvert = $i('#toconvert').value;
|
|
237
417
|
if (await getPref('ampspace')) {
|
|
238
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
418
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
239
419
|
}
|
|
240
|
-
$('#converted').value = await this.htmlents2charrefDecval(
|
|
241
|
-
toconvert, e.target
|
|
420
|
+
$i('#converted').value = await this.htmlents2charrefDecval(
|
|
421
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
242
422
|
);
|
|
243
423
|
return false;
|
|
244
424
|
},
|
|
425
|
+
/**
|
|
426
|
+
* @param {Event} e
|
|
427
|
+
*/
|
|
245
428
|
async htmlents2charrefHex (e) {
|
|
246
|
-
let toconvert = $('#toconvert').value;
|
|
429
|
+
let toconvert = $i('#toconvert').value;
|
|
247
430
|
if (await getPref('ampspace')) {
|
|
248
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
431
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
249
432
|
}
|
|
250
|
-
$('#converted').value = await this.htmlents2charrefHexval(
|
|
251
|
-
toconvert, e.target
|
|
433
|
+
$i('#converted').value = await this.htmlents2charrefHexval(
|
|
434
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
252
435
|
);
|
|
253
436
|
return false;
|
|
254
437
|
},
|
|
438
|
+
/**
|
|
439
|
+
* @param {Event} e
|
|
440
|
+
*/
|
|
255
441
|
async htmlents2unicode (e) {
|
|
256
|
-
let toconvert = $('#toconvert').value;
|
|
442
|
+
let toconvert = $i('#toconvert').value;
|
|
257
443
|
if (await getPref('ampspace')) {
|
|
258
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
444
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
259
445
|
}
|
|
260
|
-
$('#converted').value = await this.htmlents2unicodeval(
|
|
261
|
-
toconvert, e.target
|
|
446
|
+
$i('#converted').value = await this.htmlents2unicodeval(
|
|
447
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
262
448
|
);
|
|
263
449
|
return false;
|
|
264
450
|
},
|
|
451
|
+
/**
|
|
452
|
+
* @param {Event} e
|
|
453
|
+
*/
|
|
265
454
|
async hex2dec (e) {
|
|
266
|
-
let toconvert = $('#toconvert').value;
|
|
455
|
+
let toconvert = $i('#toconvert').value;
|
|
267
456
|
if (await getPref('ampspace')) {
|
|
268
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
457
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
269
458
|
}
|
|
270
|
-
$('#converted').value = this.hex2decval(
|
|
459
|
+
$i('#converted').value = this.hex2decval(
|
|
460
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
461
|
+
);
|
|
271
462
|
return false;
|
|
272
463
|
},
|
|
464
|
+
/**
|
|
465
|
+
* @param {Event} e
|
|
466
|
+
*/
|
|
273
467
|
async dec2hex (e) {
|
|
274
|
-
let toconvert = $('#toconvert').value;
|
|
468
|
+
let toconvert = $i('#toconvert').value;
|
|
275
469
|
if (await getPref('ampspace')) {
|
|
276
|
-
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/
|
|
470
|
+
toconvert = toconvert.replaceAll(/&([^;\s]*\s)/gv, '&$1');
|
|
277
471
|
}
|
|
278
|
-
$('#converted').value = await this.dec2hexval(
|
|
472
|
+
$i('#converted').value = await this.dec2hexval(
|
|
473
|
+
toconvert, /** @type {HTMLElement} */ (e.target)
|
|
474
|
+
);
|
|
279
475
|
return false;
|
|
280
476
|
}
|
|
281
477
|
};
|
|
282
478
|
|
|
283
479
|
/**
|
|
284
|
-
* @param {
|
|
480
|
+
* @param {object} cfg
|
|
285
481
|
* @param {string} cfg.toconvert
|
|
286
482
|
* @param {string} cfg.targetid
|
|
287
483
|
* @param {import('intl-dom').I18NCallback} cfg._
|
|
288
484
|
* @throws {Error}
|
|
289
|
-
* @returns {Promise<string>}
|
|
485
|
+
* @returns {Promise<string|void>}
|
|
290
486
|
*/
|
|
291
487
|
async function findBridgeForTargetID ({_, toconvert, targetid}) {
|
|
292
488
|
let out;
|
|
293
489
|
switch (targetid) {
|
|
294
490
|
case 'context-charrefunicode1':
|
|
295
|
-
out = CharrefConverterBridges.charref2unicodeval(
|
|
491
|
+
out = CharrefConverterBridges.charref2unicodeval(
|
|
492
|
+
toconvert,
|
|
493
|
+
/** @type {HTMLElement} */ ($('#b1'))
|
|
494
|
+
);
|
|
296
495
|
break;
|
|
297
496
|
case 'context-charrefunicode2':
|
|
298
497
|
out = await CharrefConverterBridges.charref2htmlentsval(
|
|
299
|
-
toconvert, $('#b2')
|
|
498
|
+
toconvert, /** @type {HTMLElement} */ ($('#b2'))
|
|
300
499
|
);
|
|
301
500
|
break;
|
|
302
501
|
case 'context-charrefunicode3':
|
|
303
502
|
out = await CharrefConverterBridges.unicode2charrefDecval(
|
|
304
|
-
toconvert, $('#b3')
|
|
503
|
+
toconvert, /** @type {HTMLElement} */ ($('#b3'))
|
|
305
504
|
);
|
|
306
505
|
break;
|
|
307
506
|
case 'context-charrefunicode4':
|
|
308
507
|
out = await CharrefConverterBridges.unicode2charrefHexval(
|
|
309
|
-
toconvert, $('#b4')
|
|
508
|
+
toconvert, /** @type {HTMLElement} */ ($('#b4'))
|
|
310
509
|
);
|
|
311
510
|
break;
|
|
312
511
|
case 'context-charrefunicode5':
|
|
313
512
|
out = await CharrefConverterBridges.unicode2htmlentsval(
|
|
314
|
-
toconvert, $('#b5')
|
|
513
|
+
toconvert, /** @type {HTMLElement} */ ($('#b5'))
|
|
315
514
|
);
|
|
316
515
|
break;
|
|
317
516
|
case 'context-charrefunicode6':
|
|
318
|
-
out = CharrefConverterBridges.unicode2jsescapeval(
|
|
517
|
+
out = await CharrefConverterBridges.unicode2jsescapeval(
|
|
518
|
+
toconvert, $('#b6')
|
|
519
|
+
);
|
|
319
520
|
break;
|
|
320
521
|
case 'context-charrefunicode7':
|
|
321
522
|
out = await CharrefConverterBridges.unicodeTo6DigitVal(
|
|
322
|
-
toconvert, $('#b7')
|
|
523
|
+
toconvert, /** @type {HTMLElement} */ ($('#b7'))
|
|
323
524
|
);
|
|
324
525
|
break;
|
|
325
526
|
case 'context-charrefunicode8':
|
|
326
527
|
out = await CharrefConverterBridges.unicode2cssescapeval(
|
|
327
|
-
toconvert, $('#b8')
|
|
528
|
+
toconvert, /** @type {HTMLElement} */ ($('#b8'))
|
|
328
529
|
);
|
|
329
530
|
break;
|
|
330
531
|
case 'context-charrefunicode9':
|
|
331
532
|
out = await CharrefConverterBridges.htmlents2charrefDecval(
|
|
332
|
-
toconvert, $('#b9')
|
|
533
|
+
toconvert, /** @type {HTMLElement} */ ($('#b9'))
|
|
333
534
|
);
|
|
334
535
|
break;
|
|
335
536
|
case 'context-charrefunicode10':
|
|
336
537
|
out = await CharrefConverterBridges.htmlents2charrefHexval(
|
|
337
|
-
toconvert, $('#b10')
|
|
538
|
+
toconvert, /** @type {HTMLElement} */ ($('#b10'))
|
|
338
539
|
);
|
|
339
540
|
break;
|
|
340
541
|
case 'context-charrefunicode11':
|
|
341
542
|
out = await CharrefConverterBridges.htmlents2unicodeval(
|
|
342
|
-
toconvert, $('#b11')
|
|
543
|
+
toconvert, /** @type {HTMLElement} */ ($('#b11'))
|
|
343
544
|
);
|
|
344
545
|
break;
|
|
345
546
|
case 'context-charrefunicode12':
|
|
346
|
-
out = CharrefConverterBridges.hex2decval(
|
|
547
|
+
out = CharrefConverterBridges.hex2decval(
|
|
548
|
+
toconvert,
|
|
549
|
+
/** @type {HTMLElement} */ ($('#b12'))
|
|
550
|
+
);
|
|
347
551
|
break;
|
|
348
552
|
case 'context-charrefunicode13':
|
|
349
|
-
out = CharrefConverterBridges.dec2hexval(
|
|
553
|
+
out = await CharrefConverterBridges.dec2hexval(
|
|
554
|
+
toconvert,
|
|
555
|
+
/** @type {HTMLElement} */ ($('#b13'))
|
|
556
|
+
);
|
|
350
557
|
break;
|
|
351
558
|
case 'context-charrefunicode14':
|
|
352
559
|
out = CharrefConverterBridges.jsescape2unicodeval(toconvert, $('#b14'));
|
|
@@ -359,22 +566,22 @@ async function findBridgeForTargetID ({_, toconvert, targetid}) {
|
|
|
359
566
|
break;
|
|
360
567
|
case 'context-charrefunicode17':
|
|
361
568
|
out = await CharrefConverterBridges.unicode2CharDescVal(
|
|
362
|
-
toconvert, $('#b17')
|
|
569
|
+
toconvert, /** @type {HTMLElement} */ ($('#b17'))
|
|
363
570
|
);
|
|
364
571
|
break;
|
|
365
572
|
case 'context-charrefunicode18':
|
|
366
573
|
out = await CharrefConverterBridges.charDesc2UnicodeVal(
|
|
367
|
-
toconvert, $('#b18')
|
|
574
|
+
toconvert, /** @type {HTMLElement} */ ($('#b18'))
|
|
368
575
|
);
|
|
369
576
|
break;
|
|
370
577
|
case 'context-charrefunicode3b':
|
|
371
578
|
out = await CharrefConverterBridges.unicode2charrefDecval(
|
|
372
|
-
toconvert, $('#b3b'), true
|
|
579
|
+
toconvert, /** @type {HTMLElement} */ ($('#b3b')), true
|
|
373
580
|
);
|
|
374
581
|
break;
|
|
375
582
|
case 'context-charrefunicode4b':
|
|
376
583
|
out = await CharrefConverterBridges.unicode2charrefHexval(
|
|
377
|
-
toconvert, $('#b4b'), true
|
|
584
|
+
toconvert, /** @type {HTMLElement} */ ($('#b4b')), true
|
|
378
585
|
);
|
|
379
586
|
break;
|
|
380
587
|
default:
|