User:Osiris/common.js

//Dokumentation auf Benutzer:Schnark/js/specialinterwiki /*global mw: true */ (function($){ var specialinterwiki = { version: 1.4, default_target: 'de', go: function {   var href = mw.config.get('wgScript') + '?title=' + $('#interwiki-input').val + ':Special:' + mw.config.get('wgCanonicalSpecialPageName');   var search = window.location.search, hash = window.location.hash;   search = search.replace(/^\?/, '&').replace(/&title=[^&]*/g, ); //title entfernen   var slash = decodeURIComponent(window.location.pathname);   var index = slash.indexOf(mw.config.get('wgPageName').replace(/\/.*$/, ) + '/');   if (index > -1) {      slash = encodeURIComponent(slash.substr(index + 1 + mw.config.get('wgPageName').replace(/\/.*$/, '').length));      href += '/' + slash;   }   window.location.href = href + search + hash; }, init: function  {   var $tb = $('#p-tb');   if ($tb.length === 0) return;   var $iw = $tb.clone.attr('id', 'p-lang').addClass('expanded').removeClass('collapsed'); $iw.find('.body').css('display', 'block'); $iw.find('h5').removeAttr('tabindex').text('Other languages'); $iw.find('ul').html('' +                          ''); $('#p-tb').after($iw); $('#interwiki-go').click(specialinterwiki.go); $('#interwiki-input').keypress(function (ev) {   if (ev.which == 13) specialinterwiki.go;   }); } }; if (mw.config.get('debug')) window.specialinterwiki = specialinterwiki; $(document).trigger('loadWikiScript', ['Benutzer:Schnark/js/specialinterwiki.js', specialinterwiki]); if (mw.config.get('wgNamespaceNumber') == -1) $(specialinterwiki.init); })(jQuery); //

mw.loader.using( [ 'mediawiki.util' ], function { jQuery( document ).ready(function { var iProject = document.getElementById("interProject"); if(!iProject) return; var sistersibling = document.getElementById("p-lang"); if(!sistersibling) sistersibling= document.getElementById("p-tb"); if(!sistersibling) return; var sisterparent = sistersibling.parentNode; var sisterprojectnav = document.createElement("div"); sisterprojectnav.id = "p-sisterprojects"; sisterprojectnav.className = sistersibling.className sisterprojectnav.innerHTML = ' '+document.getElementById("sisterProjects").firstChild.innerHTML+'  '; var sistersiblingsub = sistersibling.getElementsByTagName("div")[0]; if(sistersiblingsub){ sisterprojectnav.childNodes[1].className = sistersiblingsub.className; } else { sisterprojectnav.childNodes[1].className = "pBody"; }   var sisternext = document.getElementById("p-lang"); if ( sisternext && sisternext.parentNode == sisterparent ){ sisterparent.insertBefore( sisterprojectnav, sisternext ); }else{ sisterparent.appendChild(sisterprojectnav); }   var sisterlinks = iProject.getElementsByTagName("a"); for (var i = 0; i < sisterlinks.length; i++) { var sistername = sisterlinks[i].firstChild.nodeValue mw.util.addPortletLink('p-sisterprojects', sisterlinks[i].getAttribute("href") + '?uselang=' + mw.config.get( 'wgUserLanguage' ), sistername, "sister-"+ sistername, sistername); } })});