Weitere Optionen
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 10: | Zeile 10: | ||
}); | }); | ||
// | //Anker aufklappen und Spoiler aufklappen bei Suchen | ||
$(document).ready(function() { | $(document).ready(function() { | ||
setTimeout(function() { | setTimeout(function() { | ||
var hash = window.location.hash; | var hash = window.location.hash; | ||
var ref = document.referrer; | |||
var searchMatch = ref.match(/[?&]search=([^&]+)/); | |||
var target = document.getElementById(hash.substring(1)); | // Anker-Link: entsprechenden Abschnitt aufklappen | ||
if (hash) { | |||
var target = document.getElementById(hash.substring(1)); | |||
if (target) { | |||
var h2 = target.closest('h2') || | |||
(target.tagName === 'H2' ? target : null); | |||
if (!h2) { | |||
var section = target.closest('.citizen-section'); | |||
if (section) h2 = section.previousElementSibling; | |||
} | |||
if (h2 && h2.classList.contains('citizen-section-heading')) { | |||
h2 = section. | var indicator = h2.querySelector('.citizen-section-indicator'); | ||
if (indicator) indicator.click(); | |||
setTimeout(function() { target.scrollIntoView(); }, 100); | |||
} | |||
} | } | ||
} | } | ||
// | // Suche: ersten Abschnitt + verschachtelte Spoiler aufklappen | ||
if (!searchMatch) return; | if (!searchMatch) return; | ||
var term = decodeURIComponent(searchMatch[1]).toLowerCase(); | var term = decodeURIComponent(searchMatch[1]).toLowerCase(); | ||
var sections = document.querySelectorAll('.citizen-section'); | var sections = document.querySelectorAll('.citizen-section'); | ||
for (var i = 0; i < sections.length; i++) { | for (var i = 0; i < sections.length; i++) { | ||
if (sections[i].textContent.toLowerCase().includes(term)) { | if (sections[i].textContent.toLowerCase().includes(term)) { | ||
var h2 = sections[i].previousElementSibling; | var h2 = sections[i].previousElementSibling; | ||
if (h2 && h2.classList.contains('citizen-section-heading')) { | if (h2 && h2.classList.contains('citizen-section-heading')) { | ||
var indicator = h2.querySelector('.citizen-section-indicator'); | var indicator = h2.querySelector('.citizen-section-indicator'); | ||
if (indicator) | if (indicator) indicator.click(); | ||
} | } | ||
// Verschachtelte mw-collapsible aufklappen die den Begriff enthalten | |||
setTimeout(function(sec) { | |||
var collapsibles = sec.querySelectorAll('.mw-collapsible.mw-collapsed'); | |||
collapsibles.forEach(function(col) { | |||
if (col.textContent.toLowerCase().includes(term)) { | |||
var toggle = col.querySelector('.mw-collapsible-toggle'); | |||
if (toggle) toggle.click(); | |||
} | |||
}); | |||
h2.scrollIntoView(); | |||
}, 200, sections[i]); | |||
break; | break; | ||
} | } | ||
| Zeile 72: | Zeile 65: | ||
}, 500); | }, 500); | ||
}); | }); | ||
//Hauptseite Grid Ausrichtung | //Hauptseite Grid Ausrichtung | ||
$(document).ready(function() { | $(document).ready(function() { | ||
Version vom 18. August 2026, 17:50 Uhr
mw.hook('wikipage.content').add(function($content) {
const headings = document.querySelectorAll('.citizen-section-heading');
if (headings.length === 0) return;
const sections = document.querySelectorAll('.citizen-section');
sections.forEach(function(section, index) {
if (index === 0) return; // Einleitungstext überspringen
section.hidden = 'until-found';
});
});
//Anker aufklappen und Spoiler aufklappen bei Suchen
$(document).ready(function() {
setTimeout(function() {
var hash = window.location.hash;
var ref = document.referrer;
var searchMatch = ref.match(/[?&]search=([^&]+)/);
// Anker-Link: entsprechenden Abschnitt aufklappen
if (hash) {
var target = document.getElementById(hash.substring(1));
if (target) {
var h2 = target.closest('h2') ||
(target.tagName === 'H2' ? target : null);
if (!h2) {
var section = target.closest('.citizen-section');
if (section) h2 = section.previousElementSibling;
}
if (h2 && h2.classList.contains('citizen-section-heading')) {
var indicator = h2.querySelector('.citizen-section-indicator');
if (indicator) indicator.click();
setTimeout(function() { target.scrollIntoView(); }, 100);
}
}
}
// Suche: ersten Abschnitt + verschachtelte Spoiler aufklappen
if (!searchMatch) return;
var term = decodeURIComponent(searchMatch[1]).toLowerCase();
var sections = document.querySelectorAll('.citizen-section');
for (var i = 0; i < sections.length; i++) {
if (sections[i].textContent.toLowerCase().includes(term)) {
var h2 = sections[i].previousElementSibling;
if (h2 && h2.classList.contains('citizen-section-heading')) {
var indicator = h2.querySelector('.citizen-section-indicator');
if (indicator) indicator.click();
}
// Verschachtelte mw-collapsible aufklappen die den Begriff enthalten
setTimeout(function(sec) {
var collapsibles = sec.querySelectorAll('.mw-collapsible.mw-collapsed');
collapsibles.forEach(function(col) {
if (col.textContent.toLowerCase().includes(term)) {
var toggle = col.querySelector('.mw-collapsible-toggle');
if (toggle) toggle.click();
}
});
h2.scrollIntoView();
}, 200, sections[i]);
break;
}
}
}, 500);
});
//Hauptseite Grid Ausrichtung
$(document).ready(function() {
setTimeout(function() {
document.querySelectorAll('.wiki-overview-grid').forEach(function(grid) {
var cols = grid.querySelectorAll('.wiki-overview-col');
var firstHeaders = [];
cols.forEach(function(col) {
var h = col.querySelector('h4');
if (h) firstHeaders.push(h);
});
// Natürliche Höhen vor minHeight messen
var naturalHeights = firstHeaders.map(function(h) { return h.offsetHeight; });
var maxH = Math.max.apply(null, naturalHeights);
var minH = Math.min.apply(null, naturalHeights);
firstHeaders.forEach(function(h) {
h.style.minHeight = maxH + 'px';
h.style.display = 'flex';
h.style.alignItems = 'flex-end';
h.style.justifyContent = 'center';
});
// Grid um den Leerraum nach oben verschieben
if (maxH > minH) {
grid.style.marginTop = '-' + (maxH - minH) + 'px';
}
});
}, 300);
});
// Ausklappen des ersten Abschnitts bei fehlendem Einleitungstext
$(document).ready(function() {
setTimeout(function() {
var content = document.querySelector('.mw-parser-output');
if (!content) return;
var children = Array.from(content.children);
// Prüfen ob die erste Section Text enthält (= Einleitungstext)
var firstSection = children.find(function(el) {
return el.classList.contains('citizen-section');
});
if (firstSection && firstSection.textContent.trim() !== '') return;
// Erste H2 aufklappen
var firstH2 = children.find(function(el) {
return el.tagName === 'H2' && el.classList.contains('citizen-section-heading');
});
if (firstH2) {
var indicator = firstH2.querySelector('.citizen-section-indicator');
if (indicator) indicator.click();
}
}, 500);
});
// Social Icons in Sidebar ersetzen
$(function() {
$('#n-sidebar-label-contactus').closest('ul').addClass('sgpggb-external-menu');
var icons = {
'n-Discord': 'fab fa-discord',
'n-Facebook': 'fab fa-facebook-f',
'n-Instagram': 'fab fa-instagram',
'n-X': 'fab fa-x-twitter',
'n-YouTube': 'fab fa-youtube',
'n-Twitch': 'fab fa-twitch',
'n-E-Mail': 'fas fa-envelope',
'n-Support-us': 'fas fa-heart'
};
$.each(icons, function(id, cls) {
$('#' + id + ' a').html('<i class="' + cls + '"></i>');
});
});
var tagline = document.getElementById('footer-tagline');
if (tagline) {
var original = tagline.innerHTML;
var shown = localStorage.getItem('footer_gender_dismissed');
if (!shown) {
tagline.innerHTML = 'Aus Gründen der besseren Lesbarkeit wird auf diesem Wiki überwiegend das generische Maskulinum verwendet. Es sind stets alle Geschlechter gleichermaßen gemeint. <button id="footer-gender-dismiss" style="background:none; border:none; cursor:pointer; font-size:0.9em; opacity:0.6; padding:0 4px;" title="Verstanden">✕</button>';
document.getElementById('footer-gender-dismiss').addEventListener('click', function() {
tagline.innerHTML = original;
localStorage.setItem('footer_gender_dismissed', '1');
});
}
}
// mw-anon Klasse für nicht angemeldete User setzen
if ( !mw.config.get('wgUserId') ) {
document.documentElement.classList.add('mw-anon');
}