User:PerfektesChaos/js/refNames/core/d.js: Difference between revisions

Content deleted Content added
-0.03
-0.04
Line 1:
/// User:PerfektesChaos/js/refNames/core/d.js
/// 2022-07-2728 PerfektesChaos@de.wikipedia
// <ref name="..."> major work
// ResourceLoader: compatible;
Line 19:
( function ( mw, $ ) {
"use strict";
var Version = -0.0304,
Signature = "refNames",
THIS = { lapsus: false,
Line 72:
},
PARSER = { reQuot: false,
pending: ! PARSER.lock ) {false,
$textarea: false },
SOURCE = { before: [ ".wikibase-entity-usage",
Line 193 ⟶ 194:
// [ 0 ] -- string, with 2 hex storage path
// [ 1 ] -- string, with signifcant ID
// appearance -- intnumber, with pixel size
// 2022-07-01 PerfektesChaos@de.wikipedia
var $r = $( "<img>" );
Line 370 ⟶ 371:
// Precondition:
// all -- string, with entire story
// at -- intnumber, position in all
// allow -- true, if bidi permitted
// Postcondition:
Line 455 ⟶ 456:
// Communicate error details (browser console)
// Precondition:
// at -- intnumber, position in wikitext
// alert -- string, with message
// about -- string, with detail, or not
Line 478 ⟶ 479:
// Precondition:
// all -- string, with entire story
// at -- intnumber, first possible position in all
// after -- intnumber, position of '>' in all
// about -- string, with attribute name
// Postcondition:
Line 485 ⟶ 486:
// .set -- string, value
// .lock -- boolean, on error
// .more -- intnumber, position after value
// Uses:
// PARSER.first()
Line 544 ⟶ 545:
 
 
PARSER.features = function ( all, at, after, alone ) {
// Retrieve <ref> or </references> tag attributes
// Precondition:
// all -- string, with entire story
// at -- intnumber, first possible position in all
// after -- intnumber, position of '>' in all
// alone -- boolean, for </ref>
// Postcondition:
// Returns object with name="", or not
Line 557 ⟶ 559:
// .content -- string, content until </ref>, or not
// .lone -- boolean, unary (/)
// .next -- intnumber, position of '>' in all
// Uses:
// < PARSER.lock
Line 605 ⟶ 607:
if ( lock ) {
PARSER.lock = true;
} else if ( alone && r ) {
i = PARSER.first( all, i, after );
if ( all.charCodeAt( i ) === 0x2F ) { // /
Line 612 ⟶ 614:
}
if ( i === after ) {
if ( r && ! r.name && alone ) {
r = false;
}
Line 629 ⟶ 631:
// Precondition:
// all -- string, with entire story
// at -- intnumber, position after '<' in all
// after -- intnumber, position of '>' in all
// about -- object
// .group -- string, ID, or not
Line 643 ⟶ 645:
// Returns about object with modified entries
// .wikitext -- string, modified all
// .next -- intnumber, modified after position
// Uses:
// PARSER.fix()
Line 735 ⟶ 737:
 
 
PARSER.finish = function ( all, at, alone ) {
// Find </ref> or </references> tag
// Precondition:
// all -- string, with entire story
// at -- intnumber, first possible position in all
// alone -- boolean, for </ref>
// Postcondition:
// Returns Array [ begin, end ] of < >
Line 745 ⟶ 748:
// Uses:
// PARSER.first()
// 2022-07-0128 PerfektesChaos@de.wikipedia
var i = at,
j, kR, kE, kF, n, r, s;
do {
i = all.indexOf( "<", i );
Line 767 ⟶ 770:
if ( ( kR === 0x52 || kR === 0x72 ) &&
( kE === 0x45 || kE === 0x65 ) &&
( kF === 0x46 || kF === 0x66 ) ) &&{
if ( n === j + 4 alone) ||{
if ( n === PARSER.first( all, j + 4, n ) ) ) {||
r n === [ iPARSER.first( -all, 1 j + 4, n ];) ) {
r = PARSER.fiat( all,[ i, n,- r1, adjust )n ];
}
} else if ( n >= j + adjust.group === r.group10 ) &&{
kE = all.charCodeAt( j + 4 );
if ( kE === 0x45 || kE === 0x65 ) {
s = all.substring( j + 1, j + 11 )
.toLowerCase();
if ( s === "references" ) {
r = [ i - 1, n ];
}
}
}
}
}
Line 960 ⟶ 975:
// Precondition:
// all -- string, with entire story
// at -- intnumber, first position in all
// after -- intnumber, beyond position in all
// Postcondition:
// Returns position in all, even after
Line 1,036 ⟶ 1,051:
// Precondition:
// all -- string, with entire story
// at -- intnumber, first possible position in all
// adjust -- object, with name-group to be replaced, or not
// .group -- string, ID, or not
Line 1,047 ⟶ 1,062:
// .content -- string, content until </ref>, or not
// .lone -- boolean, unary (/)
// .next multi -- intnumber, position of closing '>' in all0
// .next -- number, position of closing '>' in all
// .wikitext -- string, modified all
// Uses:
// >< PARSER.pending
// < PARSER.lock
// PARSER.first()
Line 1,055 ⟶ 1,072:
// PARSER.features()
// PARSER.fiat()
// 2022-07-01 PerfektesChaos@de PARSER.wikipediafrontal()
// 2022-07-28 PerfektesChaos@de.wikipedia
var i = at,
j, kR, kE, kF, n, r, v;
Line 1,067 ⟶ 1,085:
if ( n < 0 ) {
break; // while ! r
} else if ( n >= i + 10 ) {
j = PARSER.first( all, i, n );
if ( n >= j + 10 ) {
kR = all.charCodeAt( j );
kE = all.charCodeAt( j + 1 );
kF = all.charCodeAt( j + 2 );
if ( ( kR === 0x52 || kR === 0x72 ) &&
( kE === 0x45 || kE === 0x65 ) &&
( kF === 0x46 || kF === 0x66 ) ) &&{
if ( flat( all, j + 3 ) === 0x20 ) {
r = PARSER.features( all, j + 4, n, true );
if ( r ) {
if ( ! r.lone ) {
v = PARSER.finish( all, n + 1, true );
if ( v ) {
r.content = all.substring( n + 1, v[ 0 ] )
.trim( v[ 0 ] );
r.next = v[ 1 ] + 1 .trim();
} else { r.next = v[ 1 ] + 1;
PARSER.lock} =else true;{
PARSER.fault( i, "Missing </ref>"PARSER.lock = )true;
PARSER.fault( i, "Missing </ref>" );
}
}
if ( PARSER.pending ) {
if ( r.next < PARSER.pending.max ) {
r.group = PARSER.pending.shared;
} else {
PARSER.pending = false;
}
}
if ( r.name &&
adjust &&
adjust.seek === r.name &&
( ( ! adjust.group && ! r.group ) ||
adjust.group === r.group ) &&
! PARSER.lock ) {
r = PARSER.fiat( all, i, n, r, adjust );
}
}
} else if ( r.name &&{
kE = all.charCodeAt( j + adjust3 &&);
if ( kE === 0x45 adjust.seek || kE === r.name 0x65 ) &&{
PARSER.frontal( (all, !j, adjust.group && ! r.groupn ) ||;
adjust.group === r.group ) &&
! PARSER.lock ) {
r = PARSER.fiat( all, i, n, r, adjust );
}
}
Line 1,106 ⟶ 1,138:
return r;
}; // PARSER.front()
 
 
 
PARSER.frontal = function ( all, at, after ) {
// Check opening <references group=""> tag
// Precondition:
// all -- string, with entire story
// at -- number, position of "ref" in all
// after -- number, position of ">" in all
// Uses:
// >< PARSER.pending
// < PARSER.lock
// flat()
// PARSER.features()
// PARSER.finish()
// 2022-07-28 PerfektesChaos@de.wikipedia
var s = all.substring( at, at + 10 ).toLowerCase(),
k, q;
if ( s === "references" ) {
k = flat( all, at + 10 );
if ( k === 0x20 ) {
q = PARSER.features( all, at + 10, after, false );
if ( q && q.group ) {
PARSER.pending = { shared: q.group };
q = PARSER.finish( all, at + 10, false );
if ( q ) {
PARSER.pending.max = q[ 0 ];
} else {
PARSER.pending.max = all.length;
PARSER.lock = true;
}
}
} else if ( PARSER.pending ) {
PARSER.pending = false;
}
}
}; // PARSER.frontal()
 
 
Line 1,752 ⟶ 1,821:
// Equip references list item -- $.each()
// Precondition:
// at -- intnumber, with sequence index
// apply -- object, with <li> DOM
// Postcondition:
Line 1,791 ⟶ 1,860:
// Equip references list -- $.each()
// Precondition:
// at -- intnumber, with sequence index
// apply -- object, with <ol> DOM
// Postcondition: