// <nowiki>
importScript("User:JJPMaster/CurateThisPage/review.js");
var parsedTitle = mw.config.get("wgPageName").replace(/_/g, " ");
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) {
var RFDporty = mw.util.addPortletLink('p-cactions', '#', 'RfD', 'pt-rfd', 'File a deletion request for this page');
var RFDad = " (using [[:b:en:User:JJPMaster/rfd.js|RfD]])";
$("#bodyContent").append(`
<div id="RFDdialog">
Please enter the reason for deletion:
<textarea name="RFDreason" id="RFDreason">Reason for deletion</textarea>
<input type="checkbox" id="notifyAuthor2" name="notifyAuthor2" checked /><label for="notifyAuthor2">Notify page author</label><br />
<button type="button" id="reqDel">Request deletion</button></div>
`);
$("#RFDdialog").hide();
$(RFDporty).click(() => $("#RFDdialog").dialog({ title: "Request deletion" }));
$("#reqDel").click(function() {
var myText = document.getElementById("RFDreason");
var reason = myText.value;
doTheReviewA();
doTheReviewB();
var params = {
action: 'edit',
prependtext: `{{Rfd}}\n`,
title: parsedTitle,
summary: "Making [[WB:Requests for deletion|deletion request]]" + RFDad,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
(async function() {
if ($("#notifyAuthor2").prop("checked")) {
params = {
action: 'edit',
appendtext: `\n{{subst:Rfd warning|${parsedTitle}|~~~~}}`,
title: `User_talk:${await getAuthor()}`,
summary: "Notifying author about page tagging" + RFDad,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
}
})();
params = {
action: 'edit',
appendtext: `\n== [[${parsedTitle}]] ==\n${reason} ~~~~`,
title: `User:JJPMaster/CurateThisPage/sandbox`,
summary: `Adding deletion request for [[${parsedTitle}]]` + RFDad,
format: 'json'
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
mw.notify("RfD:\nThe page has been nominated for deletion. Reloading...")
setTimeout(() => window.location.reload(), 2000);
});
}
});
// </nowiki>