Sha256: 1004388c51b53888a92cc9444c14365be8af65183a79b1cf94fb2327224f0ea6

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

document.addEventListener("DOMContentLoaded", () => {
  const menu = document.getElementById("config-selector");

  showCurrentConfiguration = () => {
    const selectedId = menu.options[menu.selectedIndex].value;
    const hash = selectedId.replace(/^config-/, "");

    document.querySelectorAll(".ultra-settings-configuration").forEach((configuration) => {
      if (configuration.id === selectedId) {
        configuration.style.display = "block";
        window.location.hash = hash;
      } else {
        configuration.style.display = "none";
      }
    });
  }

  menu.addEventListener("change", showCurrentConfiguration);

  const setCurrentSelection =  () => {
    const hash = window.location.hash.replace(/^#/, "");
    const selectedId = `config-${hash}`;
    for (const option of menu.options) {
      if (option.value === selectedId) {
        option.selected = true;
        break;
      }
    }

    showCurrentConfiguration();
  }

  window.addEventListener('hashchange', setCurrentSelection);


  if (window.location.hash) {
    setCurrentSelection()
  }

  showCurrentConfiguration();
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ultra_settings-2.4.1 app/application.js
ultra_settings-2.4.0 app/application.js
ultra_settings-2.3.0 app/application.js
ultra_settings-2.2.0 app/application.js
ultra_settings-2.1.0 app/application.js
ultra_settings-2.0.0 app/application.js
ultra_settings-1.1.2 app/application.js
ultra_settings-1.1.1 app/application.js