Zum Inhalt springen

MediaWiki:Common.js

Aus awm

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
/**
 * https://wiki.awm.infeo.at/index.php/Vorlage:Applikationsauswahl
 */

document.querySelectorAll('.infeo-application-selection').forEach(function (applicationSelection, i) {
  var awmDesktopInput = '<label> <input type="radio" name="application-' + i + '" value="awm-desktop"> awm desktop </label>';
  var awmWebInput = '<label> <input type="radio" name="application-' + i + '" value="awm-web"> awm web </label>';

  applicationSelection.innerHTML = '<fieldset> <legend>Inhalte anpassen für:</legend> ' + awmWebInput + awmDesktopInput + ' </fieldset>';

  applicationSelection.addEventListener('change', function (changeEvent) {
    var selectedApplication = changeEvent.target.value;

    // Wird eine Applikation ausgewählt, müssen sämtliche `.infeo-application-selection` mit der gleichen Auswahl
    // aktualisiert werden.

    document.querySelectorAll('.infeo-application-selection input').forEach(function (applicationSelectionInput) {
      if (applicationSelectionInput.value === selectedApplication) {
        applicationSelectionInput.click();
      }
    });

    // Die entsprechenden Inhalte anzeigen und für die ausgewählte Applikation irrelevanten Inhalte ausblenden.

    document.querySelectorAll('.infeo-application-selection-content').forEach(function (applicationSelectionContent) {
      if (applicationSelectionContent.dataset.for === selectedApplication) {
        applicationSelectionContent.style.display = 'block';
      } else {
        applicationSelectionContent.style.display = 'none';
      }
    });
  });
});

// Standardmäßig sollen die Inhalte für „awm web“ angezeigt werden.

document.querySelectorAll('.infeo-application-selection input[value="awm-web"]').forEach(function (applicationSelectionInput) {
  applicationSelectionInput.click();
});