User:So9q/KORP-link.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)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
 * Simple script to add a link to the Swedish corpus KORP in the Tools section on items.
 * Forked from https://www.wikidata.org/wiki/User:Fnielsen/scholia-link.js by Fnielsen.
 * Getting the lemma with code by Salgo60 from https://www.wikidata.org/wiki/User:Salgo60/SAOB.js 
 */

( function ( mw, $ ) {
	if (mw.config.get( 'wgNamespaceNumber' ) != 146) {
		return;
	} else {
		mw.hook("wikibase.entityPage.entityLoaded").add( function ( e ) {
			var language = e.language,
				lemma = e.lemmas && e.lemmas.sv ? e.lemmas.sv.value : false;
			if (lemma && language == 'Q9027') {
				// Add portlet link for item
				mw.util.addPortletLink(
					'p-tb',
					'//spraakbanken.gu.se/korp/#?cqp=[]&corpus=fsbbloggvuxna,magmakolumner,informationstidningar,lagtexter,myndighet,propositioner,barnlitteratur,fsbessaistik,fsbsakprosa,fsbskonlit1960-1999,fsbskonlit2000tal,ungdomslitteratur,fnb1999,fnb2000,hbl1991,hbl1998,hbl1999,hbl20122013,hbl2014,jakobstadstidning1999,jakobstadstidning2000,pargaskungorelser2011,pargaskungorelser2012,sydosterbotten2010,sydosterbotten2011,sydosterbotten2012,sydosterbotten2013,sydosterbotten2014,vasabladet1991,vasabladet2012,vasabladet2013,vasabladet2014,abounderrattelser2012,abounderrattelser2013,osterbottenstidning2011,osterbottenstidning2012,osterbottenstidning2013,osterbottenstidning2014,borgabladet,vastranyland,at2012,ostranyland,astra1960-1979,astranova,bullen,fanbararen,finsktidskrift,forumfeot,hankeiten,hanken,jft,kallan,meddelanden,nyaargus,studentbladet,svenskbygden,sfs,romi,romii,rom99,storsuc,bloggmix1998,bloggmix1999,bloggmix2000,bloggmix2001,bloggmix2002,bloggmix2003,bloggmix2004,bloggmix2005,bloggmix2006,bloggmix2007,bloggmix2008,bloggmix2009,bloggmix2010,bloggmix2011,bloggmix2012,bloggmix2013,bloggmix2014,bloggmix2015,bloggmix2016,bloggmix2017,bloggmixodat,twitter,gp1994,gp2001,gp2002,gp2003,gp2004,gp2005,gp2006,gp2007,gp2008,gp2009,gp2010,gp2011,gp2012,gp2013,gp2d,press65,press76,press95,press96,press97,press98,webbnyheter2001,webbnyheter2002,webbnyheter2003,webbnyheter2004,webbnyheter2005,webbnyheter2006,webbnyheter2007,webbnyheter2008,webbnyheter2009,webbnyheter2010,webbnyheter2011,webbnyheter2012,webbnyheter2013,attasidor,dn1987,ordat,fof,snp7879,suc3,wikipedia-sv,talbanken&search=word|' + lemma,
					'KORP',
					't-korp',
					'This Wikidata item in KORP'
				);
			}
		});
	}
}( mediaWiki, jQuery ) );