MediaWiki:Gadget-AuthorityControl.js

De WikiMinecraft
Saltar a: navegación, buscar
/* AuthorityControl.js
 * Provides a link to various Authority Control tools (VIAF, GND, etc.) for Wikidata statements that
 * feature certain properties.
 *
 * Original gadget coded by [[User:Ricordisamoa]]
 */
( function( mw, $ ) {

var BASE_LANGUAGE = mw.config.get( 'wgUserLanguage' ).replace( /[^a-z].*/, '' );

var PROPERTIES = {
	212: mw.util.getUrl('Special:BookSources') + '/$1', // ISBN-13
	213: 'http://www.isni.org/$1', // ISNI
	214: '//viaf.org/viaf/$1/', // VIAF
	220: 'http://www-01.sil.org/iso639-3/documentation.asp?id=$1', // ISO 639-3
	225: '//species.wikimedia.org/wiki/$1', // taxon name
	227: 'http://d-nb.info/gnd/$1', // GND
	231: '//tools.wmflabs.org/magnustools/cas.php?cas=$1', // CAS
	233: 'http://chemapps.stolaf.edu/jmol/jmol.php?model=$1', // SMILES molecular spec
	234: 'http://chemapps.stolaf.edu/jmol/jmol.php?&model=InChI=$1',  // InChl chem ID
	235: '//www.ncbi.nlm.nih.gov/sites/entrez?cmd=search&db=pccompound&term=%22$1%22[InChIKey]', // InChIKey
	236: '//www.worldcat.org/search?fq=x0:jrnl&q=n2:$1', // ISSN
	243: '//www.worldcat.org/oclc/$1?lang=' + BASE_LANGUAGE, // OCLC
	244: 'http://lccn.loc.gov/$1', // LCCN
	245: '//www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=$1', // ULAN
	246: 'http://www.iupac.org/highlights/periodic-table-of-the-elements.html',  // element symbol (table)
	247: 'http://nssdc.gsfc.nasa.gov/nmc/spacecraftDisplay.do?id=$1', // NSSDC ID
	267: 'http://www.whocc.no/atc_ddd_index/?code=$1', // ATC code
	268: 'http://catalogue.bnf.fr/ark:/12148/cb$1/PUBLIC', // BNF
	269: 'http://www.idref.fr/$1', // SUDOC
	270: 'http://opac.calis.edu.cn/aopac/ajsp/detail.jsp?actionfrom=1&actl=CAL++$1%23', // CALIS
	271: 'http://ci.nii.ac.jp/author/$1', // CiNii
	303: 'http://www.entente-ee.com/deutsch/sparten/tauben/Dateien/2012/ELRT%2011-06-2012.pdf',  // EE breed number (list)
	345: 'http://www.imdb.com/Name?$1', // IMDb
	347: 'http://www.culture.gouv.fr/public/mistral/joconde_fr?ACTION=CHERCHER&FIELD_1=REF&VALUE_1=$1', // Joconde
	349: 'http://id.ndl.go.jp/auth/ndlna/$1', // NDL
	350: 'http://explore.rkd.nl/nl/images/$1', // RKDimages
	351: 'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=retrieve&dopt=default&list_uids=$1', // Entrez Gene
	352: 'http://www.uniprot.org/uniprot/$1', // Uniprot
	353: 'http://www.genenames.org/data/hgnc_data.php?match=$1', // HGNC/HUGO gene symbol
	354: 'http://www.genenames.org/data/hgnc_data.php?hgnc_id=$1', // HGNC
	356: 'http://dx.doi.org/$1', // DOI
	359: 'http://monumentenregister.cultureelerfgoed.nl/php/main.php?cAction=search&cOffset=1&cLimit=25&oOrder=ASC&cSubmit=1&sCompMonNr=$1', // Rijksmonument
	373: '//commons.wikimedia.org/wiki/Category:$1', // Commons category
	374: 'http://www.insee.fr/fr/bases-de-donnees/esl/comparateur.asp?codgeo=com-$1', // INSEE commune code
	377: 'http://www.n2yo.com/satellite/?s=$1', // SCN
	380: 'http://www.culture.gouv.fr/public/mistral/merimee_fr?ACTION=CHERCHER&FIELD_1=REF&VALUE_1=$1', // Mérimée
	381: '//toolserver.org/~erfgoed/api/api.php?action=search&format=html&srcountry=ch&srid=$1', // KGS identifier
	396: 'http://id.sbn.it/af/$1', // SBN
	402: 'http://www.openstreetmap.org/?relation=$1', // OpenStreetmap
	409: 'http://nla.gov.au/anbd.aut-an$1', // NLA
	424: '//$1.wikipedia.org', // Wikimedia language code
	428: 'http://www.ipni.org/ipni/advPlantNameSearch.do?find_includePublicationAuthors=on&find_includePublicationAuthors=off&find_includeBasionymAuthors=on&find_includeBasionymAuthors=off&find_rankToReturn=all&output_format=normal&find_authorAbbrev=$1', // botanist author abbreviation
	434: '//musicbrainz.org/artist/$1', // MusicBrainz Artist ID
	435: '//musicbrainz.org/work/$1', // MusicBrainz Work ID
	436: '//musicbrainz.org/release-group/$1', // MusicBrainz Release Group ID
	454: 'http://' + ( $.inArray( BASE_LANGUAGE, ['de', 'en', 'fr'] ) !== -1 ? BASE_LANGUAGE : 'en' ) + '.structurae.de/structures/data/index.cfm?ID=$1', // Structurae ID
	455: 'http://www.emporis.com/' + ( $.inArray( BASE_LANGUAGE, ['de', 'en', 'fr'] ) !== -1 ? BASE_LANGUAGE : 'en' ) + '/wm/bu/?id=$1', // Emporis ID
	464: 'http://www.legifrance.gouv.fr/UnTexteDeJorf.do?numjo=$1', // NOR (French law)
	476: 'http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:$1:' + ( $.inArray( BASE_LANGUAGE, ['bg', 'es', 'cs', 'da', 'de', 'et', 'el', 'en', 'fr', 'ga', 'it', 'lv', 'lt', 'hu', 'mt', 'nl', 'pl', 'pt', 'ro', 'ro', 'sk', 'sl', 'fi', 'sv'] ) !== -1 ? BASE_LANGUAGE : 'en' ) + ':NOT', // CELEX (European law)
	477: 'http://www.historicplaces.ca/' + ( $.inArray( BASE_LANGUAGE, ['en', 'fr'] ) !== -1 ? BASE_LANGUAGE : 'en' ) + '/rep-reg/place-lieu.aspx?id=$1', // Historic Places (Canada)
	480: 'http://www.filmaffinity.com/' + ( $.inArray( BASE_LANGUAGE, ['en', 'es'] ) !== -1 ? BASE_LANGUAGE : 'en' ) + '/film$1.html', // Filmaffinity
	481: 'http://www.culture.gouv.fr/public/mistral/palissy_fr?ACTION=CHERCHER&FIELD_1=REF&VALUE_1=$1', // Palissy
	486: '//www.nlm.nih.gov/cgi/mesh/2013/MB_cgi?field=uid&term=$1', // Mesh
	492: '//omim.org/entry/$1', // OMIM
	493: 'http://www.icd9data.com/getICD9Code.ashx?icd9=$1', // ICD 9
	494: 'http://apps.who.int/classifications/icd10/browse/2010/en#/$1', // ICD 10
	496: 'http://orcid.org/$1', // ORCID
	497: 'http://db1.ihp.sinica.edu.tw/cbdbc/cbdbkm' + ( $.inArray( BASE_LANGUAGE.substring(0,2), ['zh'] ) !== -1 ? '' : 'eng' ) + '?~~AAA$1', // China Biographical Database
	498: 'http://www.currency-iso.org/dam/downloads/table_a1.xls', // ISO 4217 currency codes (list)
	502: 'http://www.nhc.noaa.gov/archive/$1', // HURDAT identifier
	508: 'http://thes.bncf.firenze.sbn.it/termine.php?id=$1', //BNFC
	535: 'http://www.findagrave.com/cgi-bin/fg.cgi?page=gr&GRid=$1', // Find a Grave
	536: 'http://www.atpworldtour.com/Tennis/Players/$1.aspx', // ATP id
	539: 'http://www.culture.gouv.fr/public/mistral/museo_fr?ACTION=CHERCHER&FIELD_98=REF&VALUE_98=$1', // Museofile
	549: 'http://genealogy.math.ndsu.nodak.edu/id.php?id=$1', // MGP
	557: 'http://www.diseasesdatabase.com/ddb$1.htm', // DiseasesDB
	563: 'http://www.progenetix.org/cgi-bin/subsets.cgi?project=progenetix&subsetType=ICDM&ICDMcodes_m=$1', // ICD-O
	586: 'http://www.ipni.org/ipni/idAuthorSearch.do?id=$1', // IPNI author
	587: 'http://www.marinetraffic.com/ais/fr/shipdetails.aspx?MMSI=$1', // MMSI author
	590: '//geonames.usgs.gov/pls/gnispublic/f?p=gnispq:3:::NO::P3_FID:$1', // GNIS
	592: 'https://www.ebi.ac.uk/chembl/compound/inspect/$1', // ChEMBL
	594: 'http://www.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g=$1', // Ensembl ID
	597: 'http://www.wtatennis.com/players/player/$1', // WTA id
	599: 'http://www.itftennis.com/procircuit/players/player/profile.aspx?playerid=$1', // ITF id
	600: '//appdb.winehq.org/appview.php?iAppId=$1', // Wine AppDB-ID
	604: '//www.nlm.nih.gov/medlineplus/ency/article/$1.htm', // MedlinePlus
	625: '//tools.wmflabs.org/geohack/geohack.php?language=' + BASE_LANGUAGE + '&params=$1', // coordinates
	627: 'http://www.iucnredlist.org/details/$1/0', // IUCN
	628: 'http://www.codexalimentarius.net/gsfaonline/additives/results.html?searchBy=ins&ins=$1', // E Number
	630: 'http://www.v2asp.paris.fr/commun/v2asp/v2/nomenclature_voies/Voieactu/$1.nom.htm', // Paris streets
	633: 'http://www.patrimoine-culturel.gouv.qc.ca/rpcq/detail.do?methode=consulter&id=$1&type=bien', // Quebec protected places
	638: 'http://www.rcsb.org/pdb/explore/explore.do?structureId=$1', // PDB ID
	640: 'http://www.culture.gouv.fr/public/mistral/leonore_fr?ACTION=CHERCHER&FIELD_1=COTE&VALUE_1=$1', // Léonore
	646: 'http://www.freebase.com$1', // Freebase ID (note that property values are supposed to start with slashes)
	648: 'https://openlibrary.org/books/$1', // Open Library
	650: 'http://explore.rkd.nl/nl/artists/$1', // RKDartists
	651: 'http://www.biografischportaal.nl/persoon/$1', // BPN
	652: 'http://fdasis.nlm.nih.gov/srs/srsdirect.jsp?regno=$1', // UNII
	653: '//www.ncbi.nlm.nih.gov/pubmedhealth/$1', // PubMed Health
	661: 'http://www.chemspider.com/Chemical-Structure.$1', // Chemspider
	662: 'https://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=$1', // PubChem ID
	665: 'http://www.kegg.jp/entry/$1', // KEGG ID
	668: '//www.ncbi.nlm.nih.gov/books/$1', // GeneReviews ID
	671: 'http://www.informatics.jax.org/marker/MGI:$1', // Mouse Gene Informatics ID
	673: 'http://emedicine.medscape.com/article/$1', // eMedicine
	675: 'http://books.google.com/books?id=$1', // Google Books identifier
	677: 'http://drusop.nature.cz/ost/chrobjekty/chrob_find/index.php?frame=1&h_kod=$1', // ÚSOP Code
	683: 'https://www.ebi.ac.uk/chebi/searchId.do?chebiId=CHEBI:$1', // ChEBI
	685: '//www.ncbi.nlm.nih.gov/taxonomy/$1', // NCBI Taxonomy ID
	686: 'http://amigo.geneontology.org/cgi-bin/amigo/term_details?term=GO:$1', // Gene Ontology ID
	687: 'http://biodiversitylibrary.org/page/$1', // BHL Page ID
	691: 'http://aut.nkp.cz/$1', // NK CR
	698: '//www.ncbi.nlm.nih.gov/pubmed/?term=$1',  // PubMed ID
	699: 'http://disease-ontology.org/term/DOID%3A$1', // diseases ontology ID
	701: 'http://dodis.ch/$1', // DODIS
	709: 'http://hsewsf.sedsh.gov.uk/hslive/hsstart?P_HBNUM=$1', // Historic Scotland ID
	715: 'http://www.drugbank.ca/drugs/DB$1', // Drugbank ID
	716: 'http://ssd.jpl.nasa.gov/sbdb.cgi?sstr=$1', // JPL Small-Body Database
	717: 'http://newton.dm.unipi.it/neodys/index.php?pc=2.1.0&o=$1', // MP
	718: 'http://canmore.rcahms.gov.uk/en/site/$1/details/', // Canmore ID
	721: 'http://www.mosclassific.ru/mClass/okato_view.php?text=$1', // OKATO
	723: 'http://www.dbnl.org/auteurs/auteur.php?id=$1', // DBNL ID
	724: 'https://archive.org/details/$1', // Internet Archive ID
	727: 'http://www.europeana.eu/portal/record/$1.html', // Europeana ID
	731: '//www.bgr.de/app/litholex/gesamt_ausgabe_neu.php?id=$1', // Litholex ID
	732: '//www.bgs.ac.uk/Lexicon/lexicon.cfm?pub=$1', // BGX Lexicon ID
	733: 'http://www.dinoloket.nl/$1', // Dinoloket ID
	745: 'http://www.ins-bremen.de/pbub/autor-werke.php?ID=$1&START=1&ORD=JAHR', // PBuB identifier
	757: 'http://whc.unesco.org/' + ( $.inArray( BASE_LANGUAGE, ['en', 'fr'] ) !== -1 ? BASE_LANGUAGE : 'en' ) + '/list/$1', // UNESCO World Heritage
	758: 'http://www.kulturminnesok.no/kulturminnesok/kulturminne/?LOK_ID=$1', // Kulturminne
	759: 'https://hermis.alberta.ca/ARHP/Details.aspx?DeptID=1&ObjectID=$1', // Alberta Historic Places ID
	763: 'http://www.gov.pe.ca/hpo/app.php?nav=details&p=$1&lang=' + ( $.inArray( BASE_LANGUAGE.substring(0,2), ['fr'] ) !== -1 ? 'F' : 'E' ), // Prince Edward Island Historic Places ID
	764: 'http://classif.spb.ru/classificators/view/tma.php?st=A&kr=1&kod=$1', // OKTMO
	781: 'http://www.sikart.ch/KuenstlerInnen.aspx?id=$1&lng=' + ( $.inArray( BASE_LANGUAGE, ['de', 'fr', 'it'] ) !== -1 ? BASE_LANGUAGE : 'en' ), // Sikart
	791: 'http://dispatch.opac.d-nb.de/DB=1.2/CMD?ACT=SRCHA&IKT=8529&TRM=$1',  // ISIL-ID
	804: '//geonames.usgs.gov/pls/gnispublic/f?p=gnispq:5:::NO::P5_ANTAR_ID:$1', // GNIS Antarctica ID
	808: '//toolserver.org/~platonides/wlm/ids.php?bic=$1', // code Bien de Interés Cultural (BIC)
	809: 'http://protectedplanet.net/sites/$1', // WDPA ID
	815: 'http://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=TSN&search_value=$1', // ITIS TSN
	818: 'http://arxiv.org/abs/$1', // arXiv
	819: 'http://adsabs.harvard.edu/abs/$1', // ADS bibcode
	821: 'http://www4.rncan.gc.ca/search-place-names/unique.php?id=$1', // CGNDB ID
	824: 'http://www.lpi.usra.edu/meteor/metbull.php?code=$1', // ADS bibcode
	827: 'http://www.bbc.co.uk/programmes/$1', // BBC Identifier
	829: '//oeis.org/$1', //  On-Line Encyclopedia of Integer Sequences
	830: 'http://eol.org/pages/$1', // EOL
	838: 'http://www.biolib.cz/en/taxon/id$1', // BioLib
	839: 'http://imslp.org/wiki/$1', // IMSLP ID
	842: 'http://fossilworks.org/bridge.pl?a=taxonInfo&taxon_no=$1', // Fossilworks ID
	845: 'http://heritageapp.cyr.gov.sk.ca/public/index.cfm?action=propdetails&id=$1', // Saskatchewan ID
	846: 'http://data.gbif.org/species/$1', // GBIF-ID
	850: 'http://www.marinespecies.org/aphia.php?p=taxdetails&id=$1', // WoRMS-ID
	860: 'http://www.e-archiv.li/personDetail.aspx?persID=$1', // e-archiv.li
	861: 'http://www.premiershiprugby.com/matchcentre/fixtures/squads.php?player=$1&includeref=dynamic', // premiershiprugby.com
	863: 'https://inpho.cogs.indiana.edu/idea/$1.html', //  Indiana Philosophy Ontology project
	864: '//dl.acm.org/author_page.cfm?id=$1', // Association for Computing Machinery Digital Library author identifier
	865: 'http://bmlo.de/$1', // Bayerisches Musiker-Lexikon Online
	866: 'http://www.perlentaucher.de/autor/$1.html', // Perlentaucher
	867: '//recrutement.pole-emploi.fr/fichesrome/ficherome?codeRome=$1&domaine=Candidat', // Rome occupation code
	882: 'http://quickfacts.census.gov/qfd/states/$1.html', //FIPS
	884: 'http://vwo.osm.rambler.ru/?page=findname&name=$1', // State Water Register Code (Russia)
	886: 'http://www.e-lir.ch/e-LIR___Lexicon.$1.450.0.html', // Lexicon istoric retic (LIR)
	888: 'http://www.jstor.org/stable/$1', // JSTOR
	889: 'http://www.ams.org/mathscinet-getitem?mr=$1', // ?Mathematical Reviews identifier
	892: '//tools.ietf.org/html/rfc$1', // Request for Comments number (IETF)
	893: 'http://ssrn.com/abstract=$1', // Social Science Research Network
	902: 'http://www.hls-dhs-dss.ch/textes/' + ( $.inArray( BASE_LANGUAGE, ['fr'] ) !== -1 ? 'f/F' : ( $.inArray( BASE_LANGUAGE, ['it'] ) !== -1 ? 'i/I' : 'd/D' )) + '$1.php', // HDS/HLS/DHS/DSS identifier
	905: 'http://port.' + ( $.inArray( BASE_LANGUAGE.substring(0,2), ['ro', 'cs' , 'sk', 'hr', 'sr'] ) !== -1 ? ( $.inArray( BASE_LANGUAGE, ['cs'] ) !== -1 ? 'cz' : ( $.inArray( BASE_LANGUAGE, ['sr'] ) !== -1 ? 'rs' : BASE_LANGUAGE ) ) : 'hu' ) + '/pls/fi/films.film_page?i_film_id=$1', // PORT-network identifier
	906: '//libris.kb.se/auth/$1', // Libris library catalog
	907: 'http://allgame.com/game.php?id=$1', // AMG Game ID
	909: 'https://eapps.ednet.ns.ca/HPIPublic/PropertyDisplay.aspx?Fid=$1', // Nova Scotia Register of Historic Places ID
	918: 'http://www5.' + ( $.inArray( BASE_LANGUAGE.substring(0,2), ['fr'] ) !== -1 ? 'rhdcc.gc.ca/CNP/Francais/CNP/2011/Profil' : 'hrsdc.gc.ca/noc/english/noc/2011/Profile' ) + '.aspx?val=7&val1=$1', // NOC Occupation Code
	920: 'http://id.sgcb.mcu.es/lem/ver/Autoridades/$1/concept', // Spanish subject headings for public libraries
	933: 'http://www.heritagefoundation.ca/property-search/property-details-page.aspx?id=$1', // heritagefoundation.ca ID
	935: '//commons.wikimedia.org/wiki/$1', // Commons gallery
	938: 'http://www.fishbase.org/Summary/speciesSummary.php?id=$1',  // Fishbase ID
	939: 'http://www.ksh.hu/apps/!cp.hnt2.telep?nn=$1', // Hungarian Central Statistical Office (KSH)
	946: 'http://tools.wmflabs.org/isin/?language=de&isin=$1',  // ISIN
	947: 'http://aleph.rsl.ru/F?func=find-b&find_code=SYS&adjacent=Y&local_base=RSL11&request=$1', // Russian State Library identifier
	949: 'http://a20.libnet.ac.il/F?func=find-b&REQUEST=$1&find_code=SYS&local_base=NNL10', // NLI (Israel) identifier
	950: 'http://catalogo.bne.es/uhtbin/authoritybrowse.cgi?action=display&authority_id=$1', // BNE identifier
	959: 'http://www.departments.bucknell.edu/biology/resources/msw3/browse.asp?s=y&id=$1', // MSW species identifier
	960: 'http://www.tropicos.org/Name/$1',  //Tropicos taxon name identifier
	961: 'http://www.ipni.org/ipni/idPlantNameSearch.do?id=$1', // IPNI taxon name identifier
	962: 'http://www.mycobank.org/MycoTaxo.aspx?Link=T&Rec=$1', // MycoBank taxon name identifier
	966: '//musicbrainz.org/label/$1', // MusicBrainz Label ID
	982: '//musicbrainz.org/area/$1', // MusicBrainz Area ID
	998: 'http://www.dmoz.org/$1', // Open Directory Project (DMOZ)
	1003: 'http://alephnew.bibnat.ro:8991/F?func=find-b&request=$1&find_code=SYS&adjacent=Y&local_base=NLR10', // NLR (Romania) identifier
	1004: '//musicbrainz.org/place/$1', // MusicBrainz Place ID
	1005: 'http://purl.pt/index/geral/aut/PT/$1.html', // PTBNP identifier
	1006: 'http://opc4.kb.nl/PPN?PPN=$1', // NTA name identifier
	1014: 'http://vocab.getty.edu/aat/$1', // AAT
	1025: 'http://www.sudoc.fr/$1', // SUDOC catalog (editions only)
	1036: 'http://dewey.info/class/$1/about', // DDC
	1042: 'http://dispatch.opac.d-nb.de/DB=1.1/CMD?ACT=SRCHA&IKT=8506&TRM=$1', // ZDB identifier
	1043: 'http://www.onisep.fr/onisep-portail/portal/media-type/html/group/gp/page/interieur.espace.guide.metiers.detail/js_peid/InitGuideResultatDetail/js_peid/GuideResultatMetiersDetail?typeRecherche=metierParNom&ficheIdeo=$1', // IDEO Job ID
	1044: 'http://swb.bsz-bw.de/DB=2.1/PPNSET?PPN=$1&INDEXSET=1', // SWB editions (union catalog)
	1045: 'http://www.assemblee-nationale.fr/sycomore/fiche.asp?num_dept=$1', // Sycomore
	1047: 'http://www.catholic-hierarchy.org/bishop/b$1.html', // Catholic Hierarchy
	1048: 'http://aleweb.ncl.edu.tw/F/?func=accref&acc_sequence=$1', // NCL identifier
	1051: 'http://pshmanager.techlib.cz/psh_csv', // PSH
	1053: 'http://www.researcherid.com/rid/$1', // ResearcherID
	1054: 'http://iss.ndl.go.jp/books?op_id=1&any=$1', // NDL editions
	1055: '//www.ncbi.nlm.nih.gov/nlmcatalog/$1', // NLM
	1058: 'http://lamp.infosys.deakin.edu.au/era/?page=jnamedet12f&eraid=$1', // ERA ID
	1059: 'http://cvr.dk/Site/Forms/PublicService/DisplayCompany.aspx?cvrnr=$1', // CVR identifier
	1070: 'http://www.theplantlist.org/tpl1.1/record/$1', // PlantList
	1084: 'http://srv3.eulc.edu.eg/eulc_v5/libraries/Start.aspx?fn=ApplySearch&BibID=$1', // EUL control number
	1085: 'http://www.librarything.com/work/$1', // LibraryThing work identifier
	1133: 'http://lampspw.wallonie.be/dgo4/site_thema/index.php?details=$1&thema=bc_pat', // DGO4 classified properties ID
	1138: 'https://www.kulturarv.dk/kid/VisKunstner.do?kunstnerId=$1', // Kunstindeks Danmark
	1144: 'http://lccn.loc.gov/$1', // LCCN editions
	1146: 'http://www.iaaf.org/athletes/athlete=$1', // IAAF ID
	1182: 'http://libris.kb.se/bib/$1',  // LIBRIS editions
	1187: 'http://authority.ddbc.edu.tw/person/search.php?aid=$1', //Dharma Drum Buddhist College person ID
	1212: 'http://cartelfr.louvre.fr/cartelfr/visite?srv=car_not_frame&idNotice=$1', //Atlas ID
	1214: 'http://data.riksdagen.se/person/$1', //Riksdagen person-id
	1216: 'http://list.english-heritage.org.uk/resultsingle.aspx?uid=$1', //English Heritage list number
	1222: 'http://research.archives.gov/person/$1', // NARA person authority control
	1223: 'http://research.archives.gov/organization/$1', // NARA organization authority control
	1224: 'http://research.archives.gov/geographic-reference/$1', // NARA geographic authority control
	1225: 'http://research.archives.gov/topical-subject/$1', // NARA subject authority control
	1226: 'http://research.archives.gov/specific-records-type/$1', // NARA records type authority control
	1231: 'research.archives.gov/description/$1', // NARA online catalog
	1238: 'http://svenskfotboll.se/allsvenskan/person/?playerid=$1', // Swedish Football Association playerid
	1245: 'http://www.omegawiki.org/DefinedMeaning:$1'//OmegaWiki DefinedMeaning
	// Note: Watch out to keep the trailing comma at the end of every entry other than the last!
};

mw.hook( 'wikibase.domready' ).add( function() {
        if(mw.config.get('wgNamespaceNumber') !== 0) {
		// Only item pages feature appropriate statements.
		return;
	}

	initGadget();
} );

/**
 * Initializes the gadget.
 * This procedure needs to be perform as good as possible. jQuery selector usage should be limited
 * to a minimum.
 */
function initGadget() {
	$( ':wikibase-statementview' ).each( function() {
		var $statementview = $( this ),
			statementview = $.data( this, 'statementview' ),
			statement = statementview.value(),
			mainSnak = statement.getMainSnak(),
			numericPropertyId = mainSnak.getPropertyId().slice( 1 ),
			qualifiers = statement.getQualifiers(),
			references = statementview.getReferences(),
			// Do not look for referenceview DOM nodes before they are actually needed:
			$referenceviews = null;

		if( PROPERTIES[numericPropertyId] ) {
			createLink(
				numericPropertyId,
				mainSnak.getValue(),
				statementview.$mainSnak,
				$statementview
			);
		}

		qualifiers.each( function( i, snak ) {
			if( PROPERTIES[snak.getPropertyId().slice( 1 )] ) {
				linkSnakview( snak, statementview.$qualifiers, $statementview );
			}
		} );

		for( var i in references ) {
			references[i].getSnaks().each( function( j, snak ) {
				if( PROPERTIES[snak.getPropertyId().slice( 1 )] ) {
					if( !$referenceviews ) {
						$referenceviews = $statementview.find( ':wikibase-referenceview' );
					}
					linkSnakview( snak, $referenceviews.eq( i ) );
				}
			} );
		}
	} );
}

/*
*/
function getGeoHackParams( coord ) {
	// TODO: individual scale for every precession

	var globes = {
		'Q308'   : 'mercury',
		'Q313'   : 'venus',
		'Q2'     : 'earth',
		'Q111'   : 'mars',

		'Q405'   : 'moon',

		'Q15034' : 'mimas',
	};

	/* BUG: .getGlobe() returns Q2 always */
	var globeQKey = coord.getGlobe().replace('http://www.wikidata.org/entity/', '');
	var globe = globes[globeQKey];

	return coord.getLatitude() + '_N_' + coord.getLongitude() + '_E_globe:' + globe;
}

/**
 * Creates a link that is placed after a snak's input textarea.
 *
 * @param {number} numericPropertyId Refers to PROPERTIES.
 * @param {object} snakValue The original value that shall be used in the link.
 * @param {jQuery} $parent The node whose descendants shall be searched for the snak value
 *                 textarea.
 * @param {jQuery} $toolbarParent The node the "edit" toolbar corresponding to the value that shall
 *                 be linked is initialized on.
 */
function createLink( numericPropertyId, snakValue, $parent, $toolbarParent ) {
	var $displayElement;
	var linkValue, displayText;
	if (snakValue.getType() === "string") {
		switch( Number(numericPropertyId) )  {
		case 213:   // ISNI
		  linkValue = snakValue.getValue().replace( / /g, '' );
		  break;
		case 502:   // HURDAT
		  linkValue = snakValue.getValue().substring(4,8);  // year
		  if ( Number(linkValue) <= 2005 ) {
			linkValue += "/";   // Brings a list for that year
			// For direct link, would need to append <name of hurricane>.[s]htlm 
			// ex: http://www.nhc.noaa.gov/archive/2004/ALEX.shtml   or   2001/ALLISON.html
		  } else {              // after 2005
			linkValue += "/" + snakValue.getValue().substring(0,4).toLowerCase() + "/";
		  }
		  break;
		case 628:   // E Number
		  linkValue = snakValue.getValue().substring(1,16);  // Skip initial letter
		  break;
		case 882:   // FIPS
		  linkValue = snakValue.getValue();
		  linkValue = linkValue.substr(0,2) + '/' + linkValue;
		  break;
		default:
		  linkValue = snakValue.getValue();
		}
		$displayElement = $parent.find( '.wb-snak-value .valueview-value textarea.valueview-input' );
		displayText = $displayElement.val();
	}
	else if (snakValue.getType() === "globecoordinate") {
		linkValue = getGeoHackParams(snakValue.getValue());
		$displayElement = $parent.find( '.wb-snak-value .valueview-value span' );
		displayText = $displayElement.text();
	}

	var toolbar = $toolbarParent.data( 'edittoolbar' ).toolbar,
		$btnEdit = toolbar.editGroup._buttons.edit,
		linkTemplate = PROPERTIES[numericPropertyId];

	var $link = $( '<a/>' )
		.text( displayText )
		.attr( 'href', linkTemplate.replace( '$1', linkValue ) )
		// Show the 'external link' icon:
		.addClass( 'external' );

	$displayElement.hide().after( $link );

	// Using ".one" since, currently, link and textarea visibility are not toggled after leaving
	// edit mode anyhow:
	$btnEdit.one( 'click', function() {
		$link.hide();
		$displayElement.show();
	} );
}

/**
 * Creates a link for the snakview featuring a specific snak.
 * Since the order of the snaks within a SnakList does not necessarily have to be the same than the
 * displayed/grouped snakviews, all snakviews need to be looped over to find out the snakview that
 * features a specific snak.
 *
 * @param {wikibase.Snak} snakToLink
 * @param {jQuery} $parent The node whose descendants will be searched for snaklistviews
 * @param {jQuery} [$toolbarParent] The node the "edit" toolbar corresponding to the value that
 *                 shall be linked is initialized on.
 */
function linkSnakview( snakToLink, $parent, $toolbarParent ) {
	$toolbarParent = $toolbarParent || $parent;

	$parent.find( '.wb-snakview' ).each( function() {
		var snak = $.data( this, 'wikibaseSnakview' ).snak();

		if( snak.equals( snakToLink ) ) {
			createLink( snak.getPropertyId().slice( 1 ), snak.getValue(), $( this ), $toolbarParent );
			return false;
		}
	} );
}

}( mediaWiki, jQuery ) );