User:So9q/diva-search-link.js
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// This script helps the user search DiVA when visiting any topic in Wikidata
( function ( mw, $ ) {
// https://www.wikidata.org/wiki/Help:Namespaces
// 0 == main
// 146 == lexemes
if (mw.config.get( 'wgNamespaceNumber' ) != 0) {
return;
} else {
var sv_label = $(".wikibase-labelview[lang='sv']").first().find('.wikibase-labelview-text').text();
var en_label = $(".wikibase-labelview[lang='en']").first().find('.wikibase-labelview-text').text();
if (en_label != "") {
mw.util.addPortletLink(
'p-tb',
'http://www.diva-portal.org/smash/resultList.jsf?dswid=-7075&language=en&searchType=SIMPLE&query=' + en_label + '&af=%5B%5D&aq=%5B%5B%5D%5D&aq2=%5B%5B%5D%5D&aqe=%5B%5D&noOfRows=50&sortOrder=author_sort_asc&sortOrder2=title_sort_asc&onlyFullText=false&sf=all',
'Search on the DiVA portal using the English label',
't-diva1',
'This Wikidata topic in DiVA the portal for all Swedish science'
);
}
if (sv_label != "") {
mw.util.addPortletLink(
'p-tb',
'http://www.diva-portal.org/smash/resultList.jsf?dswid=-7075&language=sv&searchType=SIMPLE&query=' + sv_label + '&af=%5B%5D&aq=%5B%5B%5D%5D&aq2=%5B%5B%5D%5D&aqe=%5B%5D&noOfRows=50&sortOrder=author_sort_asc&sortOrder2=title_sort_asc&onlyFullText=false&sf=all',
'Search on the DiVA portal using the Swedish label',
't-diva2',
'This Wikidata topic in DiVA the portal for all Swedish science'
);
}
}
}( mediaWiki, jQuery ) );