Content deleted Content added
-0.03 |
-0.04 |
||
Line 1:
/// User:PerfektesChaos/js/refNames/core/d.js
/// 2022-07-
// <ref name="..."> major work
// ResourceLoader: compatible;
Line 19:
( function ( mw, $ ) {
"use strict";
var Version = -0.
Signature = "refNames",
THIS = { lapsus: false,
Line 72:
},
PARSER = { reQuot: false,
$textarea: false },
SOURCE = { before: [ ".wikibase-entity-usage",
Line 193 ⟶ 194:
// [ 0 ] -- string, with 2 hex storage path
// [ 1 ] -- string, with signifcant ID
// appearance --
// 2022-07-01 PerfektesChaos@de.wikipedia
var $r = $( "<img>" );
Line 370 ⟶ 371:
// Precondition:
// all -- string, with entire story
// at --
// allow -- true, if bidi permitted
// Postcondition:
Line 455 ⟶ 456:
// Communicate error details (browser console)
// Precondition:
// at --
// alert -- string, with message
// about -- string, with detail, or not
Line 478 ⟶ 479:
// Precondition:
// all -- string, with entire story
// at --
// after --
// about -- string, with attribute name
// Postcondition:
Line 485 ⟶ 486:
// .set -- string, value
// .lock -- boolean, on error
// .more --
// 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 --
// after --
// 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 --
// 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 --
// after --
// about -- object
// .group -- string, ID, or not
Line 643 ⟶ 645:
// Returns about object with modified entries
// .wikitext -- string, modified all
// .next --
// Uses:
// PARSER.fix()
Line 735 ⟶ 737:
PARSER.finish = function ( all, at, alone ) {
// Find </ref> or </references> tag
// Precondition:
// all -- string, with entire story
// at --
// alone -- boolean, for </ref>
// Postcondition:
// Returns Array [ begin, end ] of < >
Line 745 ⟶ 748:
// Uses:
// PARSER.first()
// 2022-07-
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 ===
}
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 --
// after --
// Postcondition:
// Returns position in all, even after
Line 1,036 ⟶ 1,051:
// Precondition:
// all -- string, with entire story
// at --
// 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 -- 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-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,
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
kE = all.charCodeAt( j +
if ( kE === 0x45
▲ 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 --
// apply -- object, with <li> DOM
// Postcondition:
Line 1,791 ⟶ 1,860:
// Equip references list -- $.each()
// Precondition:
// at --
// apply -- object, with <ol> DOM
// Postcondition:
|