repaired Modal-Window of DTC-Table in WebUI
This commit is contained in:
		| @@ -81,7 +81,8 @@ function getDescriptionForDTCNumber(number, callback) { | ||||
|   fetch(jsonFilePath) | ||||
|     .then((response) => response.json()) | ||||
|     .then((data) => { | ||||
|       const foundEntry = data.find((entry) => entry.num === number); | ||||
|       const dtcList = data.dtc_table_data; | ||||
|       const foundEntry = dtcList.find((entry) => entry.num === number); | ||||
|  | ||||
|       if (foundEntry) { | ||||
|         const description = foundEntry.description; | ||||
| @@ -102,6 +103,32 @@ function getDescriptionForDTCNumber(number, callback) { | ||||
|     }); | ||||
| } | ||||
|  | ||||
| function showDTCModal(event) { | ||||
|   var dtc = parseInt(event.currentTarget.getAttribute("data-dtc")); | ||||
|   var debugval = event.currentTarget.getAttribute("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"); | ||||
| } | ||||
|  | ||||
| function fillDTCTable(dtcArray) { | ||||
|   // Referenz auf das Tabellen-Element | ||||
|   var table = document.getElementById("dtc_table"); | ||||
| @@ -176,6 +203,7 @@ function fillDTCTable(dtcArray) { | ||||
|  | ||||
|     row.setAttribute("data-dtc", dtcInfo[1]); | ||||
|     row.setAttribute("data-debugval", dtcInfo[4]); | ||||
|     row.addEventListener("click", showDTCModal); | ||||
|  | ||||
|     // Aktivität | ||||
|     var activityCell = row.insertCell(3); | ||||
|   | ||||
| @@ -10,28 +10,5 @@ document | ||||
|     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"); | ||||
| }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user