From d45aaac7627be45db8b24ec05db99bc91213ffc5 Mon Sep 17 00:00:00 2001 From: NovemLinguae <79697282+NovemLinguae@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:02:02 -0800 Subject: [PATCH] capitalize Morebit class names (#2087) related #2084 - case sensitive, all repo search and replace, excluding test files and the file morebits.js. will handle those in a later patch since messing with the morebits.js file may be risky ```js Morebits.BatchOperation = Morebits.batchOperation; Morebits.Date = Morebits.date; Morebits.QuickForm = Morebits.quickForm; Morebits.QuickForm.Element = Morebits.quickForm.element; Morebits.SimpleWindow = Morebits.simpleWindow; Morebits.Status = Morebits.status; Morebits.TaskManager = Morebits.taskManager; Morebits.Unbinder = Morebits.unbinder; Morebits.UserspaceLogger = Morebits.userspaceLogger; Morebits.wiki.Api = Morebits.wiki.api; Morebits.wiki.Page = Morebits.wiki.page; Morebits.wiki.Preview = Morebits.wiki.preview; Morebits.wikitext.Page = Morebits.wikitext.page; ``` --- modules/twinklearv.js | 70 +++++++-------- modules/twinklebatchdelete.js | 76 ++++++++-------- modules/twinklebatchprotect.js | 36 ++++---- modules/twinklebatchundelete.js | 36 ++++---- modules/twinkleblock.js | 86 +++++++++--------- modules/twinkleconfig.js | 14 +-- modules/twinkledeprod.js | 32 +++---- modules/twinklediff.js | 4 +- modules/twinkleimage.js | 20 ++--- modules/twinkleprod.js | 32 +++---- modules/twinkleprotect.js | 70 +++++++-------- modules/twinklerollback.js | 48 +++++----- modules/twinkleshared.js | 22 ++--- modules/twinklespeedy.js | 60 ++++++------- modules/twinkletag.js | 62 ++++++------- modules/twinkletalkback.js | 30 +++---- modules/twinkleunlink.js | 32 +++---- modules/twinklewarn.js | 74 ++++++++-------- modules/twinklewelcome.js | 26 +++--- modules/twinklexfd.js | 152 ++++++++++++++++---------------- morebits.css | 8 +- twinkle.js | 4 +- 22 files changed, 497 insertions(+), 497 deletions(-) diff --git a/modules/twinklearv.js b/modules/twinklearv.js index 7020ab07e..a115db0b5 100644 --- a/modules/twinklearv.js +++ b/modules/twinklearv.js @@ -29,7 +29,7 @@ Twinkle.arv = function twinklearv() { }; Twinkle.arv.callback = function (uid, isIP) { - const Window = new Morebits.simpleWindow(600, 500); + const Window = new Morebits.SimpleWindow(600, 500); Window.setTitle('Advance Reporting and Vetting'); // Backronym Window.setScriptName('Twinkle'); Window.addFooterLink('AIV guide', 'WP:GAIV'); @@ -39,7 +39,7 @@ Twinkle.arv.callback = function (uid, isIP) { Window.addFooterLink('Twinkle help', 'WP:TW/DOC#arv'); Window.addFooterLink('Give feedback', 'WT:TW'); - const form = new Morebits.quickForm(Twinkle.arv.callback.evaluate); + const form = new Morebits.QuickForm(Twinkle.arv.callback.evaluate); const categories = form.append({ type: 'select', name: 'category', @@ -108,7 +108,7 @@ Twinkle.arv.callback = function (uid, isIP) { } else { query.bkusers = uid; } - new Morebits.wiki.api("Checking the user's block status", query, ((apiobj) => { + new Morebits.wiki.Api("Checking the user's block status", query, ((apiobj) => { const blocklist = apiobj.getResponse().query.blocks; if (blocklist.length) { // If an IP is blocked *and* rangeblocked, only use whichever is more recent @@ -132,14 +132,14 @@ Twinkle.arv.callback = function (uid, isIP) { Twinkle.arv.callback.changeCategory = function (e) { const value = e.target.value; const root = e.target.form; - const old_area = Morebits.quickForm.getElements(root, 'work_area')[0]; + const old_area = Morebits.QuickForm.getElements(root, 'work_area')[0]; let work_area = null; switch (value) { case 'aiv': /* falls through */ default: - work_area = new Morebits.quickForm.element({ + work_area = new Morebits.QuickForm.Element({ type: 'field', label: 'Report user for vandalism', name: 'work_area' @@ -219,7 +219,7 @@ Twinkle.arv.callback.changeCategory = function (e) { old_area.parentNode.replaceChild(work_area, old_area); break; case 'username': - work_area = new Morebits.quickForm.element({ + work_area = new Morebits.QuickForm.Element({ type: 'field', label: 'Report username violation', name: 'work_area' @@ -265,7 +265,7 @@ Twinkle.arv.callback.changeCategory = function (e) { break; case 'puppet': - work_area = new Morebits.quickForm.element({ + work_area = new Morebits.QuickForm.Element({ type: 'field', label: 'Report suspected sockpuppet', name: 'work_area' @@ -298,7 +298,7 @@ Twinkle.arv.callback.changeCategory = function (e) { old_area.parentNode.replaceChild(work_area, old_area); break; case 'sock': - work_area = new Morebits.quickForm.element({ + work_area = new Morebits.QuickForm.Element({ type: 'field', label: 'Report suspected sockpuppeteer', name: 'work_area' @@ -330,7 +330,7 @@ Twinkle.arv.callback.changeCategory = function (e) { old_area.parentNode.replaceChild(work_area, old_area); break; case 'an3': - work_area = new Morebits.quickForm.element({ + work_area = new Morebits.QuickForm.Element({ type: 'field', label: 'Report edit warring', name: 'work_area' @@ -348,7 +348,7 @@ Twinkle.arv.callback.changeCategory = function (e) { event: function(e) { const root = e.target.form; - const date = new Morebits.date().subtract(48, 'hours'); // all since 48 hours + const date = new Morebits.Date().subtract(48, 'hours'); // all since 48 hours // Run for each AN3 field const getAN3Entries = function(field, rvuser, titles) { @@ -390,7 +390,7 @@ Twinkle.arv.callback.changeCategory = function (e) { } else { comment += '"' + rev.parsedcomment + '"'; } - comment += ' at ' + new Morebits.date(rev.timestamp).calendar() + ''; + comment += ' at ' + new Morebits.Date(rev.timestamp).calendar() + ''; $entry.append(comment).appendTo($field); } } @@ -470,7 +470,7 @@ Twinkle.arv.callback.changeCategory = function (e) { Twinkle.arv.callback.evaluate = function(e) { const form = e.target; let reason = ''; - const input = Morebits.quickForm.getInputData(form); + const input = Morebits.QuickForm.getInputData(form); const uid = form.uid.value; @@ -487,13 +487,13 @@ Twinkle.arv.callback.evaluate = function(e) { return; } - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(form); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(form); Morebits.wiki.actionCompleted.redirect = 'Wikipedia:Administrator intervention against vandalism'; Morebits.wiki.actionCompleted.notice = 'Reporting complete'; - var aivPage = new Morebits.wiki.page('Wikipedia:Administrator intervention against vandalism', 'Processing AIV request'); + var aivPage = new Morebits.wiki.Page('Wikipedia:Administrator intervention against vandalism', 'Processing AIV request'); aivPage.setPageSection(1); aivPage.setFollowRedirect(true); @@ -504,12 +504,12 @@ Twinkle.arv.callback.evaluate = function(e) { // check if user has already been reported if (new RegExp('\\{\\{\\s*(?:(?:[Ii][Pp])?[Vv]andal|[Uu]serlinks)\\s*\\|\\s*(?:1=)?\\s*' + Morebits.string.escapeRegExp(input.uid) + '\\s*\\}\\}').test(text)) { aivPage.getStatusElement().error('Report already present, will not add a new one'); - Morebits.status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them under the existing report for this user at ' + $aivLink + ':'); + Morebits.Status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them under the existing report for this user at ' + $aivLink + ':'); return; } // then check for any bot reports - const tb2Page = new Morebits.wiki.page('Wikipedia:Administrator intervention against vandalism/TB2', 'Checking bot reports'); + const tb2Page = new Morebits.wiki.Page('Wikipedia:Administrator intervention against vandalism/TB2', 'Checking bot reports'); tb2Page.load(() => { const tb2Text = tb2Page.getPageText(); const tb2statelem = tb2Page.getStatusElement(); @@ -519,7 +519,7 @@ Twinkle.arv.callback.evaluate = function(e) { tb2statelem.info('Proceeded despite bot report'); } else { tb2statelem.error('Report from a bot is already present, stopping'); - Morebits.status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them at ' + $aivLink + ':'); + Morebits.Status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them at ' + $aivLink + ':'); return; } } else { @@ -541,13 +541,13 @@ Twinkle.arv.callback.evaluate = function(e) { reason = Twinkle.arv.callback.getUsernameReportWikitext(input); - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(form); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(form); Morebits.wiki.actionCompleted.redirect = 'Wikipedia:Usernames for administrator attention'; Morebits.wiki.actionCompleted.notice = 'Reporting complete'; - var uaaPage = new Morebits.wiki.page('Wikipedia:Usernames for administrator attention', 'Processing UAA request'); + var uaaPage = new Morebits.wiki.Page('Wikipedia:Usernames for administrator attention', 'Processing UAA request'); uaaPage.setFollowRedirect(true); uaaPage.load(() => { @@ -557,7 +557,7 @@ Twinkle.arv.callback.evaluate = function(e) { if (new RegExp('\\{\\{\\s*user-uaa\\s*\\|\\s*(1\\s*=\\s*)?' + Morebits.string.escapeRegExp(input.uid) + '\\s*(\\||\\})').test(text)) { uaaPage.getStatusElement().error('User is already listed.'); const $uaaLink = 'WP:UAA'; - Morebits.status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them under the existing report for this user at ' + $uaaLink + ':'); + Morebits.Status.printUserText(reason, 'The comments you typed are provided below, in case you wish to manually post them under the existing report for this user at ' + $uaaLink + ':'); return; } uaaPage.getStatusElement().status('Adding new report...'); @@ -591,8 +591,8 @@ Twinkle.arv.callback.evaluate = function(e) { sockParameters.uid = puppetReport ? form.sockmaster.value.trim() : uid; sockParameters.sockpuppets = puppetReport ? [uid] : Morebits.array.uniq($.map($('input:text[name=sockpuppet]', form), (o) => $(o).val() || null)); - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(form); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(form); Twinkle.arv.processSock(sockParameters); break; @@ -627,8 +627,8 @@ Twinkle.arv.callback.evaluate = function(e) { free_resolves: free_resolves }; - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(form); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(form); Twinkle.arv.processAN3(an3Parameters); }; @@ -835,7 +835,7 @@ Twinkle.arv.processSock = function(params) { Morebits.wiki.actionCompleted.redirect = reportpage; Morebits.wiki.actionCompleted.notice = 'Reporting complete'; - const spiPage = new Morebits.wiki.page(reportpage, 'Retrieving discussion page'); + const spiPage = new Morebits.wiki.Page(reportpage, 'Retrieving discussion page'); spiPage.setFollowRedirect(true); spiPage.setEditSummary('Adding new report for [[Special:Contributions/' + params.uid + '|' + params.uid + ']].'); spiPage.setChangeTags(Twinkle.changeTags); @@ -915,14 +915,14 @@ Twinkle.arv.processAN3 = function(params) { if (sub.length >= 2) { const last = sub[0]; const first = sub.slice(-1)[0]; - const label = 'Consecutive edits made from ' + new Morebits.date(first.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.date(last.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)'; + const label = 'Consecutive edits made from ' + new Morebits.Date(first.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.Date(last.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)'; ret = '# {{diff|oldid=' + first.parentid + '|diff=' + last.revid + '|label=' + label + '}}\n'; } - ret += sub.reverse().map((v) => (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); + ret += sub.reverse().map((v) => (sub.length >= 2 ? '#' : '') + '# {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); return ret; }).reverse().join('\n'); - const warningtext = params.warnings.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); - let resolvetext = params.resolves.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); + const warningtext = params.warnings.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); + let resolvetext = params.resolves.reverse().map((v) => '# ' + ' {{diff2|' + v.revid + '|' + new Morebits.Date(v.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC)}} ' + hasHiddenComment(v)).join('\n'); if (params.free_resolves) { const page = params.free_resolves; @@ -933,11 +933,11 @@ Twinkle.arv.processAN3 = function(params) { let rev; if (revCount < 3) { // diff=prev or next rev = revCount === 1 ? page.revisions[0] : page.revisions[1]; - resolvetext += '\n# ' + ' {{diff2|' + rev.revid + '|' + new Morebits.date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev); + resolvetext += '\n# ' + ' {{diff2|' + rev.revid + '|' + new Morebits.Date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title + '}} ' + hasHiddenComment(rev); } else { // diff and oldid are nonconsecutive rev = page.revisions[0]; const revLatest = page.revisions[revCount - 1]; - const label = 'Consecutive edits made from ' + new Morebits.date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.date(revLatest.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title; + const label = 'Consecutive edits made from ' + new Morebits.Date(rev.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) to ' + new Morebits.Date(revLatest.timestamp).format('HH:mm, D MMMM YYYY', 'utc') + ' (UTC) on ' + page.title; resolvetext += '\n# {{diff|oldid=' + rev.revid + '|diff=' + revLatest.revid + '|label=' + label + '}}\n'; } } @@ -956,7 +956,7 @@ Twinkle.arv.processAN3 = function(params) { Morebits.wiki.actionCompleted.redirect = reportpage; Morebits.wiki.actionCompleted.notice = 'Reporting complete'; - const an3Page = new Morebits.wiki.page(reportpage, 'Retrieving discussion page'); + const an3Page = new Morebits.wiki.Page(reportpage, 'Retrieving discussion page'); an3Page.setFollowRedirect(true); an3Page.setEditSummary('Adding new report for [[Special:Contributions/' + params.uid + '|' + params.uid + ']].'); an3Page.setChangeTags(Twinkle.changeTags); @@ -967,7 +967,7 @@ Twinkle.arv.processAN3 = function(params) { const notifyText = '\n\n{{subst:an3-notice|1=' + mw.util.wikiUrlencode(params.uid) + '|auto=1}} ~~~~'; - const talkPage = new Morebits.wiki.page('User talk:' + params.uid, 'Notifying edit warrior'); + const talkPage = new Morebits.wiki.Page('User talk:' + params.uid, 'Notifying edit warrior'); talkPage.setFollowRedirect(true); talkPage.setEditSummary('Notifying about edit warring noticeboard discussion.'); talkPage.setChangeTags(Twinkle.changeTags); diff --git a/modules/twinklebatchdelete.js b/modules/twinklebatchdelete.js index 5a4f61c4a..2bb2446af 100644 --- a/modules/twinklebatchdelete.js +++ b/modules/twinklebatchdelete.js @@ -28,13 +28,13 @@ let subpagesLoaded; Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { subpagesLoaded = false; - const Window = new Morebits.simpleWindow(600, 400); + const Window = new Morebits.SimpleWindow(600, 400); Window.setTitle('Batch deletion'); Window.setScriptName('Twinkle'); Window.addFooterLink('Twinkle help', 'WP:TW/DOC#batchdelete'); Window.addFooterLink('Give feedback', 'WT:TW'); - const form = new Morebits.quickForm(Twinkle.batchdelete.callback.evaluate); + const form = new Morebits.QuickForm(Twinkle.batchdelete.callback.evaluate); form.append({ type: 'checkbox', list: [ @@ -158,13 +158,13 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { const statusdiv = document.createElement('div'); statusdiv.style.padding = '15px'; // just so it doesn't look broken Window.setContent(statusdiv); - Morebits.status.init(statusdiv); + Morebits.Status.init(statusdiv); Window.display(); Twinkle.batchdelete.pages = {}; - const statelem = new Morebits.status('Grabbing list of pages'); - const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => { + const statelem = new Morebits.Status('Grabbing list of pages'); + const wikipedia_api = new Morebits.wiki.Api('loading...', query, ((apiobj) => { const response = apiobj.getResponse(); let pages = (response.query && response.query.pages) || []; pages = pages.filter((page) => !page.missing && page.imagerepository !== 'shared'); @@ -178,7 +178,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop(); if (editProt) { metadata.push('fully protected' + - (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)')); + (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.Date(editProt.expiry).calendar('utc') + ' (UTC)')); } if (page.ns === 6) { @@ -232,7 +232,7 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() { var result = form.render(); apiobj.params.Window.setContent(result); - Morebits.quickForm.getElements(result, 'pages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(result, 'pages').forEach(Twinkle.generateArrowLinks); }), statelem); @@ -252,7 +252,7 @@ Twinkle.batchdelete.generateNewPageList = function(form) { Twinkle.batchdelete.pages[elements.value].checked = elements.checked; } - return new Morebits.quickForm.element({ + return new Morebits.QuickForm.Element({ type: 'checkbox', name: 'pages', id: 'tw-dbatch-pages', @@ -286,8 +286,8 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) newPageList = Twinkle.batchdelete.generateNewPageList(form); $('#tw-dbatch-pages').replaceWith(newPageList); - Morebits.quickForm.getElements(newPageList, 'pages').forEach(Twinkle.generateArrowLinks); - Morebits.quickForm.getElements(newPageList, 'pages.subpages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(newPageList, 'pages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(newPageList, 'pages.subpages').forEach(Twinkle.generateArrowLinks); return; } @@ -298,7 +298,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) const pages = $(form.pages).map((i, el) => el.value).get(); - const subpageLister = new Morebits.batchOperation(); + const subpageLister = new Morebits.BatchOperation(); subpageLister.setOption('chunkSize', Twinkle.getPref('batchChunks')); subpageLister.setPageList(pages); subpageLister.run((pageName) => { @@ -310,7 +310,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) return; } - const wikipedia_api = new Morebits.wiki.api('Getting list of subpages of ' + pageName, { + const wikipedia_api = new Morebits.wiki.Api('Getting list of subpages of ' + pageName, { action: 'query', prop: 'revisions|info|imageinfo', generator: 'allpages', @@ -334,7 +334,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) const editProt = page.protection.filter((pr) => pr.type === 'edit' && pr.level === 'sysop').pop(); if (editProt) { metadata.push('fully protected' + - (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)')); + (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.Date(editProt.expiry).calendar('utc') + ' (UTC)')); } if (page.ns === 6) { metadata.push('uploader: ' + page.imageinfo[0].user); @@ -374,8 +374,8 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) newPageList = Twinkle.batchdelete.generateNewPageList(form); $('#tw-dbatch-pages').replaceWith(newPageList); - Morebits.quickForm.getElements(newPageList, 'pages').forEach(Twinkle.generateArrowLinks); - Morebits.quickForm.getElements(newPageList, 'pages.subpages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(newPageList, 'pages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(newPageList, 'pages.subpages').forEach(Twinkle.generateArrowLinks); subpagesLoaded = true; @@ -399,7 +399,7 @@ Twinkle.batchdelete.callback.toggleSubpages = function twDbatchToggleSubpages(e) newPageList = Twinkle.batchdelete.generateNewPageList(form); $('#tw-dbatch-pages').replaceWith(newPageList); - Morebits.quickForm.getElements(newPageList, 'pages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(newPageList, 'pages').forEach(Twinkle.generateArrowLinks); } }; @@ -408,25 +408,25 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu const form = event.target; - const numProtected = $(Morebits.quickForm.getElements(form, 'pages')).filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red').length; + const numProtected = $(Morebits.QuickForm.getElements(form, 'pages')).filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red').length; if (numProtected > 0 && !confirm('You are about to delete ' + mw.language.convertNumber(numProtected) + ' fully protected page(s). Are you sure?')) { return; } - const input = Morebits.quickForm.getInputData(form); + const input = Morebits.QuickForm.getInputData(form); if (!input.reason) { alert('You need to give a reason, you cabal crony!'); return; } - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(form); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(form); if (input.pages.length === 0) { - Morebits.status.error('Error', 'nothing to delete, aborting'); + Morebits.Status.error('Error', 'nothing to delete, aborting'); return; } - const pageDeleter = new Morebits.batchOperation(input.delete_page ? 'Deleting pages' : 'Initiating requested tasks'); + const pageDeleter = new Morebits.BatchOperation(input.delete_page ? 'Deleting pages' : 'Initiating requested tasks'); pageDeleter.setOption('chunkSize', Twinkle.getPref('batchChunks')); // we only need the initial status lines if we're deleting the pages in the pages array pageDeleter.setOption('preserveIndividualStatusLines', input.delete_page); @@ -443,7 +443,7 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu pageDeleter: pageDeleter }; - const wikipedia_page = new Morebits.wiki.page(pageName, 'Deleting page ' + pageName); + const wikipedia_page = new Morebits.wiki.Page(pageName, 'Deleting page ' + pageName); wikipedia_page.setCallbackParameters(params); if (input.delete_page) { wikipedia_page.setEditSummary(input.reason); @@ -455,7 +455,7 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu } }, () => { if (input.delete_subpages && input.subpages) { - const subpageDeleter = new Morebits.batchOperation('Deleting subpages'); + const subpageDeleter = new Morebits.BatchOperation('Deleting subpages'); subpageDeleter.setOption('chunkSize', Twinkle.getPref('batchChunks')); subpageDeleter.setOption('preserveIndividualStatusLines', true); subpageDeleter.setPageList(input.subpages); @@ -471,7 +471,7 @@ Twinkle.batchdelete.callback.evaluate = function twinklebatchdeleteCallbackEvalu pageDeleter: subpageDeleter }; - const wikipedia_page = new Morebits.wiki.page(pageName, 'Deleting subpage ' + pageName); + const wikipedia_page = new Morebits.wiki.Page(pageName, 'Deleting subpage ' + pageName); wikipedia_page.setCallbackParameters(params); wikipedia_page.setEditSummary(input.reason); wikipedia_page.setChangeTags(Twinkle.changeTags); @@ -505,7 +505,7 @@ Twinkle.batchdelete.callbacks = { bllimit: 'max', // 500 is max for normal users, 5000 for bots and sysops format: 'json' }; - wikipedia_api = new Morebits.wiki.api('Grabbing backlinks', query, Twinkle.batchdelete.callbacks.unlinkBacklinksMain); + wikipedia_api = new Morebits.wiki.Api('Grabbing backlinks', query, Twinkle.batchdelete.callbacks.unlinkBacklinksMain); wikipedia_api.params = params; wikipedia_api.post(); } @@ -518,7 +518,7 @@ Twinkle.batchdelete.callbacks = { iulimit: 'max', // 500 is max for normal users, 5000 for bots and sysops format: 'json' }; - wikipedia_api = new Morebits.wiki.api('Grabbing file links', query, Twinkle.batchdelete.callbacks.unlinkImageInstancesMain); + wikipedia_api = new Morebits.wiki.Api('Grabbing file links', query, Twinkle.batchdelete.callbacks.unlinkImageInstancesMain); wikipedia_api.params = params; wikipedia_api.post(); } @@ -532,7 +532,7 @@ Twinkle.batchdelete.callbacks = { rdlimit: 'max', // 500 is max for normal users, 5000 for bots and sysops format: 'json' }; - wikipedia_api = new Morebits.wiki.api('Grabbing redirects', query, Twinkle.batchdelete.callbacks.deleteRedirectsMain); + wikipedia_api = new Morebits.wiki.Api('Grabbing redirects', query, Twinkle.batchdelete.callbacks.deleteRedirectsMain); wikipedia_api.params = params; wikipedia_api.post(); } @@ -545,7 +545,7 @@ Twinkle.batchdelete.callbacks = { titles: pageTitle.toText(), format: 'json' }; - wikipedia_api = new Morebits.wiki.api('Checking whether talk page exists', query, Twinkle.batchdelete.callbacks.deleteTalk); + wikipedia_api = new Morebits.wiki.Api('Checking whether talk page exists', query, Twinkle.batchdelete.callbacks.deleteTalk); wikipedia_api.params = params; wikipedia_api.params.talkPage = pageTitle.toText(); wikipedia_api.post(); @@ -561,11 +561,11 @@ Twinkle.batchdelete.callbacks = { return; } - const redirectDeleter = new Morebits.batchOperation('Deleting redirects to ' + apiobj.params.page); + const redirectDeleter = new Morebits.BatchOperation('Deleting redirects to ' + apiobj.params.page); redirectDeleter.setOption('chunkSize', Twinkle.getPref('batchChunks')); redirectDeleter.setPageList(pages); redirectDeleter.run((pageName) => { - const wikipedia_page = new Morebits.wiki.page(pageName, 'Deleting ' + pageName); + const wikipedia_page = new Morebits.wiki.Page(pageName, 'Deleting ' + pageName); wikipedia_page.setEditSummary('[[WP:CSD#G8|G8]]: Redirect to deleted page "' + apiobj.params.page + '"'); wikipedia_page.setChangeTags(Twinkle.changeTags); wikipedia_page.deletePage(redirectDeleter.workerSuccess, redirectDeleter.workerFailure); @@ -579,7 +579,7 @@ Twinkle.batchdelete.callbacks = { return; } - const page = new Morebits.wiki.page(apiobj.params.talkPage, 'Deleting talk page of page ' + apiobj.params.page); + const page = new Morebits.wiki.Page(apiobj.params.talkPage, 'Deleting talk page of page ' + apiobj.params.page); page.setEditSummary('[[WP:CSD#G8|G8]]: [[Help:Talk page|Talk page]] of deleted page "' + apiobj.params.page + '"'); page.setChangeTags(Twinkle.changeTags); page.deletePage(); @@ -592,11 +592,11 @@ Twinkle.batchdelete.callbacks = { return; } - const unlinker = new Morebits.batchOperation('Unlinking backlinks to ' + apiobj.params.page); + const unlinker = new Morebits.BatchOperation('Unlinking backlinks to ' + apiobj.params.page); unlinker.setOption('chunkSize', Twinkle.getPref('batchChunks')); unlinker.setPageList(pages); unlinker.run((pageName) => { - const wikipedia_page = new Morebits.wiki.page(pageName, 'Unlinking on ' + pageName); + const wikipedia_page = new Morebits.wiki.Page(pageName, 'Unlinking on ' + pageName); const params = Object.assign({}, apiobj.params); params.title = pageName; params.unlinker = unlinker; @@ -619,7 +619,7 @@ Twinkle.batchdelete.callbacks = { text = pageobj.getPageText(); } const old_text = text; - const wikiPage = new Morebits.wikitext.page(text); + const wikiPage = new Morebits.wikitext.Page(text); text = wikiPage.removeLink(params.page).getText(); Twinkle.batchdelete.unlinkCache[params.title] = text; @@ -643,11 +643,11 @@ Twinkle.batchdelete.callbacks = { return; } - const unlinker = new Morebits.batchOperation('Unlinking backlinks to ' + apiobj.params.page); + const unlinker = new Morebits.BatchOperation('Unlinking backlinks to ' + apiobj.params.page); unlinker.setOption('chunkSize', Twinkle.getPref('batchChunks')); unlinker.setPageList(pages); unlinker.run((pageName) => { - const wikipedia_page = new Morebits.wiki.page(pageName, 'Removing file usages on ' + pageName); + const wikipedia_page = new Morebits.wiki.Page(pageName, 'Removing file usages on ' + pageName); const params = Object.assign({}, apiobj.params); params.title = pageName; params.unlinker = unlinker; @@ -671,7 +671,7 @@ Twinkle.batchdelete.callbacks = { text = pageobj.getPageText(); } const old_text = text; - const wikiPage = new Morebits.wikitext.page(text); + const wikiPage = new Morebits.wikitext.Page(text); text = wikiPage.commentOutImage(image, 'Commented out because image was deleted').getText(); Twinkle.batchdelete.unlinkCache[params.title] = text; diff --git a/modules/twinklebatchprotect.js b/modules/twinklebatchprotect.js index 22515e2b4..bb0b3412f 100644 --- a/modules/twinklebatchprotect.js +++ b/modules/twinklebatchprotect.js @@ -21,14 +21,14 @@ Twinkle.batchprotect = function twinklebatchprotect() { Twinkle.batchprotect.unlinkCache = {}; Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { - const Window = new Morebits.simpleWindow(600, 400); + const Window = new Morebits.SimpleWindow(600, 400); Window.setTitle('Batch protection'); Window.setScriptName('Twinkle'); Window.addFooterLink('Protection policy', 'WP:PROT'); Window.addFooterLink('Twinkle help', 'WP:TW/DOC#protect'); Window.addFooterLink('Give feedback', 'WT:TW'); - const form = new Morebits.quickForm(Twinkle.batchprotect.callback.evaluate); + const form = new Morebits.QuickForm(Twinkle.batchprotect.callback.evaluate); form.append({ type: 'checkbox', event: Twinkle.protect.formevents.editmodify, @@ -168,12 +168,12 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { const statusdiv = document.createElement('div'); statusdiv.style.padding = '15px'; // just so it doesn't look broken Window.setContent(statusdiv); - Morebits.status.init(statusdiv); + Morebits.Status.init(statusdiv); Window.display(); - const statelem = new Morebits.status('Grabbing list of pages'); + const statelem = new Morebits.Status('Grabbing list of pages'); - const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => { + const wikipedia_api = new Morebits.wiki.Api('loading...', query, ((apiobj) => { const response = apiobj.getResponse(); const pages = (response.query && response.query.pages) || []; const list = []; @@ -203,7 +203,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { } if (editProt) { metadata.push('fully' + (missing ? ' create' : '') + ' protected' + - (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)')); + (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.Date(editProt.expiry).calendar('utc') + ' (UTC)')); } const title = page.title; @@ -214,14 +214,14 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { type: 'button', label: 'Select All', event: function(e) { - $(Morebits.quickForm.getElements(e.target.form, 'pages')).prop('checked', true); + $(Morebits.QuickForm.getElements(e.target.form, 'pages')).prop('checked', true); } }); form.append({ type: 'button', label: 'Deselect All', event: function(e) { - $(Morebits.quickForm.getElements(e.target.form, 'pages')).prop('checked', false); + $(Morebits.QuickForm.getElements(e.target.form, 'pages')).prop('checked', false); } }); form.append({ @@ -240,7 +240,7 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() { result.moveexpiry.value = '2 days'; result.createexpiry.value = 'infinity'; - Morebits.quickForm.getElements(result, 'pages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(result, 'pages').forEach(Twinkle.generateArrowLinks); }), statelem); @@ -254,29 +254,29 @@ Twinkle.batchprotect.callback.evaluate = function twinklebatchprotectCallbackEva const form = event.target; - const numProtected = $(Morebits.quickForm.getElements(form, 'pages')) + const numProtected = $(Morebits.QuickForm.getElements(form, 'pages')) .filter((index, element) => element.checked && element.nextElementSibling.style.color === 'red') .length; if (numProtected > 0 && !confirm('You are about to act on ' + mw.language.convertNumber(numProtected) + ' fully protected page(s). Are you sure?')) { return; } - const input = Morebits.quickForm.getInputData(form); + const input = Morebits.QuickForm.getInputData(form); if (!input.reason) { alert("You've got to give a reason, you rouge admin!"); return; } - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(form); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(form); if (input.pages.length === 0) { - Morebits.status.error('Error', 'Nothing to protect, aborting'); + Morebits.Status.error('Error', 'Nothing to protect, aborting'); return; } - const batchOperation = new Morebits.batchOperation('Applying protection settings'); + const batchOperation = new Morebits.BatchOperation('Applying protection settings'); batchOperation.setOption('chunkSize', Twinkle.getPref('batchChunks')); batchOperation.setOption('preserveIndividualStatusLines', true); batchOperation.setPageList(input.pages); @@ -286,7 +286,7 @@ Twinkle.batchprotect.callback.evaluate = function twinklebatchprotectCallbackEva titles: pageName, format: 'json' }; - const wikipedia_api = new Morebits.wiki.api('Checking if page ' + pageName + ' exists', query, + const wikipedia_api = new Morebits.wiki.Api('Checking if page ' + pageName + ' exists', query, Twinkle.batchprotect.callbacks.main, null, batchOperation.workerFailure); wikipedia_api.params = Object.assign({ page: pageName, @@ -306,7 +306,7 @@ Twinkle.batchprotect.callbacks = { const exists = !response.query.pages[0].missing; - const page = new Morebits.wiki.page(apiobj.params.page, 'Protecting ' + apiobj.params.page); + const page = new Morebits.wiki.Page(apiobj.params.page, 'Protecting ' + apiobj.params.page); let takenAction = false; if (exists && apiobj.params.editmodify) { page.setEditProtection(apiobj.params.editlevel, apiobj.params.editexpiry); @@ -321,7 +321,7 @@ Twinkle.batchprotect.callbacks = { takenAction = true; } if (!takenAction) { - Morebits.status.warn('Protecting ' + apiobj.params.page, 'page ' + (exists ? 'exists' : 'does not exist') + '; nothing to do, skipping'); + Morebits.Status.warn('Protecting ' + apiobj.params.page, 'page ' + (exists ? 'exists' : 'does not exist') + '; nothing to do, skipping'); apiobj.params.batchOperation.workerFailure(apiobj); return; } diff --git a/modules/twinklebatchundelete.js b/modules/twinklebatchundelete.js index a804ea382..cc75fdc67 100644 --- a/modules/twinklebatchundelete.js +++ b/modules/twinklebatchundelete.js @@ -20,13 +20,13 @@ Twinkle.batchundelete = function twinklebatchundelete() { }; Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { - const Window = new Morebits.simpleWindow(600, 400); + const Window = new Morebits.SimpleWindow(600, 400); Window.setScriptName('Twinkle'); Window.setTitle('Batch undelete'); Window.addFooterLink('Twinkle help', 'WP:TW/DOC#batchundelete'); Window.addFooterLink('Give feedback', 'WT:TW'); - const form = new Morebits.quickForm(Twinkle.batchundelete.callback.evaluate); + const form = new Morebits.QuickForm(Twinkle.batchundelete.callback.evaluate); form.append({ type: 'checkbox', list: [ @@ -48,7 +48,7 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { const statusdiv = document.createElement('div'); statusdiv.style.padding = '15px'; // just so it doesn't look broken Window.setContent(statusdiv); - Morebits.status.init(statusdiv); + Morebits.Status.init(statusdiv); Window.display(); const query = { @@ -60,8 +60,8 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { gpllimit: Twinkle.getPref('batchMax'), format: 'json' }; - const statelem = new Morebits.status('Grabbing list of pages'); - const wikipedia_api = new Morebits.wiki.api('loading...', query, ((apiobj) => { + const statelem = new Morebits.Status('Grabbing list of pages'); + const wikipedia_api = new Morebits.wiki.Api('loading...', query, ((apiobj) => { const response = apiobj.getResponse(); let pages = (response.query && response.query.pages) || []; pages = pages.filter((page) => page.missing); @@ -73,7 +73,7 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { const title = page.title; list.push({ label: title + (editProt ? ' (fully create protected' + - (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.date(editProt.expiry).calendar('utc') + ' (UTC)') + ')' : ''), + (editProt.expiry === 'infinity' ? ' indefinitely' : ', expires ' + new Morebits.Date(editProt.expiry).calendar('utc') + ' (UTC)') + ')' : ''), value: title, checked: true, style: editProt ? 'color:red' : '' @@ -84,14 +84,14 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { type: 'button', label: 'Select All', event: function(e) { - $(Morebits.quickForm.getElements(e.target.form, 'pages')).prop('checked', true); + $(Morebits.QuickForm.getElements(e.target.form, 'pages')).prop('checked', true); } }); apiobj.params.form.append({ type: 'button', label: 'Deselect All', event: function(e) { - $(Morebits.quickForm.getElements(e.target.form, 'pages')).prop('checked', false); + $(Morebits.QuickForm.getElements(e.target.form, 'pages')).prop('checked', false); } }); apiobj.params.form.append({ @@ -105,7 +105,7 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { const result = apiobj.params.form.render(); apiobj.params.Window.setContent(result); - Morebits.quickForm.getElements(result, 'pages').forEach(Twinkle.generateArrowLinks); + Morebits.QuickForm.getElements(result, 'pages').forEach(Twinkle.generateArrowLinks); }), statelem); wikipedia_api.params = { form: form, Window: Window }; @@ -115,26 +115,26 @@ Twinkle.batchundelete.callback = function twinklebatchundeleteCallback() { Twinkle.batchundelete.callback.evaluate = function(event) { Morebits.wiki.actionCompleted.notice = 'Batch undeletion is now complete'; - const numProtected = Morebits.quickForm.getElements(event.target, 'pages').filter((element) => element.checked && element.nextElementSibling.style.color === 'red').length; + const numProtected = Morebits.QuickForm.getElements(event.target, 'pages').filter((element) => element.checked && element.nextElementSibling.style.color === 'red').length; if (numProtected > 0 && !confirm('You are about to undelete ' + numProtected + ' fully create protected page(s). Are you sure?')) { return; } - const input = Morebits.quickForm.getInputData(event.target); + const input = Morebits.QuickForm.getInputData(event.target); if (!input.reason) { alert('You need to give a reason, you cabal crony!'); return; } - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(event.target); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(event.target); if (!input.pages || !input.pages.length) { - Morebits.status.error('Error', 'nothing to undelete, aborting'); + Morebits.Status.error('Error', 'nothing to undelete, aborting'); return; } - const pageUndeleter = new Morebits.batchOperation('Undeleting pages'); + const pageUndeleter = new Morebits.BatchOperation('Undeleting pages'); pageUndeleter.setOption('chunkSize', Twinkle.getPref('batchChunks')); pageUndeleter.setOption('preserveIndividualStatusLines', true); pageUndeleter.setPageList(input.pages); @@ -146,7 +146,7 @@ Twinkle.batchundelete.callback.evaluate = function(event) { pageUndeleter: pageUndeleter }; - const wikipedia_page = new Morebits.wiki.page(pageName, 'Undeleting page ' + pageName); + const wikipedia_page = new Morebits.wiki.Page(pageName, 'Undeleting page ' + pageName); wikipedia_page.setCallbackParameters(params); wikipedia_page.setEditSummary(input.reason); wikipedia_page.setChangeTags(Twinkle.changeTags); @@ -179,7 +179,7 @@ Twinkle.batchundelete.callbacks = { titles: talkpagename, format: 'json' }; - wikipedia_api = new Morebits.wiki.api('Checking talk page for deleted revisions', query, Twinkle.batchundelete.callbacks.undeleteTalk); + wikipedia_api = new Morebits.wiki.Api('Checking talk page for deleted revisions', query, Twinkle.batchundelete.callbacks.undeleteTalk); wikipedia_api.params = params; wikipedia_api.params.talkPage = talkpagename; wikipedia_api.post(); @@ -196,7 +196,7 @@ Twinkle.batchundelete.callbacks = { return; } - const talkpage = new Morebits.wiki.page(apiobj.params.talkPage, 'Undeleting talk page of ' + apiobj.params.page); + const talkpage = new Morebits.wiki.Page(apiobj.params.talkPage, 'Undeleting talk page of ' + apiobj.params.page); talkpage.setEditSummary('Undeleting [[Help:Talk page|talk page]] of "' + apiobj.params.page + '"'); talkpage.setChangeTags(Twinkle.changeTags); talkpage.undeletePage(); diff --git a/modules/twinkleblock.js b/modules/twinkleblock.js index 73819e942..870bfed6f 100644 --- a/modules/twinkleblock.js +++ b/modules/twinkleblock.js @@ -33,7 +33,7 @@ Twinkle.block.callback = function twinkleblockCallback() { Twinkle.block.field_block_options = {}; Twinkle.block.field_template_options = {}; - const Window = new Morebits.simpleWindow(650, 530); + const Window = new Morebits.SimpleWindow(650, 530); // need to be verbose about who we're blocking Window.setTitle('Block or issue block template to ' + relevantUserName); Window.setScriptName('Twinkle'); @@ -46,7 +46,7 @@ Twinkle.block.callback = function twinkleblockCallback() { // Always added, hidden later if actual user not blocked Window.addFooterLink('Unblock this user', 'Special:Unblock/' + relevantUserName, true); - const form = new Morebits.quickForm(Twinkle.block.callback.evaluate); + const form = new Morebits.QuickForm(Twinkle.block.callback.evaluate); const actionfield = form.append({ type: 'field', label: 'Type of action' @@ -234,8 +234,8 @@ Twinkle.block.fetchUserInfo = function twinkleblockFetchUserInfo(fn) { api.get(query).then((data) => { Twinkle.block.processUserInfo(data, fn); }, (msg) => { - Morebits.status.init($('div[name="currentblock"] span').last()[0]); - Morebits.status.warn('Error fetching user info', msg); + Morebits.Status.init($('div[name="currentblock"] span').last()[0]); + Morebits.Status.warn('Error fetching user info', msg); }); }; @@ -342,7 +342,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction Twinkle.block.callback.saveFieldset($('[name=field_template_options]')); if (blockBox) { - field_preset = new Morebits.quickForm.element({ type: 'field', label: 'Preset', name: 'field_preset' }); + field_preset = new Morebits.QuickForm.Element({ type: 'field', label: 'Preset', name: 'field_preset' }); field_preset.append({ type: 'select', name: 'preset', @@ -351,7 +351,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction list: Twinkle.block.callback.filtered_block_groups(blockGroup) }); - field_block_options = new Morebits.quickForm.element({ type: 'field', label: 'Block options', name: 'field_block_options' }); + field_block_options = new Morebits.QuickForm.Element({ type: 'field', label: 'Block options', name: 'field_block_options' }); field_block_options.append({ type: 'div', name: 'currentblock', label: ' ' }); field_block_options.append({ type: 'div', name: 'hasblocklog', label: ' ' }); field_block_options.append({ @@ -531,7 +531,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction event: Twinkle.block.callback.toggle_ds_reason }; if (templateBox) { - field_template_options = new Morebits.quickForm.element({ type: 'field', label: 'Template options', name: 'field_template_options' }); + field_template_options = new Morebits.QuickForm.Element({ type: 'field', label: 'Template options', name: 'field_template_options' }); field_template_options.append({ type: 'select', name: 'template', @@ -722,7 +722,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction if (field_template_options) { oldfield = $form.find('fieldset[name="field_template_options"]')[0]; oldfield.parentNode.replaceChild(field_template_options.render(), oldfield); - e.target.form.root.previewer = new Morebits.wiki.preview($(e.target.form.root).find('#twinkleblock-previewbox').last()[0]); + e.target.form.root.previewer = new Morebits.wiki.Preview($(e.target.form.root).find('#twinkleblock-previewbox').last()[0]); } else { $form.find('fieldset[name="field_template_options"]').hide(); } @@ -733,7 +733,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction // true for a user, single ip block, or the exact range for a range block const sameUser = blockedUserName === relevantUserName; - Morebits.status.init($('div[name="currentblock"] span').last()[0]); + Morebits.Status.init($('div[name="currentblock"] span').last()[0]); let statusStr = relevantUserName + ' is ' + (Twinkle.block.currentBlockInfo.partial === '' ? 'partially blocked' : 'blocked sitewide'); // Range blocked @@ -750,8 +750,8 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction if (Twinkle.block.currentBlockInfo.expiry === 'infinity') { statusStr += ' (indefinite)'; - } else if (new Morebits.date(Twinkle.block.currentBlockInfo.expiry).isValid()) { - statusStr += ' (expires ' + new Morebits.date(Twinkle.block.currentBlockInfo.expiry).calendar('utc') + ')'; + } else if (new Morebits.Date(Twinkle.block.currentBlockInfo.expiry).isValid()) { + statusStr += ' (expires ' + new Morebits.Date(Twinkle.block.currentBlockInfo.expiry).calendar('utc') + ')'; } let infoStr = 'This form will'; @@ -767,7 +767,7 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction infoStr += ' add an additional ' + (partialBox ? 'partial ' : '') + 'block.'; } - Morebits.status.warn(statusStr, infoStr); + Morebits.Status.warn(statusStr, infoStr); // Default to the current block conditions on intial form generation Twinkle.block.callback.update_form(e, Twinkle.block.currentBlockInfo); @@ -781,14 +781,14 @@ Twinkle.block.callback.change_action = function twinkleblockCallbackChangeAction if (!Twinkle.block.currentBlockInfo) { const lastBlockAction = Twinkle.block.blockLog[0]; if (lastBlockAction.action === 'unblock') { - $blockloglink.append(' (unblocked ' + new Morebits.date(lastBlockAction.timestamp).calendar('utc') + ')'); + $blockloglink.append(' (unblocked ' + new Morebits.Date(lastBlockAction.timestamp).calendar('utc') + ')'); } else { // block or reblock - $blockloglink.append(' (' + lastBlockAction.params.duration + ', expired ' + new Morebits.date(lastBlockAction.params.expiry).calendar('utc') + ')'); + $blockloglink.append(' (' + lastBlockAction.params.duration + ', expired ' + new Morebits.Date(lastBlockAction.params.expiry).calendar('utc') + ')'); } } - Morebits.status.init($('div[name="hasblocklog"] span').last()[0]); - Morebits.status.warn(Twinkle.block.currentBlockInfo ? 'Previous blocks' : 'This ' + (Morebits.ip.isRange(relevantUserName) ? 'range' : 'user') + ' has been blocked in the past', $blockloglink[0]); + Morebits.Status.init($('div[name="hasblocklog"] span').last()[0]); + Morebits.Status.warn(Twinkle.block.currentBlockInfo ? 'Previous blocks' : 'This ' + (Morebits.ip.isRange(relevantUserName) ? 'range' : 'user') + ' has been blocked in the past', $blockloglink[0]); } // Make sure all the fields are correct based on initial defaults @@ -1517,16 +1517,16 @@ Twinkle.block.callback.change_preset = function twinkleblockCallbackChangePreset form.template.value = Twinkle.block.blockPresetsInfo[key].templateName || key; Twinkle.block.callback.change_template(e); } else { - Morebits.quickForm.setElementVisibility(form.dstopic.parentNode, key === 'uw-aeblock' || key === 'uw-aepblock'); + Morebits.QuickForm.setElementVisibility(form.dstopic.parentNode, key === 'uw-aeblock' || key === 'uw-aepblock'); } }; Twinkle.block.callback.change_expiry = function twinkleblockCallbackChangeExpiry(e) { const expiry = e.target.form.expiry; if (e.target.value === 'custom') { - Morebits.quickForm.setElementVisibility(expiry.parentNode, true); + Morebits.QuickForm.setElementVisibility(expiry.parentNode, true); } else { - Morebits.quickForm.setElementVisibility(expiry.parentNode, false); + Morebits.QuickForm.setElementVisibility(expiry.parentNode, false); expiry.value = e.target.value; } }; @@ -1585,9 +1585,9 @@ Twinkle.block.callback.update_form = function twinkleblockCallbackUpdateForm(e, form.expiry.value = expiry; if (form.expiry_preset.value === 'custom') { - Morebits.quickForm.setElementVisibility(form.expiry.parentNode, true); + Morebits.QuickForm.setElementVisibility(form.expiry.parentNode, true); } else { - Morebits.quickForm.setElementVisibility(form.expiry.parentNode, false); + Morebits.QuickForm.setElementVisibility(form.expiry.parentNode, false); } } @@ -1674,25 +1674,25 @@ Twinkle.block.callback.change_template = function twinkleblockcallbackChangeTemp if (Twinkle.block.prev_template_expiry) { form.expiry.value = Twinkle.block.prev_template_expiry; } - Morebits.quickForm.setElementVisibility(form.notalk.parentNode, !settings.nonstandard); + Morebits.QuickForm.setElementVisibility(form.notalk.parentNode, !settings.nonstandard); // Partial - Morebits.quickForm.setElementVisibility(form.noemail_template.parentNode, partialBox); - Morebits.quickForm.setElementVisibility(form.nocreate_template.parentNode, partialBox); + Morebits.QuickForm.setElementVisibility(form.noemail_template.parentNode, partialBox); + Morebits.QuickForm.setElementVisibility(form.nocreate_template.parentNode, partialBox); } else if (templateBox) { // Only present if block && template forms both visible - Morebits.quickForm.setElementVisibility( + Morebits.QuickForm.setElementVisibility( form.blank_duration.parentNode, !settings.indefinite && !settings.nonstandard ); } - Morebits.quickForm.setElementVisibility(form.dstopic.parentNode, value === 'uw-aeblock' || value === 'uw-aepblock'); + Morebits.QuickForm.setElementVisibility(form.dstopic.parentNode, value === 'uw-aeblock' || value === 'uw-aepblock'); // Only particularly relevant if template form is present - Morebits.quickForm.setElementVisibility(form.article.parentNode, settings && !!settings.pageParam); - Morebits.quickForm.setElementVisibility(form.block_reason.parentNode, settings && !!settings.reasonParam); + Morebits.QuickForm.setElementVisibility(form.article.parentNode, settings && !!settings.pageParam); + Morebits.QuickForm.setElementVisibility(form.block_reason.parentNode, settings && !!settings.reasonParam); // Partial block - Morebits.quickForm.setElementVisibility(form.area.parentNode, partialBox && !blockBox); + Morebits.QuickForm.setElementVisibility(form.area.parentNode, partialBox && !blockBox); form.root.previewer.closePreview(); }; @@ -1779,9 +1779,9 @@ Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) { return alert('Please provide a reason for the block!'); } - Morebits.simpleWindow.setButtonsEnabled(false); - Morebits.status.init(e.target); - const statusElement = new Morebits.status('Executing block'); + Morebits.SimpleWindow.setButtonsEnabled(false); + Morebits.Status.init(e.target); + const statusElement = new Morebits.Status('Executing block'); blockoptions.action = 'block'; blockoptions.user = relevantUserName; @@ -1857,17 +1857,17 @@ Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) { if (logevents.params.duration === 'infinity') { logExpiry = 'indefinitely'; } else { - const expiryDate = new Morebits.date(logevents.params.expiry); + const expiryDate = new Morebits.Date(logevents.params.expiry); logExpiry += (expiryDate.isBefore(new Date()) ? ', expired ' : ' until ') + expiryDate.calendar(); } } else { // no duration, action=unblock, just show timestamp - logExpiry = ' ' + new Morebits.date(logevents.timestamp).calendar(); + logExpiry = ' ' + new Morebits.Date(logevents.timestamp).calendar(); } message += Morebits.string.toUpperCaseFirstChar(logevents.action) + 'ed by ' + logevents.user + logExpiry + ' for "' + logevents.comment + '". Do you want to override with your settings?'; if (!confirm(message)) { - Morebits.status.info('Executing block', 'Canceled by user'); + Morebits.Status.info('Executing block', 'Canceled by user'); return; } blockoptions.reblock = 1; // Writing over a block will fail otherwise @@ -1876,7 +1876,7 @@ Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) { // execute block blockoptions.tags = Twinkle.changeTags; blockoptions.token = mw.user.tokens.get('csrfToken'); - const mbApi = new Morebits.wiki.api('Executing block', blockoptions, (() => { + const mbApi = new Morebits.wiki.Api('Executing block', blockoptions, (() => { statusElement.info('Completed'); if (toWarn) { Twinkle.block.callback.issue_template(templateoptions); @@ -1885,9 +1885,9 @@ Twinkle.block.callback.evaluate = function twinkleblockCallbackEvaluate(e) { mbApi.post(); }); } else if (toWarn) { - Morebits.simpleWindow.setButtonsEnabled(false); + Morebits.SimpleWindow.setButtonsEnabled(false); - Morebits.status.init(e.target); + Morebits.Status.init(e.target); Twinkle.block.callback.issue_template(templateoptions); } else { return alert('Please give Twinkle something to do!'); @@ -1910,7 +1910,7 @@ Twinkle.block.callback.issue_template = function twinkleblockCallbackIssueTempla Morebits.wiki.actionCompleted.redirect = userTalkPage; Morebits.wiki.actionCompleted.notice = 'Actions complete, loading user talk page in a few seconds'; - const wikipedia_page = new Morebits.wiki.page(userTalkPage, 'User talk page modification'); + const wikipedia_page = new Morebits.wiki.Page(userTalkPage, 'User talk page modification'); wikipedia_page.setCallbackParameters(params); wikipedia_page.load(Twinkle.block.callback.main); }; @@ -1929,7 +1929,7 @@ Twinkle.block.callback.getBlockNoticeWikitext = function(params) { if (!/te?mp|^\s*$|min/.exec(params.expiry)) { if (params.indefinite) { text += '|indef=yes'; - } else if (!params.blank_duration && !new Morebits.date(params.expiry).isValid()) { + } else if (!params.blank_duration && !new Morebits.Date(params.expiry).isValid()) { // Block template wants a duration, not date text += '|time=' + params.expiry; } @@ -1991,14 +1991,14 @@ Twinkle.block.callback.getBlockNoticeWikitext = function(params) { Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) { let params = pageobj.getCallbackParameters(), - date = new Morebits.date(pageobj.getLoadTime()), + date = new Morebits.Date(pageobj.getLoadTime()), messageData = params.messageData, text; params.indefinite = Morebits.string.isInfinity(params.expiry); if (Twinkle.getPref('blankTalkpageOnIndefBlock') && params.template !== 'uw-lblock' && params.indefinite) { - Morebits.status.info('Info', 'Blanking talk page per preferences and creating a new talk page section for this month'); + Morebits.Status.info('Info', 'Blanking talk page per preferences and creating a new talk page section for this month'); text = date.monthHeader() + '\n'; } else { text = pageobj.getPageText(); @@ -2017,7 +2017,7 @@ Twinkle.block.callback.main = function twinkleblockcallbackMain(pageobj) { } if (!dateHeaderRegexResult || dateHeaderRegexResult.index !== lastHeaderIndex) { - Morebits.status.info('Info', 'Will create a new talk page section for this month, as none was found'); + Morebits.Status.info('Info', 'Will create a new talk page section for this month, as none was found'); text += date.monthHeader() + '\n'; } } diff --git a/modules/twinkleconfig.js b/modules/twinkleconfig.js index 323f5cb67..abc6d853f 100644 --- a/modules/twinkleconfig.js +++ b/modules/twinkleconfig.js @@ -1376,7 +1376,7 @@ Twinkle.config.listDialog.display = function twinkleconfigListDialogDisplay(e) { const curvalue = $prefbutton.data('value'); const curpref = $prefbutton.data('pref'); - const dialog = new Morebits.simpleWindow(720, 400); + const dialog = new Morebits.SimpleWindow(720, 400); dialog.setTitle(curpref.label); dialog.setScriptName('Twinkle preferences'); @@ -1422,7 +1422,7 @@ Twinkle.config.listDialog.display = function twinkleconfigListDialogDisplay(e) { ), $('