Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 100: | Zeile 100: | ||
}); | }); | ||
}); | }); | ||
(function() { | (function(){ | ||
let tries = 0; | let tries = 0; | ||
const maxTries = 10; | const maxTries = 10; | ||
const interval = 500; // ms | const interval = 500; // ms | ||
function attempt() { | |||
tries++; | tries++; | ||
console.log(`🔍 Versuch ${tries}/${maxTries}: suche Breadcrumb-Toggle …`); | console.log(`🔍 Versuch ${tries}/${maxTries}: suche Breadcrumb-Toggle …`); | ||
Zeile 112: | Zeile 112: | ||
const navToggle = document.querySelector('#breadcrumbs .breadcrumb-nav-subpages'); | const navToggle = document.querySelector('#breadcrumbs .breadcrumb-nav-subpages'); | ||
if (!navToggle) { | if (!navToggle) { | ||
if (tries < maxTries) | if (tries < maxTries) return setTimeout(attempt, interval); | ||
return console.warn('❌ Kein Breadcrumb-Toggle gefunden, breche ab.'); | |||
} | } | ||
// 2) Menü- | // 2) Menü-Container finden | ||
const menuId = navToggle.getAttribute('aria-controls'); | const menuId = navToggle.getAttribute('aria-controls'); | ||
if (!menuId) | if (!menuId) return console.error('❌ Toggle hat kein aria-controls-Attribut'); | ||
const menuEl = document.getElementById(menuId); | const menuEl = document.getElementById(menuId); | ||
if (!menuEl) | if (!menuEl) return console.error(`❌ Kein Menü-Container mit ID “${menuId}” gefunden`); | ||
// 3) | // 3) Links im Menü (zuerst .dropdown-item, sonst *alle* <a>) | ||
let links = Array.from(menuEl.querySelectorAll('a.dropdown-item')); | |||
if (links.length === 0) links = Array.from(menuEl.querySelectorAll('a')); | |||
if (links.length === 0) { | if (links.length === 0) { | ||
return console.warn('⚠️ Keine | if (tries < maxTries) return setTimeout(attempt, interval); | ||
return console.warn('⚠️ Keine Links im Menü gefunden, breche ab.'); | |||
} | } | ||
console.log(`✅ ${links.length} | console.log(`✅ ${links.length} Link(s) gefunden`); | ||
// 4) | // 4) Box & UL 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( | links.forEach(orig => { | ||
const li = document.createElement('li'); | const li = document.createElement('li'); | ||
li.appendChild(orig.cloneNode(true)); | |||
ul.appendChild(li); | ul.appendChild(li); | ||
}); | }); | ||
box.appendChild(ul); | box.appendChild(ul); | ||
// 5) Einfügen unter | // 5) Einfügen unter Breadcrumbs | ||
const bc = document.getElementById('breadcrumbs'); | const bc = document.getElementById('breadcrumbs'); | ||
bc.insertAdjacentElement('afterend', box); | bc.insertAdjacentElement('afterend', box); | ||
console.log('🎉 Subpages-Box erfolgreich eingefügt'); | console.log('🎉 Subpages-Box erfolgreich eingefügt'); | ||
} | } | ||
if (document.readyState === 'loading') { | if (document.readyState === 'loading') { | ||
document.addEventListener('DOMContentLoaded', attempt); | document.addEventListener('DOMContentLoaded', attempt); |
Version vom 12. Juni 2025, 06:49 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();
}
});
});
(function(){
let tries = 0;
const maxTries = 10;
const interval = 500; // ms
function attempt() {
tries++;
console.log(`🔍 Versuch ${tries}/${maxTries}: suche Breadcrumb-Toggle …`);
// 1) Toggle-Link finden
const navToggle = document.querySelector('#breadcrumbs .breadcrumb-nav-subpages');
if (!navToggle) {
if (tries < maxTries) return setTimeout(attempt, interval);
return console.warn('❌ Kein Breadcrumb-Toggle gefunden, breche ab.');
}
// 2) Menü-Container finden
const menuId = navToggle.getAttribute('aria-controls');
if (!menuId) return console.error('❌ Toggle hat kein aria-controls-Attribut');
const menuEl = document.getElementById(menuId);
if (!menuEl) return console.error(`❌ Kein Menü-Container mit ID “${menuId}” gefunden`);
// 3) Links im Menü (zuerst .dropdown-item, sonst *alle* <a>)
let links = Array.from(menuEl.querySelectorAll('a.dropdown-item'));
if (links.length === 0) links = Array.from(menuEl.querySelectorAll('a'));
if (links.length === 0) {
if (tries < maxTries) return setTimeout(attempt, interval);
return console.warn('⚠️ Keine Links im Menü gefunden, breche ab.');
}
console.log(`✅ ${links.length} Link(s) gefunden`);
// 4) Box & UL bauen
const box = document.createElement('div');
box.className = 'subpages-box';
const ul = document.createElement('ul');
ul.className = 'subpages-list';
links.forEach(orig => {
const li = document.createElement('li');
li.appendChild(orig.cloneNode(true));
ul.appendChild(li);
});
box.appendChild(ul);
// 5) Einfügen unter Breadcrumbs
const bc = document.getElementById('breadcrumbs');
bc.insertAdjacentElement('afterend', box);
console.log('🎉 Subpages-Box erfolgreich eingefügt');
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', attempt);
} else {
attempt();
}
})();