User:PerfektesChaos/js/superscriptMagnifier
JavaScript gadget – magnify superscript (and subscript) characters.
Reading measures like m³ and in² for areas, volumes etc. may overstrain people with eyes less sharp as an eagle, or when selected font is using a very dense representation. In general, the meaning might be guessed from the context even when the figures were not recognized.
This tool exchanges the small characters in a wiki page against a variant of the basic font: m3 and in2 rather than m³ and in².
Usage
[edit]- If your project has registered this as a gadget, just activate on your Preferences page.
- Otherwise include the following lines into your common.js, global.js etc.:
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/superscriptMagnifier/r.js&action=raw&bcache=1&maxage=604800&ctype=text/javascript",
"text/javascript" );
Effects
[edit]- Which pages will be affected?
- Any page with user written wikitext.
- This goes also for preview in source code editing, VisualEditor and LivePreview intermediate results.
- Which pages and modes will be ignored?
- Special pages, diff pages, history, page info, media view.
- Some pages may be excluded by system or can be configured via
except
option. This documentation page shall be excluded to demonstrate the difference. - Very large pages may be ignored by
max
user request. - Is the entire page subject to modification?
- No, content area only.
- Headline, portal frame with navigation and footers won’t be modified, nor forms and edit fields.
- What about preformatted text?
- Regions in
<code>
,<pre>
and<syntaxhighlight>
are kept. - Currently HTML entities are resolved by the server and not distinguished in the HTML document. If ever, entities would be ignored.
- Are all superscript and subscript characters magnified?
- No, by default the most common ANSI digits ¹²³ will be detected for performance reasons.
- By
large
this may be extended to all latin characters. - With disabling the
latin
limitation greek and asiatic letters will be covered as well.
User options
[edit]The defaults may be adjusted, and additional decoration may be applied.
Configuration by JavaScript
[edit]Insert the following lines into common.js etc. (best before mw.loader.load):
if ( typeof mw.superscriptMagnifier !== "object" ) {
mw.libs.superscriptMagnifier = { };
}
mw.libs.superscriptMagnifier.key1 = value1; // example
Key | Value | Bedeutung |
---|---|---|
except
|
[ ]
|
Array of pageID numbers which shall not be processed. Default: false – defined by system only, e.g. manual and help pages on characters.
|
lapsus
|
true
|
Equip non-ANSI characters with class=error .They will be listed by remindErrorMessages then. large and locator will be set automatically.Default: false – no error class.
|
large
|
true
|
Include non-ANSI ranges. Default: false – consider ¹²³ only.
|
latin
|
false
|
Limit detection to latin based letters.large comes into effect automatically when this limitation is disabled.Default: true – ignore greek and asiatic letters.
|
locator
|
true
|
Show mark in page bottom area when matched and equip elements with class selektors.Default: false – Just magnify.
|
max
|
0
|
Maximum text size If you have a slow machine and you got the impression that large pages take too long, you may limit analysis time. The value is the maximum permitted number of characters in content area. |
CSS
[edit]When the locator
option is active, CSS selectors will be generated together with the elements. That may be used for debugging and further investigations; undesired characters may be detected.
- .superscriptMagnifier
- All generated elements.
- .superscriptMagnifier-ucs
- Characters beyond ANSI.
- #superscriptMagnifier-info
- Box at bottom of page for debugging.
- .error
- Characters beyond ANSI, when
lapsus
.
The following lines may be inserted into your common.css, global.css or skin dependant CSS. Any attribute value may be applied.
.superscriptMagnifier {
background: #FF8080;
}
Codes
[edit]SuMag is an independent subsystem applicable to any HTML document out of wiki context.
Source code |
|
ResourceLoader |
|
Namespaces |
|
mw.libs
|
superscriptMagnifier
|
mw.hook
|
superscriptMagnifier.ready
|
MediaWiki | 1.23 |