User:Deryck Chan/test.js

// // See User:Deryck Chan/closerfd.js /* function autorfd_result {	var f = document.editform, t = f.wpTextbox1; var wikitext_split = t.value.split("===="); t.value = "====" + wikitext_split[1] + "====" + "\n   " + "" + wikitext_split[2] + "\n"; 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\n"; f.wpSummary.value += " relisting"; }

function autorfd_scrub {	var f = document.editform, t = f.wpTextbox1; var wikitext_split = t.value.split("|content=\n"); if (wikitext_split.length == 2) wikitext_edited = wikitext_split[1]; t.value = wikitext_edited.replace("\n\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   " + "" + wikitext_split[2] + "\n"; 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;	}); } //