User:PerfektesChaos/js/listPageOptions

JavaScript gadget to add specific functionality on special pages which list other pages. This affects namely watchlists and on “recent changes”.

Currently eight features are supported:
 * 1) Toggle “multiple entries” appearance (aka “extended watchlist”).
 * 2) Toggle “group by page” appearance (“enhanced”) on extended watchlist and list of recent changes.
 * 3) Enable multiple changes of options in one to change the entire scenario.
 * 4) Remove pages and entries described by patterns, especially from recent changes.
 * 5) Toggle visibility of visited entries.
 * 6) Unwatch particular pages on your watchlist.
 * 7) Mark particular pages on your watchlist as visited.
 * 8) Hide/unhide options/notices block (for limited screen space).

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:
 * The gadget works also with non-WMF sites using MediaWiki 1.23 or higher.
 * Anonymous users might use greasemonkey or similar.

Toggle “multiple entries” on watchlist
Basically, you have to decide on global Preferences for all following calls if you want multiple activities per page listed. In the “Watchlist options” block a checkbox is added, which is preselected by your most recent known preference. If you click the on/off link or add/remove the checkbox tic and press Go the subsequent pages keep this behaviour; the links on time intervals and various options are preserving the checkbox state.

Affected pages:
 * Any “changes” watchlist.

Toggle “group by page”
If you look at a special page which provides multiple entries for the same page, there is a general user preference to group them by page, and expand that page later on click.

This goes for all views now, which is not always appropriate. This gadget provides you with a way to toggle this feature within a track if it shall not be applied, or to jump in temporarily without changing your global preferences.

In the “Watchlist options” block (or “Recent changes options”) a checkbox is added, which is preselected by your most recent known preference. If you click the on/off link or add/remove the checkbox tic and press Go later the subsequent pages keep this behaviour; the links on time intervals and various options are preserving the checkbox state. If the extended watchlist was not defined yet, the “multiple entries” option is set automatically.

Affected pages:
 * Extended watchlist – “extended” means that you will see multiple entries on your watchlist if there were multiple activities. If not enabled in your preferences, that is activated temporarily.
 * Recent changes.

Two selections in one
This fixes a nasty inconvenience of the interface behaviour: This tool will adapt the direct links according to the namespace and other control settings. You may collect option changes by using form controls, and finally request the page update by clicking on a link or Go all option changes come into effect together.
 * If you want to jump into another namespace, and also change the number of displayed results, you have to build the page two times, since the namespace selection has no effect on the links above.

Affected pages:
 * Any “changes” watchlist.
 * Recent changes.

Hide
Mainly on “recent changes” survey you might want to get rid of less dramatic activities, like some log entries or talk pages.

By user option you can establish a permanent filter, removing entries which distract your attention.

Affected pages:
 * Any “changes” watchlist.
 * Recent changes.

Unwatch
A link (like + [Unwatch]) is added to the portlet toolbox (usually on left hand side) of the watchlist. It adds an “unwatch” link (like [—]) to every page entry on the current list. If you click one of them, the action will be performed by API. If this was clicked by mistake, another click will bring the watched status back.

Affected pages:
 * Any “changes” watchlist.

Since Summer 2017 a Wiki preference „“ could equip always every entry with a similar button.

Visited
By user option a link (like + [Visited]) is added to the portlet toolbox (usually on left hand side) of the watchlist. It adds a “visited” link (like [+]) to every page entry on the current list. If you click one of them, the action will be performed by API. Then the appearance should change and the page should behave as if visited recently. Also initially all unvisited pages may be equipped with buttons.

Affected pages:
 * Any “changes” watchlist.

Quick interactive customization
The simple on/off switch options can be set interactively on as soon as the script library has been loaded.

When reloading a page the preferences declared here come into effect. This dynamic assignment overrides the static setting by JavaScript.

These user preferences are not visible to other users.

Even anonymous users may store preferences in their local browser profile. They have no access to the watchlist, but aspects of recent changes my be customized.

Configuration by JavaScript
Insert the following lines into your common.js (best before mw.loader.load, if present):

Example:

If someone needs to adapt some other of the described functionality, do not hesitate to post your deepest desires on the talk page.

Hide particular entries
The  option is an , which contains  s of rules.

Every rule element is an  with two until four elements:


 * For special pages, only log entries are known to appear. If you want to discard only particular log entries, your choice may be put into brackets:
 * If you want to suppress all log entries,  hides any reference to a special page. The GUI offered by system does not maintain such capability.
 * For regular pages, the namespace should be specified. If only some pages shall be discarded, their title may follow.
 * User name pattern:
 * This is not available for page grouping; one contribution would discard the entire page entry.
 * If provided, both page name pattern and user name pattern are to be matched.
 * If any contribution of a certain user shall be discarded, the page name pattern may be set to.

Visited pages toggling
By boolean value  an additional link is offered, which hides and shows entries already visited. If all pages were visited or none yet, the toggle will be greyed out. Updating is done by the server and requires a new page request.
 * – Show all entries initially (begin of browser session)
 * – Hide visited pages initially

The last known state will be remembered by a session cookie.

Affected pages:
 * Any “changes” watchlist.
 * Recent changes.

Compressed option box
The options in the box are (with or without gadget) grouped and divided in and by lines. By setting the  option they can be arranged flowing to save screen space.

Affected pages:
 * Any “changes” watchlist.
 * Recent changes.

If you want to save screen space on top of the watchlist, you may also want to add the following CSS rule to your common.css:

Mark pages as visited
If activated, every page entry may be equipped with a small button ( + ) that simulates a pages to be visited.

Boolean values launch this feature:
 * – Add link to the portlet toolbox that will equip all unvisited pages with a button.
 * If all pages in list have been visited already, no link is offered.
 * – Add buttons initially to all unvisited pages

Hide option box
If you are suffering from limited screen size, you might want to economize the options area (and notices inside). By boolean value  buttons are offered, which hide ( X ) and show again the options area.
 * – Show option box initially (begin of browser session)
 * – Hide option box initially

The last known state will be remembered by a session cookie.

Affected pages:
 * Any “changes” watchlist.
 * Recent changes.

Last edit your own
On watchlists in “group by page” mode you can hide the entire block if you have made the most recent edit (answered on a talk page, rollback): Set   on   and ensure   mode.

Remark
Actually, there is no need to perform this functionality by an external gadget. Maybe it is replaced by a Mediawiki server solution one day, at least the temporary switches into extended and enhanced mode.

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

de:User:PerfektesChaos/js/listPageOptions