User:Minh Nguyen/wikibaselinks.js
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* Localize the sitelink at the top of the data item page.
*
* Dependencies: mediawiki.util
*/
$(function () {
if (mw.config.get("wgPageContentModel") !== "wikibase-item") return;
var userLanguage = mw.config.get("wgUserLanguage");
var localTitle = $("#P31 .wikibase-statementview-mainsnak .wb-monolingualtext-value:lang(" + userLanguage + ")").first().text();
if (localTitle) {
$(".wikibase-sitelinkview-page a")
.attr("href", mw.util.getUrl(localTitle))
.attr("title", localTitle)
.text(localTitle);
}
});
/**
* Links [[Property:P31]] statement values to the referenced wiki pages.
*
* Dependencies: mediawiki.util
*/
$(function () {
if (mw.config.get("wgPageContentModel") !== "wikibase-item") return;
$("#P31 .wikibase-statementview-mainsnak .wb-monolingualtext-value").wrapInner(function () {
return mw.html.element("a", {
href: mw.util.getUrl(this.textContent),
title: this.textContent
});
});
});