User:Writ Keeper/Scripts/afcDialog.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Writ Keeper/Scripts/afcDialog. |
$(document).ready(function(){
afcDialogButtonText = "Make a selection";
if($("#afcSubmissionButton").length > 0)
{
$("#afcSubmissionButton").first().append('<div id="afcDialog" style="display:none;"><h2>Wait! Have you included <a href="/wiki/Wikipedia:CITE">citations</a> to independent, <a href="/wiki/Wikipedia:RS">reliable</a> sources in your article?</h2><input type="radio" id="afcOptionA" name="afcOptions"><b>A.</b> No, I forgot. I\'ll submit my page later.<br><input type="radio" id="afcOptionB" name="afcOptions"><b>B.</b> No. What are citations? How do I add them?<br><input type="radio" id="afcOptionC" name="afcOptions"><b>C.</b> No. There aren\'t any; I\'m writing about a subject that is new and/or not well known.<br><input type="radio" id="afcOptionD" name="afcOptions"><b>D.</b> No. I looked, but I am a new editor and need some help to find them.<br><input type="radio" id="afcOptionE" name="afcOptions"><b>E.</b> No, because this is a disambiguation page, template, or redirect, not an article.<br><input type="radio" id="afcOptionF" name="afcOptions"><b>F.</b> Yes, I have included citations to reliable sources in my article.<br></div>');
$("#afcOptionA").click(function(){$('div[aria-labelledby="ui-dialog-title-afcDialog"] .ui-button-text').first().text("Never mind");afcDialogButtonText ="Never mind";});
$("#afcOptionB").click(function(){$('div[aria-labelledby="ui-dialog-title-afcDialog"] .ui-button-text').first().text("Get help");afcDialogButtonText ="Get help";});
$("#afcOptionC").click(function(){$('div[aria-labelledby="ui-dialog-title-afcDialog"] .ui-button-text').first().text("Get help");afcDialogButtonText ="Get help";});
$("#afcOptionD").click(function(){$('div[aria-labelledby="ui-dialog-title-afcDialog"] .ui-button-text').first().text("Get help");afcDialogButtonText ="Get help";});
$("#afcOptionE").click(function(){$('div[aria-labelledby="ui-dialog-title-afcDialog"] .ui-button-text').first().text("Submit");afcDialogButtonText ="Submit";});
$("#afcOptionF").click(function(){$('div[aria-labelledby="ui-dialog-title-afcDialog"] .ui-button-text').first().text("Submit");afcDialogButtonText ="Submit";});
$("#afcSubmissionButton, #afcSubmissionButton > a").click(function(){
$( "#afcDialog" ).dialog(
{ buttons: [
{ text: afcDialogButtonText , click: function() {
var checkedInput = $('input[name=afcOptions]:checked');
var apiPath = mw.config.get('wgScriptPath') + "/api.php";
if(checkedInput.length > 0)
{
switch(checkedInput.attr("id"))
{
case "afcOptionB":
var catData={action:"query", prop:"categories", clcategories: "Category:Articles not submitted at AfC", pageids: mw.config.get( 'wgArticleId' ), format: "json"};
$.post(apiPath, catData, function(response)
{
if(typeof response.query.pages[wgArticleId].categories == "undefined")
{
var data = {action: "edit", title: mw.config.get( 'wgPageName' ), summary: "Article not submitted, automatically adding category", minor: "true", appendtext: "\n\n[[:Category:Articles not submitted at AfC]]", token: mw.user.tokens.get( 'csrfToken' )};
$.post(apiPath, data, function(){window.open(mw.util.getUrl("WP:Referencing for beginners"), "_self");});
}
else
{
window.open(mw.util.getUrl("WP:Referencing for beginners"), "_self");
}
});
break;
case "afcOptionC":
var catData={action:"query", prop:"categories", clcategories: "Category:Articles not submitted at AfC", pageids: mw.config.get( 'wgArticleId' ), format: "json"};
$.post(apiPath, catData, function(response)
{
if(typeof response.query.pages[wgArticleId].categories == "undefined")
{
var data = {action: "edit", title: mw.config.get( 'wgPageName' ), summary: "\nArticle not submitted, automatically adding category", minor: "true", appendtext: "\n\n[[:Category:Articles not submitted at AfC]]", token: mw.user.tokens.get( 'csrfToken' )};
$.post(apiPath, data, function(){window.open(mw.util.getUrl("WP:42"), "_self");});
}
else
{
window.open(mw.util.getUrl("WP:42"), "_self");
}
});
break;
case "afcOptionD":
var catData={action:"query", prop:"categories", clcategories: "Category:Articles not submitted at AfC", pageids: mw.config.get( 'wgArticleId' ), format: "json"};
$.post(apiPath, catData, function(response)
{
if(typeof response.query.pages[wgArticleId].categories == "undefined")
{
var data = {action: "edit", title: mw.config.get( 'wgPageName' ), summary: "\nArticle not submitted, automatically adding category", minor: "true", appendtext: "\n\n[[:Category:Articles not submitted at AfC]]", token: mw.user.tokens.get( 'csrfToken' )};
$.post(apiPath, data, function(){window.open(mw.util.getUrl("WP:Teahouse/Questions"), "_self");});
}
else
{
window.open(mw.util.getUrl("WP:Teahouse/Questions"), "_self");
}
});
break;
case "afcOptionE":
case "afcOptionF":
window.open(mw.config.get("wgScript") + "?title="+ mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ) +"&action=edit§ion=new&preload=Template:AFC_submission/Subst&editintro=Template:AFC_submission/Subst/Editintro", "_self");
break;
case "afcOptionA":
default:
alert("Your article has not been submitted.");
$( this ).dialog( "close" );
break;
}
}
return false;
} },
{ text: "Cancel", click: function() {
$( this ).dialog( "close" );
return false;
} }
],
minWidth:500
}
);
return false;
});
}
});