Share to:

MediaWiki:Common.js

/*
 * FILE : Common.js
 * LAST EDIT DATE : 25/06/2020
 * LAST EDITED BY : Fierodelveneto
*/
 mw.loader.load( '/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
/* global mediaWiki, jQuery */

( function ( mw, $ ) {
	'use strict';

	// ============================
	//     Cargamento script
	// ============================
	
/**  WikiMiniAtlas */
/*  Description: WikiMiniAtlas is a popup click and drag world map.
 *               This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
 *               The script itself is located on meta because it is used by many projects.
 *               See [[Meta:WikiMiniAtlas]] for more information. 
 *  Maintainers: [[User:Dschwen]]
 */
window.wma_settings = {
    buttonImage: "//upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Erioll_world.svg/15px-Erioll_world.svg.png"
};
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript');
/**  Fine WikiMiniAtlas */


/**  Configurasion mapa */
mw.config.set( 'osm_proj_map', 'mapa' ); //"map" in project language
mw.config.set( 'osm_proj_lang', 'vec' ); //project language
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js&action=raw&ctype=text/javascript');
/**  Configurasion mapa*/


/**  Rexultai da Wikidata  [[File:Wdsearch_script_screenshot.png]]*/
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
        mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
/** Fine Rexultai da Wikidata  [[File:Wdsearch_script_screenshot.png]]*/

/** BEGIN PURGETAB (2020) */
mw.loader.load( '/w/index.php?title=MediaWiki:Gadget-purgetab.js&action=raw&ctype=text/javascript' );
/** END PURGETAB (2020) */

	/**
	 * Portlets
	 */
	function addPortlets() {
		mw.loader.using( 'mediawiki.util' )
			.done( function () {
				// Ligo direto a commons par cargar
				mw.util.addPortletLink( 'p-tb', '//commons.wikimedia.org/wiki/Commons:Upload/vec', 'Carga so Commons',
					't-uploadcommons', 'Carga file multimediałi in Wikimedia Commons', '', '#t-specialpages' );

				// In "Wikipedia:Prinsipio" el zonta lista conpleta
				if (
					mw.config.get( 'wgIsMainPage' ) ||
					mw.config.get( 'wgPageName' ) === "Discusion Wikipedia:Prinsipio"
				) {
					var link = mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Lista_de_Wikipedie',
						'Lista intiera', 'interwiki-completelist', 'Lista intiera' );
					$( link ).css( 'font-weight', 'bold' );
				}
			} )
			.fail( function () {
				console.warn( 'MediaWiki:Common.js - Inpusìbiłe zontar lighi a ła sidebar.' );
			} );
	}

	$( addPortlets );

	/**
	 * El zonta un combox a [[MediaWiki:Edittools]]  par sełesionar grupi de caràtari spesałi (sperimentale).
	 */
	function comboboxEdittools() {
		var $specialChars = $( '#specialchars' );
		if ( $specialChars.length ) {
			var $select = $( '<select>' ).change( function () {
				$specialChars.find( 'p' ).hide();
				$specialChars.find( 'option:selected' ).data().show();
			} );
			$specialChars.find( 'p' ).each( function () {
				$( '<option>' ).html( $( this ).attr( 'id' ).replace( /_/g, ' ' ) )
					.data( $( this ) ).appendTo( $select );
			} );
			$specialChars.prepend( $select );
			$select.change();
		}
	}

	$( comboboxEdittools );


	// ============================
	//    Suporto ai modełi
	// ============================

	/**
	 * Doparada co [[modeło:Tìtuło sbajà]] par canbiar tìtuło,
	 * serca un HTML (creà dal modeło) contegnente:
	 * <div id="RealTitleBanner"><span id="RealTitle">tìtuło</span></div>
	 * El se połe dezativar co on ełemento co id="DisableRealTitle".
	 * Inportà inisialmente da [[en:MediaWiki:Common.js]].
	 * A volta soa da [[it:MediaWiki:Common.js]].
	 */
	function checkRealTitleBanner() {
		// Pusibilità de dezabiłitarlo
		if ( window.disableCheckRealTitleBanner ) {
			return;
		}

		var $realTitleBanner = $( '#RealTitleBanner' );
		if ( $realTitleBanner.length && !$( '#DisableRealTitle' ).length ) {
			var $realTitle = $realTitleBanner.find( '#RealTitle' );
			var $firstH1 = $( 'h1:first' );
			if ( $realTitle.length && $firstH1.length ) {
				$realTitleBanner.hide();
				$firstH1.html( $realTitle.html() );
				document.title = $realTitle.text() + ' - Wikipedia';
			}
		}
	}

	$( checkRealTitleBanner );

	/**
	 * Doparà con [[modeło:Gałaria]] par far na gałaria de imàzeni:
	 * serca un HTML (creà dal modeło) contegnente:
	 * <div class="ImageGroup"><div class="ImageGroupUnits">imàzeni</div></div>
	 * Idea orizenària da [[fr:MediaWiki:Common.js]] del 2007.
	 * @author [[it:User:Rotpunkt]]
	 */
	function updateImageGroup( currImg, $images, $countInfo, $prevLink, $nextLink ) {
		$images.hide().eq( currImg ).show();
		$countInfo.html( '(' + ( currImg + 1 ) + '/' + $images.length + ')' );
		$prevLink.toggle( currImg !== 0 );
		$nextLink.toggle( currImg !== $images.length - 1 );
	}

	function initImageGroup() {
		$( 'div.ImageGroup > div.ImageGroupUnits' ).each( function ( i, imageGroupUnits ) {
			var currImg = 0;
			var $images = $( imageGroupUnits ).children( '.center, .mw-halign-center' );
			var $countInfo = $( '<kbd>' ).css( 'font-size', '110%' );
			var $prevLink =	$( '<a>' )
				.attr( 'href', '#' ).attr( 'title', 'Imàzene antesedente' )
				.text( '◀' ).css( 'text-decoration', 'none' )
				.click( function ( e ) {
					e.preventDefault();
					updateImageGroup( currImg -= 1, $images, $countInfo, $prevLink, $nextLink );
				} );
			var $nextLink =	$( '<a>' )
				.attr( 'href', '#' ).attr( 'title', 'Imàzene sevente' )
				.text( '▶' ).css( 'text-decoration', 'none' )
				.click( function ( e ) {
					e.preventDefault();
					updateImageGroup( currImg += 1, $images, $countInfo, $prevLink, $nextLink );
				} );
			updateImageGroup( currImg, $images, $countInfo, $prevLink, $nextLink );
			$( imageGroupUnits ).prepend( $prevLink, $countInfo, $nextLink );
		} );
	}

	$( initImageGroup );

	/**
	 * Doparà co [[ModTemplate:Navbox]]: se ghe ze pì navbox co
	 * clase mw-collapsible, chełi co autocollapse i se sara lori soli.
	 */
	function checkAutocollapse( $content ) {
		var $navbox = $content.filter( '.navbox' );
		if ( $navbox.length > 1 ) {
			$navbox.filter( '.autocollapse' ).find( '.mw-collapsible-toggle' ).click();
		}
	}

	mw.hook( 'wikipage.collapsibleContent' ).add( checkAutocollapse );
}( mediaWiki, jQuery ) );


