User:PerfektesChaos/js/resultListSort

JavaScript gadget to sort page lists on special pages.

On pages like “Whatlinkshere” several hundred results may occur in any order dropped from database query. Name spaces are mixed randomly, no one gets a survey.

Usage

 * If your project has registered this as a gadget, just activate on your Preferences page.
 * Otherwise include the following lines into your common.js or skin dependant like vector.js, or even global.js:
 * If you are blocking scripts from sites other than your local Wiki you might need to put www.mediawiki.org on the whitelist.
 * The gadget works also with non-WMF sites using MediaWiki.
 * The script may be loaded by anonymous users, e.g. via greasemonkey.

Effects
By default there is just a link added to the content actions of portlet. If sorting is needed it may be requested manually.

However, some types of special pages may be configured by user to perform sorting automatically, if machine is fast enough and response time acceptable to the user.

Standard collation is by namespace and page title.

Some pages get a second and even more action links: Sort by URL, and Watchlist and Recentchanges may be sorted by user or summary, Newpages also by size.

Other pages may be added if meaningful use has been found. Some 20 maintenance page lists are available right now.

For  and   it is offered to convert the three column table into a list. With long page names (perhaps caused by subpage path) they may be confusing to read.

The server provides unordered lists. These are always turned into numbered lists, since a larger number of pages sharing the same property can be derived easily.

Note that the information is gained by screengrabbing. If some details in formatting change, extraction of sortkey might fail. Please notify me.

Quick interactive configuration
Options can be set interactively on, if the script has been loaded before.

They are the same as described in next section: These requests are stored together with user preferences on Wiki server and will be in effect on all browsers. They are overriding settings from the following section.
 * Automatic sorting for specified special pages
 * Insertion of portlet-link: always, never, on particular pages only
 * Ignore case on sorting
 * Keep page together with talk page

Anonymous users can use this mode, too; options will be stored in browser profile rather than on wiki server.

Javascript object
Insert code similar to the following lines into common.js etc. before mw.loader.load:

API
Two functions are exposed to users. They are available if the current page is a special page.

If you want to make use of the API you may place the following call wherever you want: When loading of all components has been completed, the  hook will be fired.

Here is  a callback function with the actual functionality of the user application.

may use one parameter. That is the application object for the API. It provides some version information as well as functions on special pages.

mw.libs
The application object will be mapped into  component.

Option values may be assigned to this object before loading.

Selective loading
Since the gadget is meaningful on special pages only, loading may be limited to such pages:

Other languages
This gadget is prepared for multilingual support.
 * If you like a version in your own language, please forward translations to me:
 * This documentation page.
 * The  mapping on top of source code.
 * Further ISO 639 language codes your translation might support.


 * German