Home  

Random  

Nearby  



Log in  



Settings  



Donate  



About Wikipedia  

Disclaimers  



Wikipedia





User:PerfektesChaos/js/listPageOptions





User page  

Talk  



Language  

Watch  

Edit  


< User:PerfektesChaos | js



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

edit
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/listPageOptions/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript",
               "text/javascript");

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:

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:

Two selections in one

edit

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.

Affected pages:

Hide

edit

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

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

Affected pages:

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:

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

Byuser 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:

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 Arrays of rules.

Every rule element is an Array with two until four elements:

Single rule Array
[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.
  • 0 or not provided: Any list of pages.
  • 1: Watchlist only
  • 2: Recent changes only
[3] (optional) User name pattern (contributor).
Regular expression style, as string.
[4] (optional) Minor edits only.

Visited pages toggling

edit

By boolean value .learnt 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.

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

Affected pages:

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:

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:

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.

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

Affected pages:

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 .leyoontrue 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
  • ext.gadget.listPageOptions for mw:Extension:Gadgets
  • Dependencies: user, user.options, jquery.cookie, mediawiki.api, mediawiki.user, mediawiki.util
Namespaces -1
(Watchlist, Recentchanges, Blankpage)
Cookies
  • listPageOptions (sessionStorage)
  • preferencesGadgetOptions (localStorage) – anonymous users only
mw.libs listPageOptions
MediaWiki
  • 1.26 (mw.storage) options for anonymous users
  • 1.23 for registered users

Other languages

edit

This gadget is prepared for multilingual support.


Retrieved from "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/listPageOptions&oldid=1071602099"
 



Last edited on 13 February 2022, at 12:23  


Languages

 


Deutsch
 

Wikipedia


This page was last edited on 13 February 2022, at 12:23 (UTC).

Content is available under CC BY-SA 4.0 unless otherwise noted.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Terms of Use

Desktop