Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 34: | Zeile 34: | ||
}); | }); | ||
}); | }); | ||
$(function() { | |||
console.log('▶ Sidebar-Script gestartet'); | |||
$('body').on('click', 'a.mws-tree-item-label', function() { | $('body').on('click', 'a.mws-tree-item-label', function() { | ||
var href = this.href; | |||
console.log('🖱 Klick auf:', href); | |||
try { | try { | ||
window.name = JSON.stringify({ lastNav: | window.name = JSON.stringify({ lastNav: href }); | ||
} catch (e) { | console.log(' → window.name gesetzt'); | ||
} catch (e) { | |||
console.error(' ! Fehler beim Setzen von window.name', e); | |||
} | |||
}); | }); | ||
var lastHref; | |||
var lastHref | |||
try { | try { | ||
var data = JSON.parse(window.name || '{}'); | var data = JSON.parse(window.name || '{}'); | ||
lastHref = data.lastNav; | lastHref = data.lastNav; | ||
} catch (e) {} | console.log('► Aus window.name gelesen:', lastHref); | ||
} catch (e) { | |||
console.error(' ! JSON parse error', e); | |||
} | |||
if (!lastHref) { | if (!lastHref) { | ||
console.log(' – kein lastHref, breche ab'); | |||
return; | return; | ||
} | } | ||
var attempts = 0; | var attempts = 0; | ||
var | var interval = setInterval(function() { | ||
attempts++; | attempts++; | ||
console.log('… Versuch', attempts); | |||
var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]'); | var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]'); | ||
if ( | console.log(' → gefunden Links:', $link.length); | ||
clearInterval( | if ($link.length) { | ||
clearInterval(interval); | |||
console.log(' ✓ Link gefunden, klappe auf'); | |||
$link.parents('li.mws-tree-item').each(function(i) { | |||
console.log(' – Parent #'+i, this.id); | |||
var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed'); | var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed'); | ||
console.log(' expander gefunden:', $exp.length); | |||
if ($exp.length) { | if ($exp.length) { | ||
$exp.trigger('click'); | $exp.trigger('click'); | ||
console.log(' trigger click ausgeführt'); | |||
} | |||
var $sub = $(this).children('ul.mws-tree-item-children'); | |||
console.log(' submenu gefunden:', $sub.length); | |||
if ($sub.length) { | |||
$sub.css('display','block'); | |||
console.log(' submenu sichtbar gemacht'); | |||
} | } | ||
}); | }); | ||
console.log(' → Scroll zum Link'); | |||
$('html, body').scrollTop($link.offset().top - 80); | $('html, body').scrollTop($link.offset().top - 80); | ||
clearInterval( | } else if (attempts > 10) { | ||
clearInterval(interval); | |||
console.warn(' ! maximal Versuche erreicht, breche ab'); | |||
} | } | ||
}, 300); | }, 300); | ||
}); | }); |
Version vom 11. Juni 2025, 20:15 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() {
console.log('▶ Sidebar-Script gestartet');
$('body').on('click', 'a.mws-tree-item-label', function() {
var href = this.href;
console.log('🖱 Klick auf:', href);
try {
window.name = JSON.stringify({ lastNav: href });
console.log(' → window.name gesetzt');
} catch (e) {
console.error(' ! Fehler beim Setzen von window.name', e);
}
});
var lastHref;
try {
var data = JSON.parse(window.name || '{}');
lastHref = data.lastNav;
console.log('► Aus window.name gelesen:', lastHref);
} catch (e) {
console.error(' ! JSON parse error', e);
}
if (!lastHref) {
console.log(' – kein lastHref, breche ab');
return;
}
var attempts = 0;
var interval = setInterval(function() {
attempts++;
console.log('… Versuch', attempts);
var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]');
console.log(' → gefunden Links:', $link.length);
if ($link.length) {
clearInterval(interval);
console.log(' ✓ Link gefunden, klappe auf');
$link.parents('li.mws-tree-item').each(function(i) {
console.log(' – Parent #'+i, this.id);
var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed');
console.log(' expander gefunden:', $exp.length);
if ($exp.length) {
$exp.trigger('click');
console.log(' trigger click ausgeführt');
}
var $sub = $(this).children('ul.mws-tree-item-children');
console.log(' submenu gefunden:', $sub.length);
if ($sub.length) {
$sub.css('display','block');
console.log(' submenu sichtbar gemacht');
}
});
console.log(' → Scroll zum Link');
$('html, body').scrollTop($link.offset().top - 80);
} else if (attempts > 10) {
clearInterval(interval);
console.warn(' ! maximal Versuche erreicht, breche ab');
}
}, 300);
});