Page MenuHomePhabricator
Authored By
alaa_wmde
Jul 29 2019, 10:32 PM
Size
1 KB
Referenced Files
None
Subscribers
None
/* <nowiki>
*
* taxobox.js by [[User:FelixReimann]] with help from [[User:Ricordisamoa]]
* based on [[User:Ricordisamoa/Wikispecies.js]]
*/
$(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 ){// 'taxon name' is present
var language = mw.user.options.get('language');
var count = 5;
if (mw.config.get('taxoboxCount')) {
count = mw.config.get('taxoboxCount');
}
var template = '<div class="wikibase-taxobox">{{Taxobox|qid=' + wgPageName + '|count=' + count + '|lang=' + language + '}}<div class="wikibase-taxobox-references" style="clear:right;"><references/></div></div>';
// https://www.wikidata.org/w/api.php?action=parse&text={{Taxobox|qid=Q36146}}&prop=text&contentmodel=wikitext&format=jsonfm
$.getJSON(mw.util.wikiScript('api'),
{
action:'parse',
format:'json',
text:template,
contentmodel:'wikitext',
prop:'text'
},
function(data){
var text=data.parse.text;
$('.wikibase-sitelinkgrouplistview').append(text['*']); // TODO insert text
});
}
} );
});
//</nowiki>

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7792555
Default Alt Text
raw.txt (1 KB)

Event Timeline