MediaWiki:Synchronizer.js

var Centralizer = {

init: function { Centralizer.makeTable; Centralizer.makeRows; },

makeTable: function { var table = $( ' ' ); var row = $( ' ' ); var headerWiki = $( ' ' ).text( 'Wiki' ); var headerLink = $( ' ' ).text( 'Link' ); var headerStatus = $( ' ' ).text( 'Status' ); row.append( headerWiki, headerLink, headerStatus ); table.append( row ); $( '#centralizer' ).html( table ); },

makeRows: function { var id = mw.config.get( 'wgWikibaseItemId' ); $.get( '//www.wikidata.org/wiki/Special:EntityData/' + id + '.json' ).done( function ( data ) {			console.log( data );			var entities = data.entities;			var entity = entities[ id ];			var sitelinks = entity.sitelinks;

var siteData, siteName, siteURL, siteTitle; var link; var row, cellWiki, cellLink, cellStatus; for ( var siteID in sitelinks ) { siteData = sitelinks[ siteID ]; siteName = siteData.site; siteLink = siteData.url; siteTitle = siteData.title;

link = $( '' ).text( siteTitle ).attr( 'href', siteLink );

cellWiki = $( ' ' ).html( siteID ); cellLink = $( ' ' ).html( link ); cellStatus = $( ' ' ); row = $( ' ' ).append( cellWiki, cellLink, cellStatus ); $( '#centralizer table' ).append( row ); }		} );	} };

$( Centralizer.init );