User:PerfektesChaos/js/refNames

 &lt;ref name=""> JavaScript gadget – keep survey and rename  assignments.

The goal of this tool is to improve the identifiers of named  tags: However, editing is limited to the source text of the foreground page. Syntax hidden in transcluded templates or otherwise not obvious elements will be kept unchanged.
 * detect,
 * mark if undesired,
 * rename easily in the entire page without clashes
 * dismiss if superfluous and confusing.

Mission
On referencing annotations, identifiers should be self-explaining and not misleading. The identifier should give a unique hint within this particular page which content will be linked. Identifiers should not contain syntax characters which cause confusion on various stages, like            or typographic characters of similar appearance nor hidden characters.
 * VisualEditor assigns like  or   which tells absolutely nothing.
 * Some users are copying the syntax description  and continue until   which gives no clue what is referred to.
 * Others use the initial numbering and provide  for [1] and   for [2] etc. As soon something is inserted between this strategy crashes since then [3] is defined by   and becomes entirely confusing.
 * Some tools insert  etc.
 * Jane Smith: How to make reasonable identifiers? 2022, p. 42.
 * may be a good choice if no other publications written by any Smith are occurring.

Usage

 * If your project has registered this as a gadget, just activate on your Preferences page.
 * Otherwise include the following line into your common.js, global.js etc.:

Triggering
By default, the gadget takes action in three namespaces: More can be configured by individual configuration, but special pages are not meaningful.
 * Main spaces (articles, )
 * User space
 * Project spaces

In view or source editing preview mode the toolbox of desktop interface will offer a link to start analysis.

Overview and judging
If analysis is requested the lists of  will be equipped with a label for each named item.

On source editing preview mode the final section of the edit page will repeat all named reference identifiers visible in source code by tag syntax, even if not in effect on rendered pages. The headline is linked to this docpage.
 * The tooltip will show the text of that reference.
 * The marker is linked with the related presentation of this item at rendered page, if found. On grouped elements with identical name the assignment is not unique and cannot hit the related rendering.
 * The items at rendered part are linked to this headline.

Exchanging and deletion
If the entire page is covered by source editing preview and syntax leaves no doubt it is possible to ask for global renaming of identifiers. On editing the rendered content or wikitext will be offered to exploit names and words via copy&paste.
 * OOjs UI icon edit-ltr-progressive.svg will open an edit form.
 * OOjs UI icon trash-destructive.svg will permit name deletion if mouse pointer is kept for about two seconds in this position after clicking. If moving out this action is aborted for security reasons.

Exchanging will not cover identifiers which are hidden in templates, as template parameters or within  functions.

Exchanging is in effect for tag syntax disabled by  comments or       elements.

Syntax error tracking
If invalid syntax is encountered, manipulation is not offered and error messages can be read at browser console. After  they tell the character position in edit field. precedes the line number which may be guessed from diff page. However, a line might be quite long and multiple  could occur. The message is terminated by an attempt to reproduce the invalid element.

Individual Configuration
The initial environment and the behaviour can be equipped by each user individually.

Quick interactive costumization
Some options can be set interactively on specific as soon as the script has been loaded.

When reloading a page the preferences declared here come into effect. This dynamic assignment for namespaces overrides the static setting by hooked object.

Anonymous users can use this mode, too; options will be stored in browser profile rather than on wiki server.

The following capabilities are offered: Default: see namespaces. for all namespaces.
 * Namespace numbers to be equipped with toolbox link (space separated).
 * Regular expression for undesired name patterns.
 * Namespace numbers to launch on source editing preview (space separated).

Configuration by JavaScript
Before the request for loading described at “Usage” something like the following statement might be executed: By those keywords the process might be influenced as described here:

CSS
All relevant elements have selectors prefixed by.

The gadget CSS definitions may be adopted by higher specificity.

To avoid FOUC it might be helpful to provide the declarations of  since those decorations might arrive a bit later while the toolbox link has been inserted already.

Internationalization
A translation of this page may be offered. Translations of interactive costumization is also welcome.

Codes
de:User:PerfektesChaos/js/refNames