Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 101: | Zeile 101: | ||
}); | }); | ||
document.addEventListener('DOMContentLoaded', function() { | document.addEventListener('DOMContentLoaded', function() { | ||
// 1) | // 1) Toggle-Link finden | ||
const | const navToggle = document.querySelector('#breadcrumbs .breadcrumb-nav-subpages'); | ||
if (! | if (!navToggle) { | ||
console.log('➔ Kein Breadcrumb-Toggle gefunden'); | |||
return; | |||
} | |||
// 2) | // 2) Menü-ID aus aria-controls ziehen und Menü-Element finden | ||
const | const menuId = navToggle.getAttribute('aria-controls'); | ||
if ( | const menuEl = menuId && document.getElementById(menuId); | ||
if (!menuEl) { | |||
console.log('➔ Kein Menü-Container mit ID "', menuId, '" gefunden'); | |||
return; | |||
} | |||
// 3) | // 3) Alle Unterseiten-Links im Menü suchen | ||
const links = Array.from(menuEl.querySelectorAll('a.dropdown-item')); | |||
if (links.length === 0) { | |||
console.log('➔ Keine Links mit .dropdown-item im Menü gefunden'); | |||
return; | |||
} | |||
// 4) Container und Liste bauen | |||
const box = document.createElement('div'); | const box = document.createElement('div'); | ||
box.className = 'subpages-box'; | box.className = 'subpages-box'; | ||
const ul = document.createElement('ul'); | const ul = document.createElement('ul'); | ||
ul.className = 'subpages-list'; | ul.className = 'subpages-list'; | ||
links.forEach(origLink => { | |||
const li = document.createElement('li'); | const li = document.createElement('li'); | ||
const a = origLink.cloneNode(true); | |||
const a = | |||
li.appendChild(a); | li.appendChild(a); | ||
ul.appendChild(li); | ul.appendChild(li); | ||
Zeile 125: | Zeile 138: | ||
box.appendChild(ul); | box.appendChild(ul); | ||
// | // 5) Unterhalb der Breadcrumbs einfügen | ||
const breadcrumbContainer = document.getElementById('breadcrumbs'); | |||
const | if (breadcrumbContainer) { | ||
breadcrumbContainer.insertAdjacentElement('afterend', box); | |||
console.log('➔ Subpages-Box erfolgreich eingefügt'); | |||
} else { | |||
console.log('➔ Kein #breadcrumbs-Container zum Einfügen gefunden'); | |||
} | } | ||
}); | }); |
Version vom 12. Juni 2025, 06:41 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/**
* Entfernt das Wort „Fortsetzung“ aus allen SMW-Spalten-Headern (div.smw-column-header).
* Leg die Datei MediaWiki:Common.js (oder Discovery.js) an bzw. bearbeite sie:
*
* 1. Gehe als Admin auf Special:Edit/MediaWiki:Common.js
* 2. Füge diesen Code ans Ende ein und speichere.
* 3. Leere den Browser-Cache (STRG + F5), damit das neue JS geladen wird.
*/
mw.loader.using(['jquery'], function () {
$(document).ready(function () {
$('.smw-column-header').each(function () {
// aktuellen HTML-Inhalt holen
var html = $(this).html();
// "Fortsetzung" entfernen, Leerzeichen ggf. bereinigen
var newHtml = html.replace(/Fortsetzung/g, '').trim();
// falls nach dem Entfernen gar kein Text übrig ist, komplette Header-Box ausblenden:
if (newHtml === '') {
$(this).hide();
} else {
// ansonsten nur den Text überschreiben, sodass z. B. "B Fortsetzung" → "B" wird
$(this).html(newHtml);
}
});
$(function () {
$('<style>')
.prop('type', 'text/css')
.html(
'.breadcrumb-item { font-size: 17px !important; }' +
'.breadcrumb-nav { border-bottom: 2px solid #85bc20!important; margin-bottom: 20px !important; }'
)
.appendTo('head');
});
});
});
$(function() {
// 1) Klick merken
$('body').on('click', 'a.mws-tree-item-label', function() {
try {
window.name = JSON.stringify({ lastNav: this.getAttribute('href') });
} catch (e) {}
});
// 2) Polling & Aufklappen + Inline‐Styling
var attempts = 0,
interval = setInterval(function() {
attempts++;
var data = {};
try {
data = JSON.parse(window.name || '{}');
} catch (e) {}
var last = data.lastNav;
if (!last || attempts > 10) {
clearInterval(interval);
return;
}
var $link = $('a.mws-tree-item-label[href="' + last + '"]');
if ($link.length) {
clearInterval(interval);
// Zweige aufklappen
$link.parents('li.mws-tree-item').each(function() {
var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed');
if ($exp.length) {
$exp.trigger('click');
}
});
// Inline‐Styles setzen
$link.css({
'background-color': '#eef',
'font-weight': 'bold',
'color': '#000',
'border-left': '3px solid #98A7C4',
'padding-left': '0.5em'
});
// optional scrollen
$('html, body').scrollTop($link.offset().top - 80);
}
}, 300);
});
$(function(){
// In allen Category-Ausgaben: jede LI, die einen <a class="new"> enthält, entfernen
$('.smw-columnlist-container a.new').each(function(){
$(this).closest('li').remove();
});
});
$(function(){
// 1. Rote Links raus (wie gehabt)
$('.smw-columnlist-container a.new').each(function(){
$(this).closest('li').remove();
});
// 2. Jetzt jede Buchstaben-Überschrift entfernen, deren Liste leer ist
$('.smw-column-header').each(function(){
var $header = $(this),
$ul = $header.next('ul');
if ($ul.length && $ul.children('li').length === 0) {
$ul.remove();
$header.remove();
}
});
});
document.addEventListener('DOMContentLoaded', function() {
// 1) Toggle-Link finden
const navToggle = document.querySelector('#breadcrumbs .breadcrumb-nav-subpages');
if (!navToggle) {
console.log('➔ Kein Breadcrumb-Toggle gefunden');
return;
}
// 2) Menü-ID aus aria-controls ziehen und Menü-Element finden
const menuId = navToggle.getAttribute('aria-controls');
const menuEl = menuId && document.getElementById(menuId);
if (!menuEl) {
console.log('➔ Kein Menü-Container mit ID "', menuId, '" gefunden');
return;
}
// 3) Alle Unterseiten-Links im Menü suchen
const links = Array.from(menuEl.querySelectorAll('a.dropdown-item'));
if (links.length === 0) {
console.log('➔ Keine Links mit .dropdown-item im Menü gefunden');
return;
}
// 4) Container und Liste bauen
const box = document.createElement('div');
box.className = 'subpages-box';
const ul = document.createElement('ul');
ul.className = 'subpages-list';
links.forEach(origLink => {
const li = document.createElement('li');
const a = origLink.cloneNode(true);
li.appendChild(a);
ul.appendChild(li);
});
box.appendChild(ul);
// 5) Unterhalb der Breadcrumbs einfügen
const breadcrumbContainer = document.getElementById('breadcrumbs');
if (breadcrumbContainer) {
breadcrumbContainer.insertAdjacentElement('afterend', box);
console.log('➔ Subpages-Box erfolgreich eingefügt');
} else {
console.log('➔ Kein #breadcrumbs-Container zum Einfügen gefunden');
}
});