JavaScript gadget – check uniqueness, validity and show position of anchors in page:
id
has been repeated in HTML document, the subsequent targets become unreachable.
mw.loader.load( "https://en.wikipedia.org/?title=User:PerfektesChaos/js/fragmentAnchors/r.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript",
"text/javascript" );
The appearance might be changed via CSS.
The following selectors will be provided:
.fragmentAnchors-mark
– all inserted elements.error-repeated-id
– multiple id
.fragmentAnchors-inner
– detected inner link.fragmentAnchors-broken
– detected inner link without target#fragmentAnchors-mark-errors
– error message summary.error
– error message summaryThe following code should appear on your
common.js,
global.js or skin dependant JS best before an mw.loader.load()
call as described in “
Usage” section.
First, the application object is to be etablished:
if ( typeof mw.libs.fragmentAnchors !== "object" ) {
mw.libs.fragmentAnchors = { };
}
After that, currently there are three options available:
mw.libs.fragmentAnchors.large = true;
This will decorate the full page and does not narrow to content area and not exclude source text edit form.
mw.libs.fragmentAnchors.launch = true;
This will trigger page decoration immediately after loading without generating a link in tool box. It is supposed that loading is limited to certain conditions.
mw.libs.fragmentAnchors.lock = true;
This will prevent from generating a link in tool box and gives opportunity to trigger decoration by any other means, calling .fetch() and .fire() methods.
After the mw.hook
fragmentAnchors.ready
has been triggered a function may be called. The application object is the parameter of the mw.hook callback function and should be identical with mw.libs.fragmentAnchors
.
All functions are components of the application object.
Collect all fragments in HTML document (starting with #
and not decoded).
Call | .fetch()
| ||
---|---|---|---|
Return value |
|
The document wouldn’t get decorated, except on locations of detected errors.
Trigger page decoration from external command.
Call | .fire()
| ||
---|---|---|---|
Return value |
|
Should declare
.lock = true;
in advance if link in
tool box is undesired.
A test page provides examples.
Not required, symbols only.
Source code |
|
ResourceLoader |
|
Namespaces | Every. |
Cookies | None |
mw.libs
|
fragmentAnchors
|
mw.hook
|
fragmentAnchors.ready When page has been equipped with portlet, or is ready for decoration. |
MediaWiki | 1.23 |
JavaScript gadget – check uniqueness, validity and show position of anchors in page:
id
has been repeated in HTML document, the subsequent targets become unreachable.
mw.loader.load( "https://en.wikipedia.org/?title=User:PerfektesChaos/js/fragmentAnchors/r.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript",
"text/javascript" );
The appearance might be changed via CSS.
The following selectors will be provided:
.fragmentAnchors-mark
– all inserted elements.error-repeated-id
– multiple id
.fragmentAnchors-inner
– detected inner link.fragmentAnchors-broken
– detected inner link without target#fragmentAnchors-mark-errors
– error message summary.error
– error message summaryThe following code should appear on your
common.js,
global.js or skin dependant JS best before an mw.loader.load()
call as described in “
Usage” section.
First, the application object is to be etablished:
if ( typeof mw.libs.fragmentAnchors !== "object" ) {
mw.libs.fragmentAnchors = { };
}
After that, currently there are three options available:
mw.libs.fragmentAnchors.large = true;
This will decorate the full page and does not narrow to content area and not exclude source text edit form.
mw.libs.fragmentAnchors.launch = true;
This will trigger page decoration immediately after loading without generating a link in tool box. It is supposed that loading is limited to certain conditions.
mw.libs.fragmentAnchors.lock = true;
This will prevent from generating a link in tool box and gives opportunity to trigger decoration by any other means, calling .fetch() and .fire() methods.
After the mw.hook
fragmentAnchors.ready
has been triggered a function may be called. The application object is the parameter of the mw.hook callback function and should be identical with mw.libs.fragmentAnchors
.
All functions are components of the application object.
Collect all fragments in HTML document (starting with #
and not decoded).
Call | .fetch()
| ||
---|---|---|---|
Return value |
|
The document wouldn’t get decorated, except on locations of detected errors.
Trigger page decoration from external command.
Call | .fire()
| ||
---|---|---|---|
Return value |
|
Should declare
.lock = true;
in advance if link in
tool box is undesired.
A test page provides examples.
Not required, symbols only.
Source code |
|
ResourceLoader |
|
Namespaces | Every. |
Cookies | None |
mw.libs
|
fragmentAnchors
|
mw.hook
|
fragmentAnchors.ready When page has been equipped with portlet, or is ready for decoration. |
MediaWiki | 1.23 |