User:Christian Ferrer/common.js

From Wikidata
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.load( '//www.wikidata.org/w/index.php?title=User:Succu/taxobox.js&action=raw&ctype=text/javascript' ); // [[User:Succu/taxobox.js]]
mw.loader.load( '//www.wikidata.org/w/index.php?title=User:Ricordisamoa/Wikispecies.js&action=raw&ctype=text/javascript' ); // [[User:Ricordisamoa/Wikispecies.js]]
////////// link in the toolbox section in left sidebar, to ALEC (A List of Everything Cool)//////////
/*global mw, $*/
/*jshint curly:false */

$(document).ready(function() {
	if (mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgAction') !== "view" ) return;
		mw.util.addPortletLink('p-tb', 'https://alec-demo.herokuapp.com/' + mw.config.get('wgPageName'), 'ALEC', null);
});
////////// link in the toolbox section in left sidebar, to Wikimedia Commons search for images//////////
/*global mw, $*/
/*jshint curly:false */

$(document).ready(function() {
	if (mw.config.get('wgNamespaceNumber') !== 0 || mw.config.get('wgAction') !== "view" ) return;
		mw.util.addPortletLink('p-tb', 'https://commons.wikimedia.org/w/index.php?search=' + mw.config.get('wgPageName') + '&title=Special:MediaSearch&go=Go&type=image', 'Search images', null);
});
////////// link named "Images (query)" in the toolbox section in left sidebar, to a query in Wikimedia Commons Query Service that shows files depicting taxon and child taxa. Only displayed for items having P225 (taxon name)//////////
/*global mw, $*/
/*jshint curly:false */

$(document).ready(function() {
    mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function( entity ) {
    // only on entities, not properties or other namespaces
    if ( mw.config.get('wgNamespaceNumber') != 0 ) return ;
    if ( mw.config.get('wgAction') != 'view' ) return ;
    
    if( typeof entity.claims=='undefined' ) return;
	if( Object.keys( entity.claims ).indexOf( 'P225' ) != -1 ){
		mw.util.addPortletLink('p-tb', 'https://wcqs-beta.wmflabs.org/embed.html#%23defaultView%3AImageGrid%0ASELECT%20%3Ffile%20%3Fimage%0AWITH%0A{%0A%20%20SELECT%20%3Fitem%20%0A%20%20WHERE%0A%20%20{%0A%20%20%20%20SERVICE%20%3Chttps%3A%2F%2Fquery.wikidata.org%2Fsparql%3E%0A%20%20%20%20{%0A%20%20%20%20%20%20%20%20%3Fitem%20wdt%3AP171%2Fwdt%3AP171*%20wd%3A' + mw.config.get('wgPageName') + '.%0A%20%20%20%20%20}%20%0A%20%20}%0A}%20AS%20%25get_items%0AWHERE%0A{%0A%20%20INCLUDE%20%25get_items%0A%20%20%3Ffile%20wdt%3AP180%20%3Fitem%20.%0A%20%20%3Ffile%20schema%3AcontentUrl%20%3Furl%20.%0A%20%20BIND(IRI(CONCAT(%22http%3A%2F%2Fcommons.wikimedia.org%2Fwiki%2FSpecial%3AFilePath%2F%22%2C%20wikibase%3AdecodeUri(SUBSTR(STR(%3Furl)%2C53))))%20AS%20%3Fimage)%0A}', 'Images (query)', null);
    }
    } );
});
////////// link named "List of treated taxa (query)" in the toolbox section in left sidebar, to a query in Wikidata Query Service giving the taxa where the reference is used, the role of the reference, and the potential Plazi IDs. Only displayed for items having P1476 (title)//////////
/*global mw, $*/
/*jshint curly:false */

$(document).ready(function() {
    mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function( entity ) {
    // only on entities, not properties or other namespaces
    if ( mw.config.get('wgNamespaceNumber') != 0 ) return ;
    if ( mw.config.get('wgAction') != 'view' ) return ;
    
    if( typeof entity.claims=='undefined' ) return;
	if( Object.keys( entity.claims ).indexOf( 'P1476' ) != -1 ){
		mw.util.addPortletLink('p-tb', 'https://query.wikidata.org/embed.html#SELECT%20%0A%20%20%3Fitem%20%3FitemLabel%20%3FsynOf%20%3FsynOfLabel%20%3Fsyn_sl%20%3FrefHasRole%20%3FrefHasRoleLabel%20%3FPages%0A%20%20%28IRI%28CONCAT%28%22https%3A%2F%2Fbiodiversitylibrary.org%2Fpage%2F%22%2C%3FBHLpageID%29%29%20as%20%3FBHL_URL%29%0A%20%20%28IRI%28CONCAT%28%22http%3A%2F%2Ftreatment.plazi.org%2Fid%2F%22%2C%3FPlaziID%29%29%20as%20%3FPlaziID_URL%29%0AWHERE%20%7B%0A%20%20%3Freference%20pr%3AP248%20%3Fpublication.%20FILTER%20%28%3Fpublication%20IN%20%28wd%3A' + mw.config.get('wgPageName') + '%29%29%0A%20%20%3Freference%20%5Eprov%3AwasDerivedFrom%20%3Fst%20.%0A%20%20%3Fst%20%5Ep%3AP225%20%3Fitem%20.%0A%0A%20%20OPTIONAL%20%7B%0A%20%20%20%20%3Fitem%20p%3AP2868%20%3Fsyn_st%20.%0A%20%20%20%20%3Fsyn_st%20a%20wikibase%3ABestRank%20.%0A%20%20%20%20%3Fsyn_st%20ps%3AP2868%20wd%3AQ1040689%20.%0A%20%20%20%20%3Fsyn_st%20pq%3AP642%20%3FsynOf%20.%0A%20%20%20%20OPTIONAL%20%7B%0A%20%20%20%20%20%20%3Fsyn_sl%20schema%3Aabout%20%3FsynOf%20.%0A%20%20%20%20%20%20%3Fsyn_sl%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fspecies.wikimedia.org%2F%3E%20.%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20OPTIONAL%20%7B%20%3Freference%20pr%3AP6184%20%3FrefHasRole%20.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Freference%20pr%3AP304%20%3FPages%20.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Freference%20pr%3AP1992%20%3FPlaziID%20.%20%7D%0A%20%20OPTIONAL%20%7B%20%3Freference%20pr%3AP687%20%3FBHLpageID%20.%20%7D%0A%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%7D', 'List of treated taxa (query)', null);
    }
    } );
});
////////// link named "Taxa list (query)" in the toolbox section in left sidebar, to a query in Wikidata Query Service giving the taxa list for which the person is noted as the author. Only displayed for items having P106 (occupation)//////////
/*global mw, $*/
/*jshint curly:false */

