File: index.js

package info (click to toggle)
accessible-pygments 0.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,076 kB
  • sloc: python: 1,451; sh: 48; javascript: 33; makefile: 3
file content (16 lines) | stat: -rw-r--r-- 602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Get the <select> element
const select = document.querySelector("select");

// Get the current theme
let currentTheme = select.value;

// Whenever user chooses a new option from the <select> dropdown, reload all the
// iframes on the page with examples from the new chosen theme
select.addEventListener("change", (event) => {
  const nextTheme = event.currentTarget.value;
  document.querySelectorAll("iframe").forEach((element) => {
    // Replace theme name in URL to load example from new theme
    element.src = element.src.replace(currentTheme, nextTheme);
  });
  currentTheme = nextTheme;
});