User:PerfektesChaos/js/watchCategories

JavaScript gadget – display number of entries within a category.

This is aiming at maintenance categories which are supposed to be empty. If not, you might feel prompted to intervene and clear the causes.

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:

Furthermore you will need to put the following lines before a statement mentioned above, if any: This block should be followed by definition of your particular categories and options. In the most simplified case this is one line: That one triggers the Category:All articles with HTML markup which has currently # entries (cache delay might occur on this static page).

Effects
On the requested target page a box is displayed, with a link to the category and the number of entries.
 * By default the target page is the watchlist (changes). The box is appearing on top of the watchlist.
 * By default only categories with at least one member are visible.
 * Only pages which are put directly into the category will be counted; neither sub-categories nor their pages nor files.

Format of definitions
The configuration element  is supposed to be either
 * a string with the category title
 * a number with the  of that category description
 * an Array with a collection of
 * string with category title
 * number with
 * object with a detailed specification

Examples
Most simplified case:

A more complex example, which puts conditions on call to accelerate page loading on all other pages: Thereby on all other pages (articles and discussions) loading of the gadget is suppressed and execution time minimized.
 * A function  is defined, which does the real business.
 * By number of namespace it can be decided efficiently, whether further examination will be meaningful.
 * Only if the page title matches,  is called and will load the gadget.
 * The same analysis is made within the gadget according to the  definitions.
 * Within the function an Array with two elements is defined:
 * Category:All articles with HTML markup on watchlist
 * Category:All NRHP articles with dead external links on Wikipedia:WikiProject National Register of Historic Places/maintenance
 * Link title is abbreviated.

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.
 * No adaption of source code necessary.


 * German version

Other Scripts

 * User:Ais523/catwatch.js
 * Similar goal, but different appearance at other place with single pages rather a total number.
 * Last code revision 2008.