Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 34: | Zeile 34: | ||
}); | }); | ||
}); | }); | ||
/* MediaWiki:Common.js */ | |||
// Speichert und klappt in der Sidebar den zuletzt angeklickten Punkt auf | |||
$(function() { | $(function() { | ||
// 1) Klick-Handler: immer den RELATIVEN href speichern | |||
$('body').on('click', 'a.mws-tree-item-label', function() { | $('body').on('click', 'a.mws-tree-item-label', function() { | ||
try { | try { | ||
window.name = JSON.stringify({ lastNav: | // .getAttribute('href') liefert z.B. "/wiki/Arbeitsorganisation:Arbeitsmittel/Ausleihe" | ||
var relHref = this.getAttribute('href'); | |||
window.name = JSON.stringify({ lastNav: relHref }); | |||
} catch (e) { | } catch (e) { | ||
console.error(' | console.error('Speichern fehlgeschlagen', e); | ||
} | } | ||
}); | }); | ||
var lastHref; | // 2) Beim Laden: aus window.name auslesen | ||
var lastHref = null; | |||
try { | try { | ||
var data = JSON.parse(window.name || '{}'); | var data = JSON.parse(window.name || '{}'); | ||
lastHref = data.lastNav; | lastHref = data.lastNav; | ||
} catch (e) { | } catch (e) { | ||
return; | |||
} | } | ||
if (!lastHref) { | if (!lastHref) { | ||
return; | return; | ||
} | } | ||
// 3) Polling, bis der Link im DOM steht, dann aufklappen | |||
var attempts = 0; | var attempts = 0; | ||
var interval = setInterval(function() { | var interval = setInterval(function() { | ||
attempts++; | attempts++; | ||
// Selektiere jetzt mit RELATIVEM href | |||
var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]'); | var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]'); | ||
if ($link.length) { | if ($link.length) { | ||
clearInterval(interval); | clearInterval(interval); | ||
$link.parents('li.mws-tree-item').each(function( | // Rekursive Expansion aller Eltern-<li> | ||
$link.parents('li.mws-tree-item').each(function() { | |||
var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed') | var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed'), | ||
$sub = $(this).children('ul.mws-tree-item-children'); | |||
if ($exp.length) { | if ($exp.length) { | ||
$exp. | $exp | ||
.removeClass('collapsed') | |||
.addClass('expanded') | |||
.attr('aria-expanded', 'true'); | |||
} | } | ||
if ($sub.length) { | if ($sub.length) { | ||
$sub.css('display','block'); | $sub.css('display','block'); | ||
} | } | ||
}); | }); | ||
// Zum Link scrollen | |||
$('html, body').scrollTop($link.offset().top - 80); | $('html, body').scrollTop($link.offset().top - 80); | ||
} else if (attempts > 10) { | } else if (attempts > 10) { | ||
clearInterval(interval); | clearInterval(interval); | ||
console.warn(' | console.warn('Kein Link gefunden nach 10 Versuchen:', lastHref); | ||
} | } | ||
}, 300); | }, 300); | ||
}); | }); |
Version vom 11. Juni 2025, 20:22 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');
});
});
});
/* MediaWiki:Common.js */
// Speichert und klappt in der Sidebar den zuletzt angeklickten Punkt auf
$(function() {
// 1) Klick-Handler: immer den RELATIVEN href speichern
$('body').on('click', 'a.mws-tree-item-label', function() {
try {
// .getAttribute('href') liefert z.B. "/wiki/Arbeitsorganisation:Arbeitsmittel/Ausleihe"
var relHref = this.getAttribute('href');
window.name = JSON.stringify({ lastNav: relHref });
} catch (e) {
console.error('Speichern fehlgeschlagen', e);
}
});
// 2) Beim Laden: aus window.name auslesen
var lastHref = null;
try {
var data = JSON.parse(window.name || '{}');
lastHref = data.lastNav;
} catch (e) {
return;
}
if (!lastHref) {
return;
}
// 3) Polling, bis der Link im DOM steht, dann aufklappen
var attempts = 0;
var interval = setInterval(function() {
attempts++;
// Selektiere jetzt mit RELATIVEM href
var $link = $('a.mws-tree-item-label[href="' + lastHref + '"]');
if ($link.length) {
clearInterval(interval);
// Rekursive Expansion aller Eltern-<li>
$link.parents('li.mws-tree-item').each(function() {
var $exp = $(this).children('div').children('a.mws-tree-expander.collapsed'),
$sub = $(this).children('ul.mws-tree-item-children');
if ($exp.length) {
$exp
.removeClass('collapsed')
.addClass('expanded')
.attr('aria-expanded', 'true');
}
if ($sub.length) {
$sub.css('display','block');
}
});
// Zum Link scrollen
$('html, body').scrollTop($link.offset().top - 80);
} else if (attempts > 10) {
clearInterval(interval);
console.warn('Kein Link gefunden nach 10 Versuchen:', lastHref);
}
}, 300);
});