Content deleted Content added
indicate review status with icons, not text |
fix linter errors |
||
(16 intermediate revisions by the same user not shown) | |||
Line 2:
/*
- Displays whether or not a mainspace page is marked as reviewed. This info is placed on the right of the page title using a small icon.
- Without a script like this, you need to be a new page reviewer or admin and look at the Page Curation toolbar. Or you need to use Special:Log -> Page Curation Log. And there is also some complex logic. For example, the absence of a log entry means the page is marked as reviewed.
*/
// TODO: display whether the page is indexed or not. can do this by using JS to look for "noindex", or can do this by checking the first revision date.
$(async function() {▼
// TODO: display in all namespaces
async function isReviewed(pageID) {▼
// TODO: do I need to use different code to check if marked as patrolled? I think that uses recentchanges table... maybe?
let api = new mw.Api();▼
let response = await api.get( {▼
class ReviewStatus {
action: 'pagetriagelist',▼
async execute() {
format: 'json',▼
page_id: pageID,▼
}▼
let htmlToInsert = '';
// modules/ext.pageTriage.views.toolbar/images/icons/
// 0▼
} else {
}▼
if ( this.pageHasSections() ) {
$( '#firstHeading .mw-editsection' ).before( htmlToInsert );
} else {
$( '#firstHeading' ).append( htmlToInsert );
}
}
/**
function shouldRunOnThisPage(title) {▼
* @param {number} pageID The page ID number. A positive number with no commas.
*/
▲ format: 'json',
formatversion: '2',
prop: 'isreviewed',
return response.query.pages[ 0 ].isreviewed;
}▼
// don't run when not viewing articles
if ( action !== 'view' ) {
return false;
}
// don't run when viewing diffs
if ( isDiff ) {
return false;
}
if ( isDeletedPage ) {
return false;
}
// Only run in mainspace
if ( !
return false;
}
Line 55 ⟶ 78:
}
pageHasSections() {
return $( '#firstHeading .mw-editsection' ).length;
▲ if ( ! shouldRunOnThisPage(title) ) {
}
}
▲$( async function () {
▲ let pageID = mw.config.get('wgArticleId');
await mw.loader.using( [ 'mediawiki.api' ], async function () {
▲ let boolIsReviewed = await isReviewed(pageID);
await ( new ReviewStatus() ).execute();
▲ if ( boolIsReviewed ) {
} );▼
▲ $(`#firstHeading`).append(`<img src="https://en.wikipedia.org/w/extensions/PageTriage/modules/ext.pageTriage.views.list/images/icon_reviewed.png" title="Reviewed" />`);
▲ $(`#firstHeading`).append(`<img src="https://en.wikipedia.org/w/extensions/PageTriage/modules/ext.pageTriage.views.list/images/icon_not_reviewed.png" title="Not reviewed" />`);
▲ }
▲});
// </nowiki>
|