Inspired by this discussion, CatVisor is a script that adds user-configurable ways of arranging and displaying the categories on articles. CatVisor does not touch the article source, and will not change anything for those not using it. It will include a tool to edit arrangements, and a template will allow editors to offer pre-made arrangements to readers using the tool, but this will not change the order of the categories for non-CatVisor readers, or anything else about the rendered page.
Discussion on the talk page, please.
Planned features
Priority features are bolded.
- Display categories in the order they do now.
- Display categories sorted alphabetically by category name.
- Display categories sorted alphabetically by sortkey.
- Display categories sorted in an order specifiable by a template added to the article. There can be several templates for different orderings. The template(s) will be invisible to the reader.
- Editor tool to make template maintenance painless.
- Display categories as a vertical list.
- Display categories in columns, sorted in rows.
- Display categories in columns, sorted in columns.
- Display categories in titled groups specified by a template added to the article. There can be several templates for different groupings. The template(s) will be invisible to the reader.
- Compatibility with HotCat
- Compatibility with Vector and Monobook skins.
- Package script as MediaWiki gadget.
- Investigate implementation possibilities. Lua? Custom skin? Extension?
- Use CSS flexbox "order" property to change presentation. Use node rearrangement for backwards compatibility later, if no CSS shim/shiv/polyfill can be found.
- Is it permissible to add the same category multiple times on a page? If so, the most primitive variant would be to simply produce all variants in different sections. Crude, and maintenance would very likely be a major pain.
- [[File:|25px|link=]] Can't be done. Categories are not rendered in the article, regardless of how often you put them into the wikitext.
- Persistent user preferences
- Offer information on the various arrangement schemes to the user.
- Machine-generated orderings. E. g. based on traffic stats, or degrees of separation.
JQuery workaround by Salix alba
Generously donated by Salix alba (talk · contribs). Discuss at User_talk:Paradoctor/CatVisor#jQuery workaround by Salix alba.
- Works for me in FF31 and IE10 with both Monobook+HotCat and Vector+HotCat on Windows 8.1.
- Also works as Greasemonky 1.12 user script on FF31, didn't test other cases.
- Replaced "innerHTML" with "textContent", works with the abovementioned as well as Chrome 36.0.1985.143 m and the Android 4.1.2 browser.
jQuery( document ).ready( function( $ ) {
var $cats_ul = $('#mw-normal-catlinks ul');
var $cats_li = $cats_ul.children('li');
$cats_li.sort(function(a,b) {
if(a.children[0].textContent > b.children[0].textContent) return 1;
return -1;
});
$cats_li.detach().appendTo($cats_ul);
});