$(document).ready(function() {
    mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function( entity ) {
    // only on entities, not properties or other namespaces
    if ( mw.config.get('wgNamespaceNumber') != 0 ) return ;
    if ( mw.config.get('wgAction') != 'view' ) return ;
    
    if( typeof entity.claims=='undefined' ) return;
	if( Object.keys( entity.claims ).indexOf( 'P106' ) != -1 ){
		mw.util.addPortletLink('p-tb', 'https://query.wikidata.org/embed.html#SELECT%20(YEAR(%3Fdate)%20as%20%3Fyear)%20%3Ftaxonitem%20%3FtaxonitemLabel%20%3FtaxonitemDescription%20%3Frank%20%3FrankLabel%20%3Fimg%20%3Fwikispecies%0AWHERE%0A{%0A%20%20%20%20%3Fst%20pq%3AP405%20wd%3A' + mw.config.get('wgPageName') + '%20.%20%0A%20%20%20%20%3Fst%20ps%3AP225%20%3Ftaxon%20.%0A%20%20%20%20%3Ftaxonitem%20p%3AP225%20%3Fst%20.%20%0A%20%20%20%20OPTIONAL%20{%20%3Fst%20pq%3AP574%20%3Fdate%20}%0A%20%20%20%20OPTIONAL%20{%20%3Ftaxonitem%20wdt%3AP105%20%3Frank%20}%0A%20%20%20%20OPTIONAL%20{%20%3Ftaxonitem%20wdt%3AP18%20%3Fimg%20}%0A%20%20%20%20OPTIONAL%20{%20%3Fwikispecies%20schema%3Aabout%20%3Ftaxonitem%20%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fspecies.wikimedia.org%2F%3E%20}%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20{%20bd%3AserviceParam%20wikibase%3Alanguage%20%22[AUTO_LANGUAGE]%2Cen%22.%20}%0A}', 'Taxa list (query)', null);
    }
    } );
});
////////// link named "Articles list (query)" in the toolbox section in left sidebar, to a query in Wikidata Query Service giving the articles list for which the person is noted as the author. Only displayed for items having P106 (occupation)//////////
/*global mw, $*/
/*jshint curly:false */

$(document).ready(function() {
    mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function( entity ) {
    // only on entities, not properties or other namespaces
    if ( mw.config.get('wgNamespaceNumber') != 0 ) return ;
    if ( mw.config.get('wgAction') != 'view' ) return ;
    
    if( typeof entity.claims=='undefined' ) return;
	if( Object.keys( entity.claims ).indexOf( 'P106' ) != -1 ){
		mw.util.addPortletLink('p-tb', 'https://query.wikidata.org/embed.html#SELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20(YEAR(%3Fdate_de_publication)%20as%20%3Fyear)%20%3Fwikispecies%20%3FwikimediaCommons%20WHERE%20{%0A%20%20SERVICE%20wikibase%3Alabel%20{%20bd%3AserviceParam%20wikibase%3Alanguage%20%22[AUTO_LANGUAGE]%2Cen%22.%20}%0A%20%20{%0A%20%20%20%20SELECT%20DISTINCT%20%3Fitem%20WHERE%20{%0A%20%20%20%20%20%20%3Fitem%20p%3AP50%20%3Fstatement0.%0A%20%20%20%20%20%20%3Fstatement0%20(ps%3AP50%2F(wdt%3AP279*))%20wd%3A' + mw.config.get('wgPageName') + '.%0A%20%20%20%20%20%20%20%20%20%20}%0A%20%20%20%20LIMIT%20100%0A%20%20}%0A%20%20OPTIONAL%20{%20%3Fwikispecies%20schema%3Aabout%20%3Fitem%20%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fspecies.wikimedia.org%2F%3E%20}%0A%20%20OPTIONAL%20{%20%3FwikimediaCommons%20schema%3Aabout%20%3Fitem%20%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fcommons.wikimedia.org%2F%3E%20}%0A%20%20OPTIONAL%20{%20%3Fitem%20wdt%3AP577%20%3Fdate_de_publication.%20}%0A}', 'Articles list (query)', null);
    }
    } );
});