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:
- Toggle “multiple entries” appearance (aka “extended watchlist”).
- Toggle “group by page” appearance (“enhanced”) on extended watchlist and list of recent changes.
- Enable multiple changes of options in one to change the entire scenario.
- Remove pages and entries described by patterns, especially from recent changes.
- Toggle visibility of visited entries.
- Unwatch particular pages on your watchlist.
- Mark particular pages on your watchlist as visited.
- Hide/unhide options/notices block (for limited screen space).
Usage
[edit]- 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:
mw.loader.load("http://en.wiki.x.io/w/index.php?title=User:PerfektesChaos/js/listPageOptions/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript",
"text/javascript");
- The gadget works also with non-WMF sites using MediaWiki 1.23 or higher.
- Anonymous users might use greasemonkey or similar.
Effects
[edit]Toggle “multiple entries” on watchlist
[edit]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”
[edit]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
[edit]This fixes a nasty inconvenience of the interface behaviour:
- 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.
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.
Affected pages:
- Any “changes” watchlist.
- Recent changes.
Hide
[edit]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
[edit]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 „Add direct unwatch/watch markers (×/+) to watched pages with changes (JavaScript required for toggle functionality)“ could equip always every entry with a similar button.
Visited
[edit]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.
User options
[edit]Quick interactive customization
[edit]The simple on/off switch options can be set interactively on Special:Blankpage 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
[edit]Insert the following lines into your common.js (best before mw.loader.load, if present):
if ( typeof mw.libs.listPageOptions !== "object" ) {
mw.libs.listPageOptions = { };
}
mw.libs.listPageOptions.key1 = value1;
Key | Value | Bedeutung |
---|---|---|
lean
|
true
|
Compressed option box. Default: false – unchanged layout
|
learnt
|
true
|
Visited pages toggling. Default: null – no additional link
|
leyo
|
true
|
Hide “last edit your own” blocks. Default: null – no hiding
|
looked
|
true
|
Mark pages as visited. Default: null – no portlet link, no buttons
|
lower
|
true
|
Hide options box. Default: null – no toggle buttons
|
luxury
|
true
|
Additional checkboxes for hide/show. Default: false – no additional checkboxes
|
hide
|
Array
|
Hide particular pages or patterns. Default: No hiding. |
Example:
if ( typeof mw.libs.listPageOptions !== "object" ) {
mw.libs.listPageOptions = { };
}
mw.libs.listPageOptions.learn = true;
mw.libs.listPageOptions.hide = [ [ true, "Log/articlefeedback", 2 ],
[ false, "User:", 2 ],
[ false, "([A-Z][a-z]+_)?[Tt]alk:", 2 ],
[ false, "Wikipedia:Sandbox", 2 ]
];
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
[edit]The hide
option is an Array
, which contains Array
s of rules.
Every rule element is an Array
with two until four elements:
[0]
|
Special page indicator.true = special and false = regular page
|
[1]
|
Page name pattern. Regular expression style, as string. Reflects the format as used in URL. Literal URL encoding may be used, or formatted page title with spaces. |
[2]
|
(optional) Limit rule to certain page listings.
|
[3]
|
(optional) User name pattern (contributor). Regular expression style, as string. |
[4]
|
(optional) Minor edits only. |
- 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:
"Log/(articlefeedback|block|upload)"
- 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.
- If you want to suppress all log entries,
- 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
false
.
Visited pages toggling
[edit]By boolean value .learnt
an additional link is offered, which hides and shows entries already visited.
false
– Show all entries initially (begin of browser session)true
– Hide visited pages initially
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.
The last known state will be remembered by a session cookie.
Affected pages:
- Any “changes” watchlist.
- Recent changes.
Compressed option box
[edit]The options in the box are (with or without gadget) grouped and divided in and by lines. By setting the .lean
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:
form#mw-watchlist-resetbutton ul li {
display: none;
}
Mark pages as visited
[edit]If activated, every page entry may be equipped with a small button ( + ) that simulates a pages to be visited.
Boolean values launch this feature:
false
– 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.
true
– Add buttons initially to all unvisited pages
Hide option box
[edit]If you are suffering from limited screen size, you might want to economize the options area (and notices inside). By boolean value .lower
buttons are offered, which hide ( X ) and show again the options area.
false
– Show option box initially (begin of browser session)true
– 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
[edit]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 .leyo
on true
and ensure hideOwn=0
mode.
Remark
[edit]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.
Codes
[edit]Source code |
|
ResourceLoader |
|
Namespaces | -1 ( Watchlist , Recentchanges , Blankpage )
|
Cookies |
|
mw.libs
|
listPageOptions
|
MediaWiki |
|
Other languages
[edit]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
POpt.texts
mapping on top of source code. - Further ISO 639 language codes your translation might support.