MediaWiki:Gadget-autosort.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 7:
(function ($, mw, rs) {
var $sortables = $('.sortable[class*="autosort="]');
console.log('Found sortables:', $sortables);
if (!$sortables.length) return;
rs.autosort = function () {
Line 15 ⟶ 14:
matched = (' ' + $(this).attr('class') + ' ').match(/autosort=(\d+)[,-]{1}(a|d)/),
$sortCol = $this.find('> thead th:nth-child(' + matched[1] + ')');
console.log('Matched details:', matched);
if (matched[2] === 'd') {
// descending
Line 29 ⟶ 27:
mw.hook('wikipage.content').add(function init() {
if ($('.jquery-tablesorter').length) {
setTimeout(rs.autosort(, 100);
} else {
// tablesorter plugin has not run yet; observe the first