Difference between revisions of "MediaWiki:AuthorityControl.js"

From EAGLE MediaWiki
Jump to navigation Jump to search
(Created page with "/* * * Adapted from AuthorityControl.js by User:Ricordisamoa at Wikidata * Provides a link to various EAGLE Authority Control tools (EDH, ARACHNE, etc.) * for EAGLEwik...")
 
(correggo URL RIB)
 
(2 intermediate revisions by the same user not shown)
Line 16: Line 16:
 
33: 'http://petrae.tge-adonis.fr/index.php/inscriptions/liste?p01=$1', // Petrae
 
33: 'http://petrae.tge-adonis.fr/index.php/inscriptions/liste?p01=$1', // Petrae
 
34: 'http://www.ubi-erat-lupa.org/monument.php?id=$1', // Ubi Erat Lupa
 
34: 'http://www.ubi-erat-lupa.org/monument.php?id=$1', // Ubi Erat Lupa
  +
35: 'http://arachne.uni-koeln.de/entity/$1', // DAI
 
37: 'http://www.edb.uniba.it/epigraph/$1', // Epigraphic Database Bari (EDB)
 
37: 'http://www.edb.uniba.it/epigraph/$1', // Epigraphic Database Bari (EDB)
 
40: 'http://irt.kcl.ac.uk/irt2009/$1.html', // BSR (IRT)
 
40: 'http://irt.kcl.ac.uk/irt2009/$1.html', // BSR (IRT)
 
47: 'http://laststatues.classics.ox.ac.uk/database/detail-base.php?record=$1', // Last Statues of Antiquity
 
47: 'http://laststatues.classics.ox.ac.uk/database/detail-base.php?record=$1', // Last Statues of Antiquity
 
52: '$1', // Generic URL
 
52: '$1', // Generic URL
  +
63: 'http://romaninscriptionsofbritain.org/inscriptions/$1', // RIB
 
};
 
};
 
$.each( properties, function( k, v ) {
 
$.each( properties, function( k, v ) {

Latest revision as of 12:06, 2 October 2014

/*
 *
 * Adapted from AuthorityControl.js by [[User:Ricordisamoa]] at Wikidata
 * Provides a link to various EAGLE Authority Control tools (EDH, ARACHNE, etc.)
 * for EAGLEwiki elements that have related properties
 */

function AuthorityControl() {
	if( mw.config.get( 'wbEntityType' ) === 'item' ) { // only on items, not properties or other namespaces
		var baseLanguage = mw.config.get( 'wgUserLanguage' ).replace( /^([a-z]*).*$/g, '$1' );
		var properties = {
			 3: 'http://www.trismegistos.org/text/$1', // Trismegistos
			22: 'http://eda-bea.es/pub/record_card_1.php?rec=$1', // HispaniaEpigraphica
			24: 'http://edh-www.adw.uni-heidelberg.de/edh/inschrift/$1', // Heidelberg
			39: 'http://edh-www.adw.uni-heidelberg.de/edh/foto/$1', // Heidelberg-foto
			33: 'http://petrae.tge-adonis.fr/index.php/inscriptions/liste?p01=$1', // Petrae
			34: 'http://www.ubi-erat-lupa.org/monument.php?id=$1', // Ubi Erat Lupa
			35: 'http://arachne.uni-koeln.de/entity/$1', // DAI
			37: 'http://www.edb.uniba.it/epigraph/$1', // Epigraphic Database Bari (EDB)
			40: 'http://irt.kcl.ac.uk/irt2009/$1.html', // BSR (IRT)
			47: 'http://laststatues.classics.ox.ac.uk/database/detail-base.php?record=$1', // Last Statues of Antiquity
			52: '$1', // Generic URL
			63: 'http://romaninscriptionsofbritain.org/inscriptions/$1', // RIB
		};
		$.each( properties, function( k, v ) {
			var input = $( '.wb-snak-property a' ).filter( function() {
				return new RegExp( 'Property:P' + k + '$' ).test( this.href );
			} )
			.parent()
			.parent()
			.parent()
			.find( '.wb-snak-value .valueview-value textarea.valueview-input' );
			if( input && input.size() > 0 ) {
				input.each( function( i, e ) {
					var id = $( e ).val();
					if( k == 213 ) id = id.replace( / /g, '' );
					var parent = $( e ).parents( '.wb-statement-claim' ).first();
					if( parent.size() < 1 ) parent = $( e ).parents( '.wb-referenceview' ).first();
					parent
					.find( '.wb-editsection .wikibase-toolbarbutton' )
					.click( function() { // show the textarea and hide the link when the user clicks 'edit'
						$( e ).show().next().hide();
					} );
					$( e )
					.hide() // 'replace' the textarea with the link
					.after(
						$( '<a>' )
						.text( $( e ).val() )
						.attr( 'href', v.replace( '$1', id ) )
						.addClass( 'external' ) // show the 'external link' icon
					);
				} );
			}
		} );
	}
}

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