From 39325df6382de2de5072ed2bf9b65736542d9444 Mon Sep 17 00:00:00 2001 From: Sjur N Moshagen Date: Mon, 25 Sep 2023 13:59:39 +0300 Subject: [PATCH] Special needs for dictionaries - two language codes --- assets/js/langtable.js | 40 ++++++++++++++++++++++++++++++++++++++ dicts/DictionarySources.md | 10 +++++----- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/assets/js/langtable.js b/assets/js/langtable.js index 08db7769..b4de639d 100644 --- a/assets/js/langtable.js +++ b/assets/js/langtable.js @@ -8178,3 +8178,43 @@ function doesTopicsHaveSomeFilter(topics, filters) { }) }) } + +// Dictionary page: + +function addNegUnorderedDictList(repos, mainFilter, filters) { + ul = document.createElement('ul') + for (const repo of repos) { + if (repo.name.startsWith(mainFilter)) { + if (!doesTopicsHaveSomeFilter(repo.topics, filters)) { + ul.appendChild(addDictLi(repo)) + } + } + } + // If no repos found, inform the user: + if (!ul.firstChild) { + const p = document.createElement('p') + p.appendChild(document.createTextNode('No repos found.')) + return p + } else { + return ul + } +} + +function addDictLi(repo) { + const li = document.createElement('li') + li.appendChild(addr(reponame2dictname(repo.name), repo.name + '/')) + li.appendChild(document.createTextNode(' ')) + li.appendChild(addr('(source)', repo.html_url)) + + return li +} + +function reponame2dictname(reponame) { + parts = reponame.split('-'); + + if (parts.length === 3) { + return code2langname[parts[1]] + ' - ' + code2langname[parts[2]] + } + + return code2langname[parts[1]] + ' (' + parts.slice(3).join('-') + ')' +} diff --git a/dicts/DictionarySources.md b/dicts/DictionarySources.md index f78b26de..80711596 100644 --- a/dicts/DictionarySources.md +++ b/dicts/DictionarySources.md @@ -127,7 +127,7 @@ domExperLangs.appendChild(addRepoTable({{lang_repos}}, 'dict-', ['maturity-exper @@ -158,12 +158,12 @@ domAfricaLangs.appendChild(addUnorderedList({{lang_repos}}, 'dict-', ['geo-afric @@ -199,10 +199,10 @@ domNigerCongoLangs.appendChild(addUnorderedList({{lang_repos}}, 'dict-', ['langf