MediaWiki:Common.js
Erscheinungsbild
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
/* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */
/* WikiEditor Buttons */
(function () {
// Only on edit or submit actions
var action = mw.config.get('wgAction');
if (action !== 'edit' && action !== 'submit') {
return;
}
// Load WikiEditor then add tools
mw.loader.using('ext.wikiEditor').then(function () {
var $tb = $('#wpTextbox1');
// Abort if the wikitext textarea is not present (e.g., VisualEditor)
if (!$tb.length || typeof $tb.wikiEditor !== 'function') {
return;
}
// Helper: add tool group
function addTools(section, group, tools) {
$tb.wikiEditor('addToToolbar', {
section: section,
group: group,
tools: tools
});
}
/* ========== MAIN / INSERT ========== */
addTools('main', 'insert', {
categorytext: {
label: 'Category',
type: 'button',
icon: '/images/buttons/Button_category_new.png',
action: {
type: 'encapsulate',
options: {
pre: '[[Kategorie:',
periMsg: 'KategorieName',
post: ']]'
}
}
},
workinprogress: {
label: 'WorkInProgress Vorlage',
type: 'button',
icon: '/images/buttons/Button_progress_new.png',
action: {
type: 'encapsulate',
options: { pre: '{{WorkInProgress}}' }
}
},
notmaintained: {
label: 'NotMaintained Vorlage',
type: 'button',
icon: '/images/buttons/Button_maintained.png',
action: {
type: 'encapsulate',
options: { pre: '{{NotMaintained}}' }
}
},
toc: {
label: 'Table of Content einfügen',
type: 'button',
icon: '/images/buttons/Button_numbered_list.png',
action: {
type: 'encapsulate',
options: { pre: '__TOC__' }
}
},
tocright: {
label: 'Table of Content rechts einfügen',
type: 'button',
icon: '/images/buttons/Button_Toc.png',
action: {
type: 'encapsulate',
options: { pre: '{{TOCright}}' }
}
},
pretext: {
label: '<pre>',
type: 'button',
icon: '/images/buttons/Button_pre.png',
action: {
type: 'encapsulate',
options: {
pre: '<pre>',
periMsg: 'insert pre text here',
post: '</pre>'
}
}
},
sourcetext_bash: {
label: '<syntaxhighlight>',
type: 'button',
icon: '/images/buttons/Button_Source_new.png',
action: {
type: 'encapsulate',
options: {
pre: '<syntaxhighlight lang="bash">',
periMsg: 'insert source text here',
post: '</syntaxhighlight>'
}
}
},
relatedarticle: {
label: 'RelatedArticle',
type: 'button',
icon: '/images/buttons/article.png',
action: {
type: 'encapsulate',
options: {
pre: '{{#related:',
periMsg: 'insert sitename here',
post: '}}'
}
}
}
});
/* ========== ADVANCED / FORMAT ========== */
addTools('advanced', 'format', {
codetext: {
label: '<code>',
type: 'button',
icon: '/images/buttons/Button_code.png',
action: {
type: 'encapsulate',
options: {
pre: '<code>',
periMsg: 'insert code text here',
post: '</code>'
}
}
},
hline: {
label: 'Horizontal line',
type: 'button',
icon: '/images/buttons/Button_hr.png',
action: {
type: 'encapsulate',
options: { pre: '----', ownline: true }
}
},
strikethrough: {
label: 'Strike',
type: 'button',
icon: '/images/buttons/Button_strike.png',
action: {
type: 'encapsulate',
options: { pre: '<s>', post: '</s>' }
}
},
underline: {
label: 'Underline',
type: 'button',
icon: '/images/buttons/Button_underline.png',
action: {
type: 'encapsulate',
options: { pre: '<u>', post: '</u>' }
}
},
spanred: {
label: 'Span (red)',
type: 'button',
icon: '/images/buttons/Button_span_2.png',
action: {
type: 'encapsulate',
options: { pre: '<span style="color:red;">', post: '</span>' }
}
}
});
});
})();
/* Top20Pages */
$(function () {
var $ol = $('#tt-top20 ol').first();
if (!$ol.length) return;
$ol.find('li').each(function () {
var a = this.querySelector('a');
if (!a) return;
this.textContent = ''; // alles außer dem Link raus
this.appendChild(a);
});
});