/**
 * Script par alternar intrà vàrie imàzene doparà inte el modelo {{switcher2}}

 * provegnensa: [[:fr:special:permalink/165756873]] inte el 26-07-2020 e [[:ca:special:permalink/24309161]] inte el 13-11-2021

 */

function GeoBox_Init($content) {
	$content.find( 'div.img_toogle' ).each( function ( i, Container ) {
		Container.id = 'img_toogle_' + i;
		var Boxes = $( Container ).find( '.geobox' );
		if (Boxes.length < 2) {
			return;
		}
		var ToggleLinksDiv = document.createElement('ul');
		ToggleLinksDiv.id = 'geoboxToggleLinks_' + i;
		Boxes.each( function ( a, ThisBox ) {
			ThisBox.id = 'geobox_' + i + '_' + a;
			var ThisAlt = ThisBox.getElementsByTagName('img')[0].alt;
			var toggle = document.createElement('a');
			toggle.id = 'geoboxToggle_' + i + '_' + a;
			toggle.textContent = ThisAlt;
			toggle.href = 'javascript:';
			toggle.onclick = function (e) {
				e.preventDefault();
				GeoBox_Toggle(this);
			};
			var Li = document.createElement('li');
			Li.appendChild(toggle);
			ToggleLinksDiv.appendChild(Li);
			if (a === (Boxes.length - 1)) {
				toggle.style.color = '#888';
				toggle.style.pointerEvents = 'none';
			} else {
				ThisBox.style.display = 'none';
			}
		} );
		Container.appendChild(ToggleLinksDiv);
	} );
}

function GeoBox_Toggle(link) {
	var ImgToggleIndex = link.id.replace('geoboxToggle_', '').replace(/_.*/g, '');
	var GeoBoxIndex = link.id.replace(/.*_/g, '');
	var ImageToggle = document.getElementById('img_toogle_' + ImgToggleIndex);
	var Links = document.getElementById('geoboxToggleLinks_' + ImgToggleIndex);
	var Geobox = document.getElementById('geobox_' + ImgToggleIndex + '_' + GeoBoxIndex);
	var Link = document.getElementById('geoboxToggle_' + ImgToggleIndex + '_' + GeoBoxIndex);
	if ( !ImageToggle || !Links || !Geobox || !Link ) {
		return;
	}
	$( ImageToggle ).find( '.geobox' ).each( function ( _, ThisgeoBox ) {
		if (ThisgeoBox.id === Geobox.id) {
			ThisgeoBox.style.display = '';
		} else {
			ThisgeoBox.style.display = 'none';
		}
	} );
	$( Links ).find( 'a' ).each( function ( _, thisToggleLink ) {
		if (thisToggleLink.id === Link.id) {
			thisToggleLink.style.color = '#888';
			thisToggleLink.style.pointerEvents = 'none';
		} else {
			thisToggleLink.style.color = '';
			thisToggleLink.style.pointerEvents = '';
		}
	} );
}

mw.hook( 'wikipage.content' ).add( GeoBox_Init );

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.
Prefix: a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9

Portal di Ensiklopedia Dunia

Kembali kehalaman sebelumnya