MediaWiki:Gadget-InterProjectLinks.js

Opmerking: nadat u de wijzigingen hebt gepubliceerd is het wellicht nodig uw browsercache te legen.

  • Firefox / Safari: houd Shift ingedrukt terwijl u 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)
  • Internet Explorer / Edge: houd Ctrl ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5
  • Opera: druk op Ctrl-F5.
$( function() {
	'use strict';
	var
		iwlinks = $( 'div.interProject' ),
		wb = $( '#p-wikibase-otherprojects' ),
		pproject,
		wbul;
	if ( !iwlinks.length ) {
		return;
	}
	if ( wb.length ) {
		wbul = wb.find( 'ul' );
		if ( !wbul.length ) {
			return;
		}
		iwlinks.each( function( i, e ) {
			var
				t = $( e ),
				a = t.find( 'a' );
			if ( t.hasClass( 'commons' ) && !wb.find( '.wb-otherproject-commons' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wiktionary' ) && !wb.find( '.wb-otherproject-wiktionary' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikinews' ) && !wb.find( '.wb-otherproject-wikinews' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikisource' ) && !wb.find( '.wb-otherproject-wikisource' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikibooks' ) && !wb.find( '.wb-otherproject-wikibooks' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikiquote' ) && !wb.find( '.wb-otherproject-wikiquote' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikiversity' ) && !wb.find( '.wb-otherproject-wikiversity' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikidata' ) && !wb.find( '.wb-otherproject-wikidata' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikivoyage' ) && !wb.find( '.wb-otherproject-wikivoyage' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikispecies' ) && !wb.find( '.wb-otherproject-species' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'mediawiki' ) && !wb.find( '.wb-otherproject-mediawiki' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'meta' ) && !wb.find( '.wb-otherproject-meta' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'incubator' ) && !wb.find( '.wb-otherproject-incubator' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			else if ( t.hasClass( 'wikimania' ) && !wb.find( '.wb-otherproject-wikimania' ).length ) {
				a.unwrap().wrap( '<li class="' + t.attr( 'class' ) + '"></li>' ).parent().appendTo( wbul );
			}
			/*DEBUG[
			else {
				a.unwrap().wrap( '<li>' ).parent().appendTo( wbul );
			}]*/
		} );
	} else {
		pproject = $( '#p-tb' ).clone().attr( 'id', 'p-wikibase-otherprojects' ).insertAfter( '#p-tb' );
		if ( pproject.attr( 'aria-labelledby' ) ) {
			pproject.attr( 'aria-labelledby', 'p-wikibase-otherprojects-label' );
		}
		pproject.find( 'h3' ).attr( 'id', 'p-wikibase-otherprojects-label' ).text( 'In andere projecten' );
		pproject.find( 'ul' ).addClass( 'interProject' ).empty().append( iwlinks );
		iwlinks.replaceWith( function() {
			return $( '<li>' ).addClass( $(this).attr( 'class' ) ).append( $(this).contents() );
		} );
	}
} );