Content deleted Content added
(bot/CD) |
(bot/CD) |
||
Line 350:
}));
var version = "0.7.
var gitAbbrevHash = "
var gitBranch = "main";
var gitDate = "
var gitVersion = "0.7.
/**
Line 971:
throw e;
}
}▼
/**▼
* Check if a given parameter is a wikitext heading parsed into HTML.
*▼
* This is its own function to account for different parse outputs (Legacy, Parsoid,
* DiscussionTools, etc.)
* @return `true` if the element is a heading, `false` otherwise
*/
return (el.classList.contains('mw-heading') || /^H\d$/.test(el.tagName));
}
/**
* Returns the last item of an array.▼
*
* @param array The array to get the last element from▼
* @return The last element of the array
*/
function last(array) {
return array[array.length - 1];▼
}
/**
* Get the level (1 to 6) of any parsed wikitext heading.
*
* This is its own function to account for different parse outputs (Legacy, Parsoid,
* DiscussionTools, etc.)
*
* @param el The element to check. This MUST be a wikitext heading.
* @return The level of the heading (1 to 6)
*/
function getWikiHeadingLevel(el) {
const h = el.classList.contains('mw-heading') ?
el.querySelector('h1, h2, h3, h4, h5, h6') :
// Check if this is a valid header
if (!/^H\d+$/.test(h.tagName)) {
throw new Error('Heading element does not contain a valid <h*> element');
}
return +last(h.tagName);
}
Line 1,046 ⟶ 1,089:
}
// All headings (h1, h2, h3, h4, h5, h6)
▲ // TODO: l10n
const headlineElement = this.parsoid ?
el :
el.querySelector('.mw-headline');
// Handle DiscussionTools case (.mw-heading)
return isWikiHeading(el
headlineElement != null &&
// eslint-disable-next-line security/detect-non-literal-regexp
/(Page|Article|Local file|File)s? \d+ (to|through) \d+$/.test(headlineElement.innerText);▼
new RegExp(window.deputy.wikiConfig.cci.headingMatch.get()).test(headlineElement.innerText);
}
/**
Line 1,142 ⟶ 1,185:
// Normalize "sectionHeading" to use the h* element and not the .mw-heading span.
sectionHeading = this.normalizeSectionHeading(sectionHeading);
const sectionHeadingLevel = getWikiHeadingLevel(sectionHeading);
const sectionMembers = [];
let nextSibling = sectionHeading.nextSibling;
while (
// Not the end of rendered page content and
nextSibling != null &&
// Next node is not...
!(
// An element
nextSibling instanceof Element &&
// A heading (of any level)
isWikiHeading(nextSibling) &&
// Higher than the current heading level
sectionHeadingLevel >= getWikiHeadingLevel(nextSibling))) {
sectionMembers.push(nextSibling);
nextSibling = nextSibling.nextSibling;
Line 2,955 ⟶ 3,009:
[ContributionSurveyRowStatus.PresumptiveRemoval]: 'trash'
};
▲ /**
▲ * Returns the last item of an array.
▲ *
▲ * @param array The array to get the last element from
▲ * @return The last element of the array
▲ */
▲ function last(array) {
▲ return array[array.length - 1];
▲ }
/**
Line 5,181 ⟶ 5,225:
addSectionOverlay(casePage, heading) {
var _a, _b, _c;
const
const section = casePage.getContributionSurveySection(normalizedHeading);
const list = section.find((v) => v instanceof HTMLElement && v.tagName === 'UL');
const headingTop = window.scrollY +
const sectionBottom = window.scrollY + ((_c = (_b = (_a = findNextSiblingElement(last(section))) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.top) !== null && _c !== void 0 ? _c :
const overlayHeight = sectionBottom - headingTop;
if (list != null) {
Line 13,818 ⟶ 13,864:
defaultValue: null,
displayOptions: { type: 'page' }
}),
headingMatch: new Setting({
▲
displayOptions: { type: 'text' }
}),
collapseTop: new Setting({
|