diff options
author | Vitaly Takmazov | 2022-04-07 10:39:35 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-04-07 10:39:35 +0300 |
commit | e8449b74a33d1fea3191c96d3c16992e032a6f47 (patch) | |
tree | 05f5a2c1cdedc2604721dc2677ab943ae419dceb /src/main | |
parent | 517444f380c9f22a73f5655e911f1367a66ad2c1 (diff) |
scripts: Add some JSDoc
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/assets/scripts.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index d053748e..08ff3c2d 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -21,6 +21,11 @@ function autosize(el) { }); } +/** + * Display an icon from the evil-icons set + * @param {string} name Icon name from the iconset + * @returns HTML markup for the selected icon + */ function evilIcon(name) { return `<div class="icon icon--${name}"><svg class="icon__cnt"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/sprite.svg#${name}-icon"></use></svg></div>`; } @@ -80,12 +85,16 @@ const translations = { }; /* eslint-enable only-ascii/only-ascii */ +/** + * Detect window language + * @returns {string} Detected language + */ function getLang() { return (window.navigator.languages && window.navigator.languages[0]) || window.navigator['userLanguage'] || window.navigator.language; } -function i18n(key, lang = undefined) { +function i18n(key = '', lang = undefined) { const fallbackLang = 'ru'; lang = lang || getLang().split('-')[0]; return (translations[lang] && translations[lang][key]) |