User:Paradoctor/CatVisor
Appearance
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
[edit]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.
- 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
[edit]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);
});
Releases
[edit]- Most recent version at User:Paradoctor/CatVisor.js.
- To install, add the line
importScript('User:Paradoctor/CatVisor.js');
to yourcommon.js
, click here to go there. You need to be logged in for this to work.
alpha 3
[edit]- Changes: Added support for IE10, should now work on all recent major browsers. HotCat's "add categories" link now stays at the original position in sorted view.
- Source code: https://en.wikipedia.org/w/index.php?title=User:Paradoctor/CatVisor.js&oldid=622159996
alpha 2
[edit]- Changes: Switch from DOM reordering to CSS flexbox, minor styling improvement, added link to CatVisor homepage, fixed HotCat compatibility issue.
- Requirements: Works for me as described with Monobook in FF31, and Chrome 36 on Windows 8.1. IE10 failed, others not tested.
- Known issues: The "add categories" link of HotCat changes position with different displays.
- Source code: https://en.wikipedia.org/w/index.php?title=User:Paradoctor/CatVisor.js&oldid=621522397
alpha 1
[edit]- Changes: Make no change to representation by default.
- Source code: https://en.wikipedia.org/w/index.php?title=User:Paradoctor/CatVisor.js&oldid=621474525
alpha 0
[edit]- Usage: After installation, you should see four links at the top of the category box looking like this: column row sorted unsorted. Click them and see what happens.
- Features: Logged-in users can switch the display of an article's categories between the default order and alphabetically sorted, and can change between inline and vertical list display by clicking on the links at the top of the category box.
- Requirements: Works for me as described with Monobook in FF31, IE10, Chrome 36 on Windows 8.1, and in FF29 and the default browser on Android 4.1.2.
- Known issues: The sorted view has no HotCat functionality.
- Source code: https://en.wikipedia.org/w/index.php?title=User:Paradoctor/CatVisor.js&oldid=621326338