INNER CODE UNIT · JavaScript

initSlider

LeyckerS/moondownloader · web/app.js:373

function initSlider(id, outId, suffix = "") {
  const input = $("#" + id);
  const out = $("#" + outId);
  const label = input.closest(".slider");
  const rec = input.dataset.rec ? Number(input.dataset.rec) : null;

  const paint = () => {
    const min = Number(input.min), max = Number(input.max);
    const pct = ((Number(input.value) - min) / (max - min)) * 100;
    label.style.setProperty("--pct", pct.toFixed(2) + "%");
    out.textContent = input.value + suffix;
    if (rec !== null) {
      label.classList.add("has-rec");
      label.style.setProperty("--rec", (((rec - min) / (max - min)) * 100).toFixed(2) + "%");
    }
  };
  input.addEventListener("input", () => { paint(); scheduleSettingsSave(); });
  paint();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…