Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display language aliases #1626

Merged
merged 4 commits into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion download.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ for (var category in components) {

var info = all[id] = {
title: all[id].title || all[id],
aliasTitles: all[id].aliasTitles,
noCSS: all[id].noCSS || all.meta.noCSS,
noJS: all[id].noJS || all.meta.noJS,
enabled: checked,
Expand Down Expand Up @@ -176,6 +177,17 @@ for (var category in components) {
info.files.dev.paths.push(cssFile);
}

function getLanguageTitle(lang) {
if (!lang.aliasTitles)
return lang.title;

var titles = [lang.title];
for (var alias in lang.aliasTitles)
if (lang.aliasTitles.hasOwnProperty(alias))
titles.push(lang.aliasTitles[alias]);
return titles.join(" + ");
}

var label = $u.element.create('label', {
attributes: {
'data-id': id
Expand Down Expand Up @@ -230,7 +242,7 @@ for (var category in components) {
properties: {
className: 'name'
},
contents: info.title
contents: getLanguageTitle(info)
},
' ',
all[id].owner? {
Expand Down
37 changes: 28 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,40 @@ <h1>Credits</h1>
continue;
}
count++;
var name = languages[id].title || languages[id];

var lang = languages[id];
var name = lang.title || lang;

var contents = [
name,
' - ',
{
tag: 'code',
contents: id
}
];

var alias = lang.alias;
if (typeof alias === 'string')
alias = [alias];

if (alias) {
for (var i = 0, l = alias.length; i < l; i++) {
contents.push(
', ',
{
tag: 'code',
contents: alias[i]
});
}
}

languageItems.push({
tag: 'li',
attributes: {
'data-id': id
},
contents: [
name,
' - ',
{
tag: 'code',
contents: id
}
]
contents: contents
});
}
$u.element.create('ul', {
Expand Down