$(".navbar-nav>li>a").on("click", function () {
  $(".navbar-collapse").collapse("hide");
});

document
  .querySelector(".custom-file-input")
  .addEventListener("change", function (e) {
    var fileName = document.getElementById("fw-update-file").files[0].name;
    var nextSibling = e.target.nextElementSibling;
    nextSibling.innerText = fileName;
  });

$("table").on("click", "tr[data-dtc]", function () {
  var dtc = $(this).data("dtc");
  var debugval = $(this).data("debugval");
  var modal = $("#dtcModal");

  getDescriptionForDTCNumber(dtc, function (error, title, description) {
    if (error) {
      console.error("Fehler beim Abrufen der Beschreibung:", error);
      modal.find(".modal-title").text("Fehler");
      modal
        .find(".dtc-desc")
        .text("DTC-Beschreibung konnte nicht geladen werden");
    } else {
      modal.find(".modal-title").text(title);
      modal.find(".dtc-desc").text(description);
      if (debugval > 0) {
        modal.find(".dtc-debugval").text("Debugvalue: " + debugval);
      } else {
        modal.find(".dtc-debugval").remove();
      }
    }
  });
  // Modal anzeigen
  modal.modal("show");
});
