// <nowiki>
importScript("User:JJPMaster/CurateThisPage/review.js");
importScript("User:JJPMaster/CurateThisPage/gsr.js");
var parsedTitle = mw.config.get("wgPageName").replace("_", " ");
async function getAuthor() {
var par = {
action: 'query',
prop: 'revisions',
titles: parsedTitle,
rvprop: 'user',
rvdir: 'newer',
rvlimit: 1,
format: 'json'
},
api = new mw.Api();
const data = await api.get( par );
return Object.values(data.query.pages)[0].revisions[0].user;
}
$(() => {
if (mw.config.get("wgArticleId") !== 0) {
getAuthor();
var porty2;
var porty = mw.util.addPortletLink('p-cactions', '#', 'Curate this page', 'pt-ctp', 'Use the CurateThisPage tool');
var CTPad = " (using [[:b:en:User:JJPMaster/CurateThisPage.js|CurateThisPage]])";
$("#bodyContent").append(`
<div id="CTPdialog">
How would you like to tag this page?
<select name="CTPtagReason" id="CTPtagReason">
<option>Select the template</option>
<option id="qr-em">Query (test)</option>
<option id="qr-dup">Query (duplicate)</option>
<option id="qr-twwp">Query (transwiki)</option>
<option id="attention">Attention</option>
<option id="cleanup">Cleanup</option>
<option id="unreferenced">Unreferenced</option>
<option id="formatting">Formatting</option>
<option id="copyedit">Copy edit</option>
<option id="delete">Mark for speedy deletion</option>
</select>
<span style="display: block;"><input type="checkbox" id="reviewMark" class="reviewMark" name="reviewMark" /><label class="reviewMark" for="reviewMark">Mark as reviewed</label></span>
<input type="checkbox" id="notifyAuthor" name="notifyAuthor" checked /><label for="notifyAuthor">Notify page author</label><br />
<button type="button" id="addTag">Add tag</button></div>
`);
$("#CTPdialog").hide();
if (!(mw.config.get("wgCanonicalNamespace") == 0 || mw.config.get("wgCanonicalNamespace") == 6 || mw.config.get("wgCanonicalNamespace") == 10 || mw.config.get("wgCanonicalNamespace") == 102 || mw.config.get("wgCanonicalNamespace") == 110 || mw.config.get("wgCanonicalNamespace") == 828)) {
porty2 = null;
$(".reviewMark").hide();
}
else porty2 = mw.util.addPortletLink('p-cactions', '#', 'Review', 'pt-rev', 'Mark this page as reviewed');
$(porty).click(() => $("#CTPdialog").dialog({ title: "CurateThisPage"} ));
$(porty2).click(() => {
doTheReviewA();
doTheReviewB();
});
$("#addTag").click(function() {
var mySelect = document.getElementById("CTPtagReason");
var critValue = mySelect.value;
var criterion;
var tag = mySelect.options[CTPtagReason.selectedIndex].id;
var finalTag;
var isDel = false;
var delCrit = "";
if ($("#reviewMark").prop("checked")) {
doTheReviewA();
doTheReviewB();
}
if(critValue !== "Mark for speedy deletion") {
criterion = `Adding {{${tag}}} tag`;
finalTag = tag;
}
else {
var innerCrit = prompt("Why?");
if(innerCrit) {
criterion = `Marking for speedy deletion: ${innerCrit}`;
finalTag = `delete|${innerCrit}`;
delCrit = innerCrit;
isDel = true;
}
else {
criterion = `Marking for speedy deletion`;
finalTag = tag;
isDel = true;
}
var metaReq = confirm("Would you like to request that a global sysop delete this page?");
if (metaReq) makeMetaReq(CTPad, parsedTitle, innerCrit);
}
var params = {
action: 'edit',
prependtext: `{{${finalTag}}}\n`,
title: parsedTitle,
summary: criterion + CTPad,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
(async function() {
if ($("#notifyAuthor").prop("checked")) {
if (!isDel) {
params = {
action: 'edit',
appendtext: `\n{{subst:User:JJPMaster/CurateThisPage/authorMsg|title=${parsedTitle}|tag=${finalTag}}}`,
title: `User_talk:${await getAuthor()}`,
summary: "Notifying author about page tagging" + CTPad,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
}
else {
params = {
action: 'edit',
appendtext: `\n{{subst:User:JJPMaster/CurateThisPage/authorMsg|title=${parsedTitle}|tag=${tag}|deletereason=${delCrit}}}`,
title: `User_talk:${await getAuthor()}`,
summary: "Notifying author about page tagging" + CTPad,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
}
}
})();
mw.notify("CurateThisPage:\nThe tag has been added. Reloading...")
setTimeout(() => window.location.reload(), 2000);
});
}
});
// </nowiki>