Naar inhoud springen

Gebruiker:Sjoerddebruin/common.js

Uit Wikipedia, de vrije encyclopedie

Opmerking: na het publiceren moet je misschien je browsercache legen om de veranderingen te zien.

  • Firefox / Safari: houd Shift ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
  • Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
  • Edge: houd Ctrl ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5.
$(function(){if(mw.config.get('wgPageName').startsWith('Gebruiker:')){setTimeout(function(){articleQuality.getAndRenderScoreHeader();},1500);}});
mw.loader.using(['mediawiki.util']).done(() => {
	if (mw.config.get('wgNamespaceNumber') === 14) {
		let categoryLink = mw.config.get("wgPageName");
		let categoryName = "Categorie:" + mw.config.get('wgTitle').replace(/_/g, ' ');
		let v1Syntax = `CREATE||LAST|Snlwiki|"${categoryLink}"||LAST|Lnl|"${categoryName}"||LAST|Dnl|"Wikimedia-categorie"||LAST|P31|Q4167836`;
		let quickStatementsURL = 'https://quickstatements.toolforge.org/#/v1=' + encodeURIComponent(v1Syntax);
		let petScanImagesURL = 'https://petscan.wmflabs.org/?format=html&ns%5B0%5D=1&project=wikipedia&page_image=no&depth=1&show_redirects=no&sortby=none&categories=' + mw.config.get('wgTitle') + '&language=nl&wikidata_prop_item_use=P18&search_max_results=5000&templates_no=Infobox+generiek&doit=';
		if (!document.getElementById('t-wikibase')) {
			mw.util.addPortletLink('p-tb', quickStatementsURL, 'Wikidata-item aanmaken', 'tb-CNC');
		}
		mw.util.addPortletLink('p-tb', petScanImagesURL, 'Missende afbeeldingen', 'tb-PMI');
	}
	mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript');
});

/*  _____________________________________________________________________________
 * |                                                                             |
 * |                    === WARNING: GLOBAL GADGET FILE ===                      |
 * |                  Changes to this page affect many users.                    |
 * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
 * |_____________________________________________________________________________|
 *
 * Imported as of 09/06/2011 from [[User:ErrantX/defaultsummaries.js]]
 * Edited version from [[User:MC10/defaultsummaries.js]]
 * Implements default edit summary dropdown boxes
 */

/* global mw, ve */

/* eslint-disable no-jquery/no-global-selector */

( function () { // Wrap with anonymous function
	var $summaryBox = $( '#wpSummary' ),
		minorSummaries = [
			'Spelling/grammatica/interpunctie/typografische verbetering',
			'Opmaak',
			'[[Wikipedia:Vandalisme|Vandalisme]] of testbewerking [[Help:Terugdraaien van ongewenste wijzigingen|teruggedraaid]]',
			'Ongemotiveerde aanpassing [[Help:Terugdraaien van ongewenste wijzigingen|terugdraaid]]',
			'[[Wikipedia:Wikiproject/Check Wikipedia|Lint-fout]]'
		],
		articleSummaries = [
			'Artikel uitgebreid',
			'Referenties toegevoegd of aangepast',
			'[[Help:Wikificeren|Wikificatie]]',
			'Categorie(ën) aangepast',
			'Interne links toegevoegd of aangepast',
			'Externe links toegevoegd of aangepast',
			'Onbebronde informatie verwijderd',
			'Infobox toegevoegd'
		],
		nonArticleSummaries = [
			'Reactie',
			'Opmerking',
			'Suggestie'
		];

	function addOptionsToDropdown( dropdown, optionTexts ) {
		dropdown.menu.addItems( optionTexts.map( function ( optionText ) {
			return new OO.ui.MenuOptionWidget( { label: optionText } );
		} ) );
	}

	function onSummarySelect( option ) {
		// Save the original value of the edit summary field
		var editsummOriginalSummary = $summaryBox.val(),
			canned = option.getLabel(),
			newSummary = editsummOriginalSummary;

		// Append old edit summary with space, if exists,
		// and last character != space
		if ( newSummary.length !== 0 && newSummary.charAt( newSummary.length - 1 ) !== ' ' ) {
			newSummary += ' ';
		}
		newSummary += canned;
		$summaryBox.val( newSummary ).trigger( 'change' );
	}

	function getSummaryDropdowns() {
		// For convenience, add a dropdown box with some canned edit
		// summaries to the form.
		var namespace = mw.config.get( 'wgNamespaceNumber' ),
			dropdown = new OO.ui.DropdownWidget( {
				label: 'Veelgebruikte bewerkingssamenvattingen'
			} ),
			minorDropdown = new OO.ui.DropdownWidget( {
				label: 'Veelgebruikte kleine bewerkingssamenvattingen'
			} );

		dropdown.menu.on( 'select', onSummarySelect );
		minorDropdown.menu.on( 'select', onSummarySelect );

		addOptionsToDropdown( minorDropdown, minorSummaries );

		if ( namespace === 0 ) {
			addOptionsToDropdown( dropdown, articleSummaries );
		} else {
			addOptionsToDropdown( dropdown, nonArticleSummaries );
			if ( namespace % 2 !== 0 && namespace !== 3 ) {
				addOptionsToDropdown( dropdown, talkPageSummaries );
			} else if (namespace === 118 ) {
				addOptionsToDropdown( dropdown, articleSummaries );
			}
		}
		return dropdown.$element.add( minorDropdown.$element );
	}
	// VisualEditor
	mw.hook( 've.saveDialog.stateChanged' ).add( function () {
		var target, $saveOptions, $dropdowns;
		// .ve-init-mw-viewPageTarget-saveDialog-checkboxes
		if ( $( 'body' ).data( 'wppresent' ) ) {
			return;
		}
		$( 'body' ).data( 'wppresent', 'true' );

		target = ve.init.target;
		$saveOptions = target.saveDialog.$saveOptions;
		$summaryBox = target.saveDialog.editSummaryInput.$input;
		if ( !$saveOptions.length ) {
			return;
		}
		$dropdowns = getSummaryDropdowns();
		$saveOptions.before( $dropdowns );
	} );
	// WikiEditor
	$.when( mw.loader.using( 'oojs-ui-core' ), $.ready ).then( function () {
		var $dropdowns,
			$editCheckboxes = $( '.editCheckboxes' );

		// If we failed to find the editCheckboxes class
		if ( !$editCheckboxes.length ) {
			return;
		}
		$dropdowns = getSummaryDropdowns();
		$dropdowns.css( {
			width: '48%',
			'padding-bottom': '1em'
		} );
		$editCheckboxes.before( $dropdowns );
	} );
}() );

// make it obvious where things are broken by disabling the auto-correction fix.
mw.util.addCSS(`html.skin-theme-clientpref-night body .mw-parser-output [style*='background'] {color: inherit; }`);