User:Stratoprutser/404.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
/**
* User-script in utter disregard of Wikimedia privacy policy
* use at your own risk to display interlanguage-links on 404-pages and redlinks
* See [[Wiktionary:Beer_parlour/2013/February#Yahoo_Pipe_for_404s]]
*/
jQuery;
var microbubble = window.microbubble || {};
jQuery.fn.getPipe = function () {
var pipeFeed = new microbubble.PipeFeed(this);
pipeFeed.parse();
};
/**
* PipeFeed Class
* Returns interwikis
*/
microbubble.PipeFeed = function (htmlElement) {
htmlElement.html('<ul id="feed-results"></ul>');
var listElement = $("#feed-results");
return {
parse: function (word) {
$.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=7ac42099ecdbca4d74462199a5383c89&_render=json&_callback=?&word=" + wgTitle,
function (json) {
parseFeed(json);
});
}
};
function parseFeed(json) {
var seen = {}; /* preventing double interwikis */
if (json.count > 0) {
$(json.value.items).each(function () {
var itemDetail = createInterwiki(this);
if (seen[itemDetail]) $(this).remove();
else {
seen[itemDetail] = true;
$(listElement).append(itemDetail);
}
});
} else {
-htmlElement.html('<ul><li class="interwiki">No interwikis found</li></ul>\n');
}
}
function createInterwiki(item)
{
return '<li class="interwiki-' + item.content + '"><a href="//' + item.content + '.wiktionary.org/wiki/' + wgTitle + '" title="' + wgTitle + '" lang="' + item.content + '" hreflang="' + item.content + '">' + item.content + '</a></li>\n';
}
};
if (wgArticleId==0 && wgCanonicalSpecialPageName==false)
{
$('#mw-panel').append('<div class="portal persistent" role="navigation" id="p-lang">\n<h3 tabindex="3">In other languages</h3>\n<div class="body" style="display: block;" id="interwikis"></div></div>');
$("#interwikis").html("<em>loading interwikis...</em>");
$("#interwikis").getPipe();
}