Mitarbeit willkommen! Bitte schau unter Hilfe:Benutzerkonto oder informiere Dich über Populus.Wiki.

MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Populus DE
Zur Navigation springenZur Suche springen
Keine Bearbeitungszusammenfassung
Markierung: Rückgängigmachung
Keine Bearbeitungszusammenfassung
 
(14 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
(function () {
console.log(window);


const className = "selected";
window.addEventListener(
"hashchange",
e => {
console.log("hash changed");
var prev = document.querySelector('#toc a.selected');
if (prev !== null) {
prev.classList.remove('selected');
}


var thkOnHashChangedListener = function(){
var curr = document.querySelector('#toc a[href="#' + window.location.hash + '"]');
var prev = document.querySelector('#toc a.' + className);
if (curr !== null) {

curr.classList.add('selected');
}
if (prev !== null) {
prev.classList.remove(className);
},
false
}

);
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))
);
}

})();

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))
  );
}

})();