Jump to content

User:PerfektesChaos/js/markGroupMembers

From Wikipedia, the free encyclopedia

JavaScript gadget – mark users who are members of arbitrary groups.

The script consists of a project configuration part in top region and a functional part in the guts. While the first is supposed to be maintained by a project, the latter is recommended to keep as-is.

For user nicks matching an entry in list one or more marker letters will be appended to userpage links in content area of any page, and a verbal description will be amended to link tooltip. A user might be member of several groups, which will be mentioned all.

The gadget updates when content area has been updated, e.g. by LivePreview or VisualEditor.

Project configuration

[edit]

The following variables might be defined for all page builds:

Groups
Array of markers which are currently in effect for this project.
Limitation to active groups accelerates execution.
Users
Object which maps each marker to an array of user nicks.
User nicks are to be provided with single spaces rather than _ and upcased first letter.
There might be more markers than groups with current members; an empty array or false is to be assigned. Empty groups should not occur in Groups array. Temporarily unused assignments might be commented out.
Tips
Object which maps each marker to a verbose explanation string appended to link tooltip.
Live
true – every linked page is required to exist for marking, and only page views willbe marked.
false – redlinks and relational pages will be marked,too.
Lower
true – include links to subpages
false – only top level page links will receive a marker
Sep
Separator string between marker components
Spaces
RegExp string describing formatted local user namespace name, including gender variants and possibly talk pages
Style
CSS string for the marker

See codes for examples.

General configuration

[edit]

Marked links will be equipped with two classes:

  1. markGroupMembers
  2. markGroupMembers-n

They might be used by anyone to style the link and marker. The first one is applied to all links which are member ofany group. The second one contains a consecutive digit which might be helpful for groups which are subsets of a basic group, but entirely useless in complex cases with many groups where the meaning depends on links encountered on a particular page.

Crystal ball

[edit]

There is no world wide application planned right now.

However, one day the gadget might be implemented by serving the functional part from a unique global core which is fed by a local wiki definition of particular groups and customization like

mw.libs.markGroupMembers = { groups: [ "A", "B" ],
                             users:  { "A":   [ "Alaŭdo",
                                                "Alaudo",
                                                "Andy",
                                   ...
                             style:  "color:#0645AD;" +
                                     "font-size:small;" +
                                     "font-weight:bold;" +
                                     "margin-left:0.2em;" +
                                     "vertical-align:super;"
                           };

which would be followed by some

mw.loader.load("https://.....functionality.delivered.by.central.maintenance......&ctype=text/javascript");

Codes

[edit]