User:Deryck Chan/closerfd.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. |
This user script seems to have a documentation page at User:Deryck Chan/closerfd. |
// <nowiki>
// There are instructions on [[User:Deryck Chan/closerfd]]!
// closerfd.js - written by [[User:Deryck Chan]], modelled upon
// [[User:King of Hearts/closerfd.js]] by [[User:King of Hearts]]
// [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]] by [[User:Johnleemk]]
// and [[User:Lifebaka/closedrv.js]] by [[User:Lifebaka]]
function autorfd_result()
{
var f = document.editform, t = f.wpTextbox1;
var wikitext_split = t.value.split("====");
t.value = "====" + wikitext_split[1] + "====" + "\n{{sub" + "st:rfdt| }} ~~" + "~~" + wikitext_split[2] + "\n{{sub" + "st:rfdb}}";
f.wpSummary.value += " closing as ";
}
function autorfd_relist()
{
var f = document.editform, t = f.wpTextbox1;
var wikitext_split = t.value.split("====");
t.value = "====" + wikitext_split[1] + "====\n{{sub" + "st:Rfdr|" + wikitext_split[1] + "}}\n";
f.wpSummary.value += " relisting";
}
function autorfd_scrub()
{
var f = document.editform, t = f.wpTextbox1;
var wikitext_split = t.value.split("<!-- End of RFD message. Don't edit anything above here, but feel free to edit below here. -->|content=\n");
if (wikitext_split.length == 2) wikitext_edited = wikitext_split[1];
t.value = wikitext_edited.replace("\n<!-- Don't add anything after this line. -->\n}}", "");
} //This approach scrubs everything above the RfD template but preserves content (e.g. draft disambigs) below the RfD template
function autorfd_result_test()
{
var f = document.editform, t = f.wpTextbox1;
var wikitext_split = t.value.split("====");
t.value = "====" + wikitext_split[1] + "====" + "\n{{sub" + "st:rfd top/sandbox| }} ~~" + "~~" + wikitext_split[2] + "\n{{sub" + "st:rfd bottom/sandbox}}";
f.wpSummary.value += " closing as with new template, comments welcome on [[WT:RFD]]";
}
// Create portlet links
if ((document.title.indexOf("Editing Wikipedia:Redirects for discussion/Log/") != -1) && (document.title.indexOf("(section)") != -1))
{
var portletLinkResult = mw.util.addPortletLink( 'p-cactions', '#',
'Close RfD', 'ca-rfd-result', 'Click here to insert RfD closure templates'
);
// Bind click handler
$( portletLinkResult ).click( function ( e ) {
e.preventDefault();
autorfd_result();
});
var portletLinkTest = mw.util.addPortletLink( 'p-cactions', '#',
'Relist RfD', 'ca-relist', 'Copy discussion content first, then click here to insert RfD relisting template'
);
// Bind click handler
$( portletLinkTest ).click( function ( e ) {
e.preventDefault();
autorfd_relist();
});
}
if ((document.title.indexOf("Editing ") != -1) && (document.editform.wpSummary.value.split("Wikipedia:Redirects for discussion").length > 1))
{
var portletLinkScrub = mw.util.addPortletLink( 'p-cactions', '#',
'Scrub RfD', 'ca-rfd-result', 'Click here to remove RfD nomination templates and restore a redirect'
);
// Bind click handler
$( portletLinkScrub ).click( function ( e ) {
e.preventDefault();
autorfd_scrub();
});
}
// </nowiki>