Mediawiki:scmcchemistry.js
| Строка 93: | Строка 93: | ||
function normalize(value) { | function normalize(value) { | ||
return String(value || '').toLocaleLowerCase('ru-RU').replace(/ё/g, 'е').trim(); | return String(value || '').toLocaleLowerCase('ru-RU').replace(/ё/g, 'е').trim(); | ||
} | |||
function capitalizeFirst(value) { | |||
var text = String(value || '').trim(); | |||
return text ? text.charAt(0).toLocaleUpperCase('ru-RU') + text.slice(1) : text; | |||
} | } | ||
| Строка 115: | Строка 120: | ||
function getName(id) { | function getName(id) { | ||
var reagent = getReagent(id); | var reagent = getReagent(id); | ||
return reagent && reagent.name ? reagent.name : id; | return capitalizeFirst(reagent && reagent.name ? reagent.name : id); | ||
} | } | ||
| Строка 147: | Строка 152: | ||
mw.loader.load(mw.util.getUrl(STYLE_PAGE, { | mw.loader.load(mw.util.getUrl(STYLE_PAGE, { | ||
action: 'raw', | action: 'raw', | ||
ctype: 'text/css' | ctype: 'text/css', | ||
maxage: 0, | |||
smaxage: 0 | |||
}), 'text/css'); | }), 'text/css'); | ||
} | } | ||
| Строка 155: | Строка 162: | ||
return mw.loader.getScript(mw.util.getUrl(CATALOG_PAGE, { | return mw.loader.getScript(mw.util.getUrl(CATALOG_PAGE, { | ||
action: 'raw', | action: 'raw', | ||
ctype: 'text/javascript' | ctype: 'text/javascript', | ||
maxage: 0, | |||
smaxage: 0 | |||
})).then(function () { | })).then(function () { | ||
if (!validateCatalog(window.ScmcChemCatalog)) { | if (!validateCatalog(window.ScmcChemCatalog)) { | ||
| Строка 257: | Строка 266: | ||
link.href = '#scmc-chem-section-' + index + '-' + slug(group.title); | link.href = '#scmc-chem-section-' + index + '-' + slug(group.title); | ||
add(link, | add(link, | ||
el('span', '', group.title), | el('span', '', capitalizeFirst(group.title)), | ||
el('span', 'scmc-chem__section-link-count', group.entries.length) | el('span', 'scmc-chem__section-link-count', group.entries.length) | ||
); | ); | ||
| Строка 269: | Строка 278: | ||
add(list, add(el('div', 'scmc-chem__mixture-item'), | add(list, add(el('div', 'scmc-chem__mixture-item'), | ||
el('span', 'scmc-chem__mixture-dot'), | el('span', 'scmc-chem__mixture-dot'), | ||
el('span', 'scmc-chem__mixture-name', item.name || getName(item.id)), | el('span', 'scmc-chem__mixture-name', capitalizeFirst(item.name || getName(item.id))), | ||
el('span', 'scmc-chem__mixture-amount', formatAmount(item.amount)) | el('span', 'scmc-chem__mixture-amount', formatAmount(item.amount)) | ||
)); | )); | ||
| Строка 368: | Строка 377: | ||
var summary = el('summary', 'scmc-chem__card-summary'); | var summary = el('summary', 'scmc-chem__card-summary'); | ||
var heading = add(el('span', 'scmc-chem__card-heading'), | var heading = add(el('span', 'scmc-chem__card-heading'), | ||
el('span', 'scmc-chem__card-name', reagent.name || entry.name || entry.id), | el('span', 'scmc-chem__card-name', capitalizeFirst(reagent.name || entry.name || entry.id)), | ||
el('code', 'scmc-chem__card-id', entry.id) | el('code', 'scmc-chem__card-id', entry.id) | ||
); | ); | ||
| Строка 420: | Строка 429: | ||
section.id = 'scmc-chem-section-' + index + '-' + slug(group.title); | section.id = 'scmc-chem-section-' + index + '-' + slug(group.title); | ||
var heading = add(el('div', 'scmc-chem__section-heading'), | var heading = add(el('div', 'scmc-chem__section-heading'), | ||
el('h2', 'scmc-chem__section-title', group.title), | el('h2', 'scmc-chem__section-title', capitalizeFirst(group.title)), | ||
el('span', 'scmc-chem__breadcrumbs', group.path.join(' › ')), | el('span', 'scmc-chem__breadcrumbs', group.path.map(capitalizeFirst).join(' › ')), | ||
el('span', 'scmc-chem__section-count', group.entries.length) | el('span', 'scmc-chem__section-count', group.entries.length) | ||
); | ); | ||