MediaWiki:Common.js: Różnice pomiędzy wersjami
Wygląd
Nie podano opisu zmian |
Nie podano opisu zmian |
||
| Linia 13: | Linia 13: | ||
const textA = a.textContent.trim().toLowerCase(); | const textA = a.textContent.trim().toLowerCase(); | ||
const textB = b.textContent.trim().toLowerCase(); | const textB = b.textContent.trim().toLowerCase(); | ||
return textA.localeCompare(textB); | return textA.localeCompare(textB, 'pl'); | ||
}); | }); | ||
items.forEach(function (item) { | items.forEach(function (item) { | ||
container.appendChild(item); | container.appendChild(item); | ||
| Linia 23: | Linia 22: | ||
} | } | ||
// | function runSort() { | ||
$(document).ready( | // small delay helps because Wikibase renders async | ||
setTimeout(sortAliases, 50); | |||
} | |||
// initial load | |||
$(document).ready(runSort); | |||
// standard MW hook | |||
mw.hook('wikipage.content').add(runSort); | |||
mw.hook('wikibase.entityPage.entityLoaded').add(runSort); | |||
mw.hook(' | |||
}); | }); | ||
Wersja z 10:14, 30 kwi 2026
/* Umieszczony tutaj kod JavaScript zostanie załadowany przez każdego użytkownika, podczas każdego ładowania strony. */
mw.loader.using(['mediawiki.util']).then(function () {
function sortAliases() {
const aliasContainers = document.querySelectorAll('.wikibase-aliasesview-list');
aliasContainers.forEach(function (container) {
const items = Array.from(container.querySelectorAll('.wikibase-aliasesview-list-item'));
if (items.length <= 1) return;
items.sort(function (a, b) {
const textA = a.textContent.trim().toLowerCase();
const textB = b.textContent.trim().toLowerCase();
return textA.localeCompare(textB, 'pl');
});
items.forEach(function (item) {
container.appendChild(item);
});
});
}
function runSort() {
// small delay helps because Wikibase renders async
setTimeout(sortAliases, 50);
}
// initial load
$(document).ready(runSort);
// standard MW hook
mw.hook('wikipage.content').add(runSort);
mw.hook('wikibase.entityPage.entityLoaded').add(runSort);
});