User:Djsasso/common.js

importScript('User:Ohconfucius/script/formatgeneral.js'); // [[User:Ohconfucius/script/formatgeneral.js]]
importScript('User:Ohconfucius/script/MOSNUM dates.js'); // [[User:Ohconfucius/script/MOSNUM dates.js]]
importScript('User:Ohconfucius/script/Common Terms.js'); // [[User:Ohconfucius/script/Common Terms.js]]
importScript('User:Ohconfucius/script/Sources.js'); // [[User:Ohconfucius/script/Sources.js]]
importScript('User:Ohconfucius/script/EngvarB.js'); // [[User:Ohconfucius/script/EngvarB.js]]
importScript('User:Ohconfucius/script/flagcruft.js'); // [[User:Ohconfucius/script/flagcruft.js]]
importScript('User:Evad37/rater.js'); // [[User:Evad37/rater]]
importScript('User:Alex 21/script-functions.js');
importScript('User:Alex 21/script-categoriessort.js');

// Citation-bot
var $spinnerspan;
var cbButton;
function addCFastToToolbox() {
	if ( mw.config.get( 'wgCanonicalNamespace' ) !== 'Special' ) {
		var pTb = document.getElementById("p-tb");
		if ( !pTb ) {
			return;
		}
		var escPageName = encodeURIComponent( mw.config.get( 'wgPageName' ));
		mw.util.addPortletLink("p-tb", "//citations.toolforge.org/process_page.php?edit=toolbar&wiki_base=en&page="+escPageName, 'Expand citations [fast]', 't-citationbot', "Expand citations and fix formatting errors");
	}
}

function addCSlowToToolbox() {
	if ( mw.config.get( 'wgCanonicalNamespace' ) !== 'Special' ) {
		var pTb = document.getElementById("p-tb");
		if ( !pTb ) {
			return;
		}
		var escPageName = encodeURIComponent( mw.config.get( 'wgPageName' ));
		mw.util.addPortletLink("p-tb", "//citations.toolforge.org/process_page.php?edit=toolbar&slow=1&wiki_base=en&page="+escPageName, 'Expand citations [slow]', 't-citationbot-slow', "Expand citations and fix formatting errors");
	}
}


function addCitationFastButton() {
	if ( document.getElementById( 'wpDiff' ) ) {
		var diff = document.getElementById( 'wpDiffWidget' );
		cbButton = new OO.ui.ButtonWidget();

		cbButton.setElementId( 'wpCitations' )
		.setIcon( 'articleCheck' )
		.setLabel( 'Citations [fast]' )
		.setFlags( 'secondary' );

		cbButton.on( 'click', function () {
			$.ajax( {
				type: 'POST',
				url: 'https://citations.toolforge.org/gadgetapi.php?wiki_base=en&',
				data: {
					text: $( '#wpTextbox1' ).textSelection( 'getContents' ),
					summary: $( '#wpSummary' ).textSelection( 'getContents' )
				},
				beforeSend: function() {
					$( cbButton.$element ).replaceWith( $spinnerspan );
				},
				success: function( data ) {
					expandedText = data.expandedtext;
					editSummary = data.editsummary;
					$( '#loader' ).replaceWith( cbButton.$element );
					if ( expandedText ) {
						// Populate text box with received expanded text
						$( '#wpTextbox1' ).textSelection( 'setContents', expandedText );
						// Populate edit summary textbox with received edit summary
						$( '#wpSummary' ).textSelection( 'setContents', editSummary );
						// Click 'Show preview' button
						$( '#wpDiff' ).click();
					} else {
						$( '#loader' ).replaceWith( cbButton.$element );
						alert( 'Error: Replacement text empty' );
					}
				},
				error: function( data ) {
					$( '#loader' ).replaceWith( cbButton.$element );
					alert( 'Error: Citations request failed' );
				}
			} );
		} );
		
		cbButton.$element.insertBefore( $(diff.nextSibling) );
	}
}

// Add a button to allow expanding citations in the text in the edit textbox
mw.hook( 'wikipage.editform' ).add( function() {
	if( !$spinnerspan ) {
		$spinnerspan = $( '<span id="loader"></span>');
	}
	if ( document.images ) {
		// Loading gif when Citations request is processing
		var spinner = new Image();
		spinner.src = "//upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif";
		$spinnerspan.append( spinner );
	}
	if( $('#wpCitations').length === 0 ){
		mw.loader.using( [ 'oojs-ui-core', 'oojs-ui.styles.icons-content', 'jquery.textSelection' ] ).then( addCitationFastButton );
	}
} );


// Add a toolbox button that runs Citation Bot on the most recent saved revision of the page
if ( $.inArray( mw.config.get( 'skin' ), ['monobook', 'modern', 'vector', 'timeless'] ) !== -1 ) {
  $( addCFastToToolbox );
  $( addCSlowToToolbox );
}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.