// environmental.el -- Environmental page efficiency calculator slider.
// Compiled with: elc --target=js --bundle --minify --obfuscate

fn main() -> Void {
    native_js("(function() {
  var slider    = document.getElementById('calc-slider');
  var spendEl   = document.getElementById('calc-spend');
  var savingsEl = document.getElementById('calc-savings');
  if (!slider) return;
  function update() {
    var monthly = parseInt(slider.value, 10);
    var annual  = Math.round(monthly * 0.35 * 12);
    if (spendEl)   spendEl.textContent   = '$' + monthly;
    if (savingsEl) savingsEl.textContent = '$' + annual;
  }
  slider.addEventListener('input', update);
  update();
})()")
}
