Jump to content

User:Rutilant/DisCloser/First.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$(function() {
	headerLevel = 2;
	$( 'h' + headerLevel + ' span.mw-headline' ).each( function( i, val ) {
						var sectionName = $( this ).text();
						var editSectionUrl = $( this ).parent().find( '.mw-editsection a:first' ).attr( 'href' );
						var sectionReg = /&section=(.*)/;
						var sectionRaw = sectionReg.exec( editSectionUrl );
						if ( sectionRaw != null && sectionRaw[ 1 ].indexOf( 'T' ) < 0 ) {
							var sectionNumber = parseInt( sectionRaw[ 1 ] );
							if ( $( this ).parent().prop( 'tagName' ) === 'H' + headerLevel ) {
	$( this ).parent( 'h' + headerLevel ).append( ' <div style=" font-size: 0.6em;font-family:calibri; font-weight: bold;float: right;border-left:3px solid black"><a href="'+mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + wgPageName+'&action=edit&closure=yes&section='+sectionNumber+'">Close</a></div>' );
							}}})});
							

    statusRegExp = /&action=edit&closure=yes&section=(.*)/;
  var sectionNumber = statusRegExp.exec(location.href)[1];
 if (sectionNumber != null && sectionNumber != ""){
 
	$('#wpPreview').click();
	text1=document.editform.wpTextbox1.value;
	text=document.editform.wpSummary.value;
	text = text.replace("/* ",""); 
		text = text.replace(" */ ",""); 
 if (text != null && text != ""){
		text2="=="+text+"==";
		texts="== "+text+" ==";
text1=text1.replace(text2,"");
text1=text1.replace(texts,"");
	    var result = prompt("Provide result\nDo NOT sign!");
	    if (result != null && result != ""){

	    text1="=="+text+"==\n{{atop|result="+result+"~~"+"~~}}" + text1+"{{abot}}";
  document.editform.wpTextbox1.value = text1;
  document.editform.wpSummary.value = 'Discussion closed using [[User:RainFall/DisCloser|DisCloser]].';
$('#wpDiff').click();
}else{
	alert("Error! You left the reason empty!");	
}
}
}else{
	alert("Error! Please refresh and try again.\n Invalid section number");

 }