Benutzer:Holder/common.js
Beaachte: Maage di cache faan dan browser leesag, wan dü a feranrangen sä wel.
- Firefox / Safari: Hual Shift bi't aktualisiarin, of trak Strg an F5 of Strg an R (⌘an R üüb en Mac)
- Google Chrome: Trak Strg an Shift an R (⌘an Shift an R üüb en Mac)
- Internet Explorer/Edge: Hual Strg bi't aktualisiarin, of trak Strg an F5
- Opera: Extras - Internetspuren löschen - Individuelle Auswahl - Den kompletten Cache löschen
//*** Configuration for "star" logo in front of interwiki links to Featured Articles
//*** and green symbol in front of interwiki links to Good Articles
/** set in Special:Mypage/common.js to switch off this "feature"
mw.user.options.set( 'linkFA_enabled', false );
* star logo for featured articles in other languages,
* see Template:Link_FA / Template:Link_GA and MediaWiki:Common.css
*/
mw.loader.using( [ 'user', 'mediawiki.user', 'user.options' ], function() { $(function() {
/** description that is displayed when cursor hovers above FA interwiki links */
var linkFA_description = "Exzellenter Artikel";
var linkGA_description = "Lesenswerter Artikel";
// linkFA_bullet/linkGA_bullet and linkFA_style/linkGA_Style wird nur für cologneblue verwendet,
// für monobook, modern siehe [[MediaWiki:Common.css]], vector hat in [[MediaWiki:Vector.css]] eigene Definitionen
/** image to use instead of the standard bullet (for cologneblue) */
var linkFA_bullet = "//upload.wikimedia.org/wikipedia/commons/d/d0/Monobook-bullet-star-transparent.png";
var linkGA_bullet = "//upload.wikimedia.org/wikipedia/commons/a/a1/Monobook-bullet-star-gray.png";
/** style to use for the linkFA_bullet/LinkGA_bullet img */
var linkFA_style = "margin-right: 0.2em;";
var linkGA_style = "margin-right: 0.2em;";
// early exit when disabled
if ( !mw.user.options.get( 'linkFA_enabled', true ) ) {
return;
}
// skins that can be handled the CSS class way
var skin = mw.config.get( 'skin' );
if (skin === "monobook" || skin === "modern" || skin === "vector" ) {
linkFA_CSS();
}
else if (skin === "cologneblue") {
linkFA_decorate();
}
/** skin == "monobook" || skin="modern" || skin== "vector" */
function linkFA_CSS() {
// links are to replaced in p-lang only
var pLang = document.getElementById("p-lang");
if (!pLang) return;
var lis = pLang.getElementsByTagName("li");
for (var i = 0; i < lis.length; i++) {
var li = lis[i];
//extract necessary classname
var matches = li.className.match( /(?:^| )(interwiki-[^ ]+)(?: |$)/ );
if ( !matches || matches.length != 2 ) {
continue;
}
var className = matches[1];
// only links with a corresponding Link_FA template are interesting
if (document.getElementById(className + "-fa")) {
li.className += " FA"; // additional class so the template can be hidden with CSS
li.title = linkFA_description; // change title
continue;
}
if (document.getElementById(className + "-ga")) {
li.className += " GA"; // additional class so the template can be hidden with CSS
li.title = linkGA_description; // change title
continue;
}
}
}
/** skin == "cologneblue" */
function linkFA_decorate() {
// these root elements can contain FA-/GA-links
var rootIds = new Array("topbar", "footer");
for (var i=0; i<rootIds.length; i++) {
var root = document.getElementById(rootIds[i]);
if (!root) continue;
// if the root exists, try to decorate all the links within
var links = root.getElementsByTagName("a");
for (var j=0; j<links.length; j++) {
decorate(links[j], "-fa", linkFA_bullet, linkFA_description, linkFA_style);
decorate(links[j], "-ga", linkGA_bullet, linkGA_description, linkGA_style);
}
}
}
/** id necessary, modify a link to show the FA- or GA-star (older) */
function decorate(link, idSuffix, bullet, description, style) {
var lang = link.hostname.split(".")[0];
var fa = document.getElementById("interwiki-" + lang + idSuffix);
if (!fa) return;
// build an image-node for the FA-star
var img = document.createElement("img");
img.setAttribute("src", bullet);
img.setAttribute("alt", description);
img.setAttribute("style", style);
// decorate the link with the image
link.appendChild(img);
link.appendChild(link.removeChild(link.firstChild));
link.setAttribute("title", description);
}
})});