function createAncientGreekSortKey(input, maintainCase) {
if (!input) return input;
var map = {
'α': //g,
'Α': //g,
'ε': //g,
'Ε': //g,
'η': //g,
'Η': //g,
'ι': //g,
'Ι': //g,
'ο': //g,
'Ο': //g,
'υ': //g,
'Υ': //g,
'ω': //g,
'Ω': //g,
'ρ': //g,
'Ρ': //g,
/* 'σ': /ς/g, */
'αι': //g,
'Αι': //g,
'ηι': //g,
'Ηι': //g,
'ωι': //g,
'Ωι': //g,
'': /´῾`΅῭῟῞῝῏῎῍῁῀᾿᾽/g
};
var output = input;
if (!maintainCase) output = output.toLowerCase();
for (var k in map) {
output = output.replace(map, k);
}
return output;
}
// Only add onload hook if the page name contains at least one Greek character
if ((wgAction == "edit" || wgAction == "submit")
&& wgPageName.match(//)) {
addOnloadHook(function () {
// Case sensitive
var li = mw.util.addPortletLink('p-tb', '#',
'Greek sort key',
't-grc-sort',
'Create Ancient Greek sort key from page title');
li.getElementsByTagName("a").onclick = function () {
insertTags(createAncientGreekSortKey(wgPageName), '', '');
return false;
};
// Case sensitive
var li = mw.util.addPortletLink('p-tb', '#',
'Greek sort key (case-sensitive)',
't-grc-sort-nofold',
'Create Ancient Greek sort key from page title (maintain case)');
li.getElementsByTagName("a").onclick = function () {
insertTags(createAncientGreekSortKey(wgPageName, true), '', '');
return false;
};
});
}