Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
//-------------------------------------------------------------
// Hilfreiche Funktionen und Konstanten
//-------------------------------------------------------------

/* Namespaces */
var NAMESPACE_ARTICLE            = "ns-0";
var NAMESPACE_ARTICLE_DISCUSSION = "ns-1";
var NAMESPACE_USER               = "ns-2";
var NAMESPACE_USER_DISCUSSION    = "ns-3";

/** 
 * Gibt true zurück, wenn die geladene Seite dem entsprechenden Namespace entspricht.
 */
function isNamespace(namespace) {
  return document.getElementsByTagName("body")[0].getAttribute("class").indexOf(namespace) >= 0;
}


//-------------------------------------------------------------
// Festes Menu an der Seite, das nicht mitscrollt und 
// nützliche Links dauerhaft anzeigt.
//-------------------------------------------------------------

/** Globale Variable des fixierten Menus. */
var fixedMenuContainer;

/**
 * Gibt die Zieladresse eines Links direkt unterhalb des durch die id bezeichneten 
 * Elements zurück. Existiert die id nicht, gibt die Funktion null zurück.
 */
function getLinkById(id) {
  var node = document.getElementById(id)
  if (node) {
    return node.firstChild.href;
  } else {
    return null;
  }
}

function createFixedMenuContainer() {
  var border = document.createElement("div");
  border.setAttribute("style","position: fixed; top: 40px; right: 0; border: 1px outset #444; border-right: 0; z-index: 100; background-color: #444; padding: 4px; -moz-opacity:0.8;");
  document.getElementById("globalWrapper").appendChild(border);

  var head = document.createElement("div");
  head.appendChild(document.createTextNode("Menu:"));
  head.setAttribute("style","color: white; font-weight: bold; font-variant: small-caps; padding: 0 0 4px 2px;");
  border.appendChild(head);

  fixedMenuContainer = document.createElement("div");
  fixedMenuContainer.setAttribute("class","fixedMenu");
  fixedMenuContainer.setAttribute("style","background-color: #000;");
  border.appendChild(fixedMenuContainer);
}

function addFixedMenuElement(element) {
  fixedMenuContainer.appendChild(element);
}

/**
 * Fügt dem fixierten Menu einen Button hinzu der das gleiche Ziel besitzt wie der 
 * Link unterhalb des durch die id gekennzeichneten Elements. Der Button hat die 
 * Aufschrift text und wird nur hinzugefügt, wenn die id existiert.
 */
function addFixedMenuButtonById(id, text) {
  var link = getLinkById(id);
  if (link) {
    var button = document.createElement("a");
    button.setAttribute("style", "display: block; font-family: monospace; padding: 2px 2px; background-color: #940; color: #fff; text-decoration: none;");
    button.setAttribute("href", link);
    button.appendChild(document.createTextNode(text));
    addFixedMenuElement(button);
  }
}

function addSeparator() {
  var sep = document.createElement("div");
  sep.setAttribute("style", "height: 2px; background-color: #fff;");
  addFixedMenuElement(sep);
}

/**
 * Baut ein kleines fest positioniertes Menu zusammen, welches verschiedene 
 * nützliche Links enthält.
 */
function buildFixedMenu() {
  createFixedMenuContainer();
  addFixedMenuButtonById("pt-watchlist", "‣ Beobachtungsliste");
  
  // Wechsel zwischen Artikel- und Diskussionsseite
  if (isNamespace(NAMESPACE_ARTICLE) || 
      isNamespace(NAMESPACE_ARTICLE_DISCUSSION) || 
      isNamespace(NAMESPACE_USER) || 
      isNamespace(NAMESPACE_USER_DISCUSSION)) {
    addSeparator();
    addFixedMenuButtonById("ca-history", "‣ Versionen");
  }
  addFixedMenuButtonById("ca-addsection", "+ Neuen Beitrag hinzufügen");
  if (isNamespace(NAMESPACE_ARTICLE) || isNamespace(NAMESPACE_USER)) {
    addFixedMenuButtonById("ca-talk", "‣ zur Diskussion");
  }
  if (isNamespace(NAMESPACE_ARTICLE_DISCUSSION) || isNamespace(NAMESPACE_USER_DISCUSSION)) {
    addFixedMenuButtonById("ca-nstab-main", "‣ zum Artikel");
  }

}

// addOnloadHook(buildFixedMenu);

//----------------------------------------------------------------
// Link zum hinzufügen neuer Beiträge am Ende der Seite.
//----------------------------------------------------------------

function appendAddSectionLinkAtEnd() {
  var linkAddress = getLinkById("ca-addsection");
  if (linkAddress) {
    var contentElement = document.getElementById("bodyContent");
    var categoryElement = document.getElementById("catlinks");
    var button = document.createElement("a");
    var text = "Einen Kommentar zu dieser Diskussion hinzufügen";
    button.setAttribute("style", "display: block; text-align: right;");
    button.setAttribute("href", linkAddress);
    button.appendChild(document.createTextNode(text));
    if (categoryElement) { // Einfügen vor den Kategorien, falls vorhanden
      contentElement.insertBefore(button, categoryElement);
    } else { // Einfügen am Ende des Inhalts, falls keine Kategorien vorhanden
      contentElement.appendChild(button);
    }
  }
}

addOnloadHook(appendAddSectionLinkAtEnd);