User:Chlod/Scripts/Deputy.js: Difference between revisions

Content deleted Content added
v0.4.0; https://github.com/ChlodAlejandro/deputy/releases/tag/v0.4.0
v0.4.1; https://github.com/ChlodAlejandro/deputy/releases/tag/v0.4.1
Line 1,019:
// All headings (h1, h2, h3, h4, h5, h6)
// TODO: l10n
const headlineElement = this.parsoid ?
el :
el.querySelector('.mw-headline');
return /^H\d$/.test Handle DiscussionTools case (el.tagNamemw-heading) &&
return (el.classList.contains('mw-heading') || /^H\d$/.test(el.tagName)) &&
headlineElement != null &&
/(Page|Article|Local file|File)s? \d+ (to|through) \d+$/.test(headlineElement.innerText);
Line 1,093 ⟶ 1,096:
sectionHeading = sectionHeading.parentElement;
}
}
// When DiscussionTools is being used, the header is wrapped in a div.
if (sectionHeading.parentElement.classList.contains('mw-heading')) {
sectionHeading = sectionHeading.parentElement;
}
const sectionMembers = [];
Line 1,750 ⟶ 1,757:
}
if (toCache.length > 0) {
const expandedData = yield window.deputy.apidispatch.getExpandedRevisionData(toCache);
for (const revisionID in expandedData) {
revisionData.set(+revisionID, new ContributionSurveyRevision(this, expandedData[revisionID]));
Line 1,794 ⟶ 1,801:
return this.comment.replace(cloneRegex$1((ContributionSurveyRow.commentMatchRegex)[this.originalStatus], { post: '$' }), '').trim();
}
return '';
}
}
Line 3,554 ⟶ 3,562:
}
 
var version = "0.4.01";
var gitAbbrevHash = "7de8464a1ccef0";
var gitBranch = "HEAD";
var gitDate = "ThuWed, 1218 Jan 2023 1121:5812:5826 +0800";
var gitVersion = "0.4.01+g7de8464ga1ccef0";
 
/**
Line 3,933 ⟶ 3,941:
const li = this.originalList.children.item(i);
if (li.tagName !== 'LI') {
return// false;Skip this element.
continue;
}
const anchor = li.querySelector('a:first-of-type');
Line 4,151 ⟶ 4,160:
yield this.getSection(Object.assign(wikitext, { revid }));
yield this.prepare();
if (heading.insertAdjacentElementparentElement.classList.contains('afterendmw-heading', this.render()); {
// Intentional recursive call
heading.parentElement.insertAdjacentElement('afterend', this.render());
}
else {
// Intentional recursive call
heading.insertAdjacentElement('afterend', this.render());
}
// Run this asynchronously.
setTimeout(this.loadData.bind(this), 0);
Line 4,669 ⟶ 4,685:
}
yield casePage.addActiveSection(sectionId);
if (heading.insertAdjacentElementparentElement.classList.contains('afterendmw-heading', el.render()); {
heading.parentElement.insertAdjacentElement('afterend', el.render());
}
else {
heading.insertAdjacentElement('afterend', el.render());
}
yield el.loadData();
mw.hook('deputy.load.cci.session').fire();
Line 5,701 ⟶ 5,722:
* API communication class
*/
class DeputyAPIDeputyDispatch {
/**
* Creates a Deputy API instance.
Line 12,828 ⟶ 12,849:
serialize: (v) => v.href,
deserialize: (v) => new URL(v),
defaultValue: new URL('https://zoomiebotdeputy.toolforge.org/bot/api/deputy/'),
displayOptions: { type: 'text' },
alwaysSave: true
Line 15,773 ⟶ 15,794:
*/
constructor() {
this.DeputyAPIDeputyDispatch = DeputyAPIDeputyDispatch;
this.DeputyStorage = DeputyStorage;
this.DeputySession = DeputySession;
Line 15,863 ⟶ 15,884:
yield this.storage.init();
// Initialize the Deputy API interface
this.apidispatch = new DeputyAPIDeputyDispatch();
// Initialize the Deputy preferences instance
this.prefs = new DeputyPreferences();