Content deleted Content added
Writ Keeper (talk | contribs) test |
Writ Keeper (talk | contribs) apparently this is bad now |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 1:
function closePeerReview()
{
mw.loader.using("mediawiki.api").done( function ()
{
$("#ca-closepeer>a").text("Closing...");
Line 7:
var talkPage = $("a:contains('Article talk')").attr("href");
var talkPageName = "";
if
{
talkPage = talkPage.match(/\/wiki\/(\w+:.+)/);
if
{
talkPageName = talkPage[1];
Line 16:
}
var api = new mw.Api();
api.edit(mw.config.get("wgPageName"), function
{
var regexResult = revision.content.match(/\{\{ *
▲ var regexResult = revision.content.match(/\{\{ *Peer review page *\| *topic *= *\w+ *\}\}/);
▲ if (regexResult != null)
{
return {
{▼
summary: "Closing peer review due to inactivity (via [[User:Writ Keeper/Scripts/peerReviewCloser
▲ summary: "Closing peer review due to inactivity (via [[User:Writ Keeper/Scripts/peerReviewCloser.js|peerReviewCloser.js]])"
};
}
else
{
mw.notify( 'Error updating the Peer Review page; article talk page might also require cleanup.', { title: 'Peer review closing error' } );
{▼
});▼
$("#ca-closepeer>a").text("error!");
return null;
}
}).done(function
{
api.edit(talkPageName, function
{
var regexResult = revision.content.match(/\{\{ *[pP]eer review *(\| *archive *= *\d+) *\}\}/);
if
{
return {
text: revision.content.replace(regexResult[0], "{{subst:Close peer review" + regexResult[1] + "}}"),
summary: "Closing peer review due to inactivity (via [[User:Writ Keeper/Scripts/peerReviewCloser
▲ text: revision.content.replace(regexResult[0], "{{Old peer review" + regexResult[1] + "}}"),
▲ summary: "Closing peer review due to inactivity (via [[User:Writ Keeper/Scripts/peerReviewCloser.js|peerReviewCloser.js]])"
};
}
{
if(typeof window.sessionStorage != "undefined")
mw.notify('Peer Review page updated. Error updating the article talk page; it may have already been closed there.',▼
{
window.sessionStorage.setItem("peerReviewCloserError","talkPageError");
___location.reload();
return null;▼
}
$("#ca-closepeer>a").text("error!");▼
▲ return null;
{
mw.notify( 'Peer review page updated, but error updating the article talk page; it may require manual intervention.', { title: 'Peer review closing error' } );
▲ $("#ca-closepeer>a").text("error!");
return null;▼
}
▲ return null;
}
})
.done(function {
___location.reload();
Line 79 ⟶ 69:
}
$(document).ready(function()
{
if(typeof window.sessionStorage != "undefined")
if (mw.config.get("wgCategories").indexOf("Current peer reviews") >= 0)▼
{
if(window.sessionStorage.getItem("peerReviewCloserError") == "talkPageError")
▲
window.sessionStorage.removeItem("peerReviewCloserError");
}
{
mw.loader.using("mediawiki.util").done( function ()
{
mw.util.addPortletLink('p-cactions', '#', "Close peer review", "ca-closepeer", "close this peer review");
$("#ca-closepeer").click(
{
event.preventDefault();
mw.loader.load( [ 'mediawiki.api.edit' ] ); //start loading, while the user is in the prompt
return closePeerReview();
});
|