Content deleted Content added
PleaseStand (talk | contribs) start cleanup, primarily of backend code |
PleaseStand (talk | contribs) add refsDiv directly under #editform, not within .wikiEditor-ui (fixes overlap issue) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 29:
/*global window, addOnloadHook, SegregateRefsJsL10n, SegregateRefsJsAllowConversion,
wikEdUseWikEd, WikEdUpdateTextarea, WikEdUpdateFrame*/
// <nowiki>
// Translate the right-hand side of these if necessary.
Line 44 ⟶ 46:
refsHeader: "Inline footnotes",
convertHeader: "Generated refs list",
refsCommentComplete: "<!-- Converted to LDR format\n using [[User:PleaseStand/References segregator]] -->\n\n",
convertSummary: "Converted footnotes to LDR format (using [[User:PleaseStand/References segregator|segregate-refs]])",
Line 54 ⟶ 55:
var editForm, refsDiv, refsH2, mainTextbox, refsTextbox, randPrefix, messages,
refsButton, convertButton
/**
Line 131 ⟶ 128:
return null;
}
var attributes =
while ( ( results = attParseRegex.exec( this.parsedRef[1] ) ) ) {
attributes[results[1].toLowerCase()] = htmlUnquote( results[2] );
Line 149 ⟶ 146:
var prefixChars, randNo, randPrefix, refPreferred, scanner, ref, parser, attributes,
refGroup, refName, refStored, refEmpty, refLong, unnamedRefs = 0,
refNames =
// Create a random prefix for autogenerated ref names
Line 177 ⟶ 174:
// The ref already has a name (possibly the empty string)
refName = attributes.name;
refStored =
refEmpty = parser.parsedRef[2].slice( -2 ) == '/>' ||
parser.parsedRef[2].slice( 0, 3 ) == '></';
Line 258 ⟶ 255:
}
var scanner, ref, parser, attributes, refCodes =
preferredRef =
// First, we build an associative array of all the ref codes
Line 269 ⟶ 266:
if ( attributes.name !== undefined ) {
// Only use the first ref having each name
if ( !
refCodes[attributes.name] = ref;
}
Line 283 ⟶ 280:
attributes = parser.getAttributes();
if ( attributes.name !== undefined ) {
if ( !
usageFreq[attributes.name] = 1;
} else {
Line 301 ⟶ 298:
parser = new RefParser( ref );
attributes = parser.getAttributes();
if (
// Is this name on the replacement list?
if (
// If we are using caseCues, and another ___location is
// preferred, skip to the next ref.
if ( caseCues &&
ref.slice( 0, 4 ) != '<REF'
) {
Line 334 ⟶ 331:
// Replace the short code with the long code
outWikiText +=
outWikiText += refLong;
offset = scanner.refScanRegex.lastIndex;
Line 343 ⟶ 340:
}
}
outWikiText += argWikiText.slice( offset );
return {
wikiText:
unusedRefs: refCodes
};
Line 371 ⟶ 370:
// Do the actual integration work
result = integrateRefs(mainTextbox.value, refsTextbox.value, randPrefix,
// Find all unused ref names
for(refName in result.unusedRefs) {
▲ unusedRefNamesQuoted.push(htmlQuote(refName));
}▼
}
// If any refs are unused, warn and allow the user to cancel;
Line 426 ⟶ 423:
// Do the actual segregation work and save the random prefix
var segFormat = segregateRefs(mainTextbox.value, "",
if(!segFormat) {
return false;
Line 458 ⟶ 455:
refsTextbox = document.createElement("textarea");
refsTextbox.id = "PsRefsTextbox";
▲ refsTextbox.value = segFormat.refCodes.join("\n\n");
refsTextbox.cols = mainTextbox.cols;▼
refsTextbox.style.border = "none";
Line 546 ⟶ 537:
refsTextbox.value = messages.refsCommentComplete +
segFormat.refCodes.join("\n");
refsTextbox.rows =
refsTextbox.style.border = "none";
Line 573 ⟶ 563:
return false;
}
}▼
Line 595 ⟶ 569:
try {
}▼
// Handle message translations
messages = (typeof SegregateRefsJsL10n == "object" &&
Line 639 ⟶ 609:
refsDiv.appendChild(refsButton);
refsDiv.appendChild(convertButton);
// Find position within the edit form to insert it at
var refsDivPos = mainTextbox, refsDivPosParent = refsDivPos.parentNode;
while (refsDivPosParent !== editForm) {
refsDivPos = refsDivPosParent;
refsDivPosParent = refsDivPos.parentNode;
if (!refsDivPosParent) {
refsDivPosParent = refsDivPos.parentNode;
break;
▲ }
▲ }
refsDivPos = refsDivPos.nextSibling;
if (refsDivPos && refsDivPos.classList.contains("wikiEditor-ui-clear")) {
refsDivPos = refsDivPos.nextSibling;
▲ }
refsDivPosParent.insertBefore(refsDiv, refsDivPos);
} catch(e) {
}
Line 646 ⟶ 631:
})( jQuery );
// </nowiki>
|