-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathform.js
More file actions
15 lines (13 loc) · 636 Bytes
/
form.js
File metadata and controls
15 lines (13 loc) · 636 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Filterform } from '/index/index.js'
import { supportedLangs } from './speech.js'
/**
* @typedef SupportedLang
* @property {string} label
* @property {function(HTMLElement, string): HTMLElement} transform
*/
const userLangs = navigator.languages.map(lang => lang.substring(0, 2))
const supportedLangCodes = Object.keys(supportedLangs)
const langs = userLangs.filter(lang => supportedLangCodes.includes(lang))
const checkedLangs = langs.length > 0 ? langs[0] : ['fr']
const tagSelector = value => value ? `*[lang="${value}"]` : '*[lang]'
new Filterform('#lang-form', tagSelector, checkedLangs, supportedLangs, p => p.lang)