Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae committed Apr 30, 2024
1 parent 1762907 commit 7156519
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Links.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
*/

class Links {
constructor( mw ) {
this.mw = mw;
}

async execute() {
this.addPendingChangesToLeftMenu();
this.pageName = mw.config.get( 'wgPageName' );
this.pageName = this.mw.config.get( 'wgPageName' );
await this.generateLinksForUserSpace();
await this.generateLinksForAllNameSpaces();
this.insertLinksInLeftMenu();
Expand All @@ -52,9 +56,11 @@ class Links {
}

insertLinksInLeftMenu() {
// this.mw.util.addPortlet( 'p-links', 'More tools', 'p-tb' );

const menuTitle = 'More tools';
let html = '';
const skin = mw.config.get( 'skin' );
const skin = this.mw.config.get( 'skin' );
switch ( skin ) {
case 'minerva':
// TODO: insert into the "More" menu, rather than the hamburger
Expand Down Expand Up @@ -205,9 +211,9 @@ class Links {
}

addPendingChangesToLeftMenu() {
mw.util.addPortletLink(
this.mw.util.addPortletLink(
'p-navigation',
mw.util.getUrl( 'Special:PendingChanges' ),
this.mw.util.getUrl( 'Special:PendingChanges' ),
'Pending changes' // can't put comma here, silent error
);
}
Expand All @@ -224,7 +230,7 @@ class Links {
* @param {Array} titles
*/
async pagesExist( titles ) {
const api = new mw.Api();
const api = new this.mw.Api();
let response = await api.get( {
action: 'query',
format: 'json',
Expand Down Expand Up @@ -272,7 +278,7 @@ class Links {
}

$( async function () {
await ( new Links() ).execute();
await ( new Links( mw ) ).execute();
} );

// </nowiki>

0 comments on commit 7156519

Please sign in to comment.