User:Faux/common.js

location.search.indexOf("printable=yes") == -1 && $(function ($) { var translate = {    'de': {      notfound: "Wikidata-Eintrag nicht gefunden",      intro: "Wikidata: ",      nolabel: "(Keine Bezeichnung)",      nodescription: "Keine Beschreibung vorhanden",      aliases: "Alternative Bezeichnungen: ",      noaliases: "keine"    },    'en': {      notfound: "Wikidata item not found.",      intro: "Wikidata: ",      nolabel: "(No label)",      nodescription: "no description given",      aliases: "Aliases: ",      noaliases: "None"    }  }  var namespace = mw.config.get('wgNamespaceNumber'),     lang = mw.config.get('wgPageContentLanguage'),    page = ( namespace -= ( namespace > 0 && namespace % 2 ) ) === 0 ? mw.config.get('wgTitle') : mw.config.get('wgFormattedNamespaces')[ namespace ] + ':' + mw.config.get('wgTitle');  namespace != 2 && $.ajax({ url: '//www.wikidata.org/w/api.php', data: { 'format': 'json', 'action': 'wbgetentities', 'sites': mw.config.get('wgDBname'), 'titles': page, 'props': 'info|labels|descriptions|aliases', 'languages': lang },   dataType: 'jsonp', success: function (data) { if (data.success) { var $d = $(" ").appendTo("#contentSub"), m = translate[ mw.config.get('wgUserLanguage') ] || translate.en; for (var i in data.entities) { if (i == -1) { $d.append($("").attr("href", "//www.wikidata.org/wiki/Special:CreateItem?site="+mw.config.get("wgDBname")+"&page="+page).text( m.notfound )) } else { var item = data.entities[i], i = 0, aliases = []; try { for (i < item.aliases[lang].length; i++) { aliases.push(item.aliases[lang][i].value); }           } catch (e) { } if ( window.WDIlimitaliases && WDIlimitaliases < aliases.length ){ for(WDIlimitaliases < aliases.length; aliases.pop ) ; aliases.push( "..." ); }           $d.append($("").attr("href", "//www.wikidata.org/wiki/" + item.title).text(m.intro + ( item.labels ? item.labels[lang].value : m.nolabel ) + " (" + item.title + ")"),$(" ").text(", "),$("").text(item.descriptions ? item.descriptions[lang].value : m.nodescription),$(" "),$(" ").text(m.aliases + (aliases.join(", ") || m.noaliases))) }       }      }    }  }); });