MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Populus DE
Zur Navigation springenZur Suche springen
Thk (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Thk (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
(18 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
(function () { |
|||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ |
|||
const className = "selected"; |
|||
thkSelectNavListener = (e) => { |
|||
console.log("hash changed"); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
var thkOnHashChangedListener = function(){ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
window.addEventListener( |
|||
⚫ | |||
"hashchange", |
|||
⚫ | |||
thkSelectNavListener, |
|||
false |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
window.addEventListener("hashchange", thkOnHashChangedListener); |
|||
var firstA = document.querySelector('#toc a:first-of-type'); |
|||
if (firstA !== null) { |
|||
firstA.classList.add(className); |
|||
} |
|||
// See Populus:QuizEditIntro |
|||
var newQuizLink = document.querySelector('a[href="http://neuequizfragedummy"]'); |
|||
if (newQuizLink !== null) { |
|||
newQuizLink.setAttribute('href', |
|||
window.location.href.replace(/(?<=title=Quiz:)\d+/, Math.floor(Math.random() * 1000000000)) |
|||
⚫ | |||
} |
|||
})(); |
Aktuelle Version vom 20. Juli 2023, 09:59 Uhr
(function () { const className = "selected"; var thkOnHashChangedListener = function(){ var prev = document.querySelector('#toc a.' + className); if (prev !== null) { prev.classList.remove(className); } var curr = document.querySelector('#toc a[href="' + window.location.hash + '"]'); if (curr !== null) { curr.classList.add(className); } }; window.addEventListener("hashchange", thkOnHashChangedListener); var firstA = document.querySelector('#toc a:first-of-type'); if (firstA !== null) { firstA.classList.add(className); } // See Populus:QuizEditIntro var newQuizLink = document.querySelector('a[href="http://neuequizfragedummy"]'); if (newQuizLink !== null) { newQuizLink.setAttribute('href', window.location.href.replace(/(?<=title=Quiz:)\d+/, Math.floor(Math.random() * 1000000000)) ); } })();