reworked DTC-Data handling
This commit is contained in:
23
Software/data_src/static/js/dtc_table.js
Normal file
23
Software/data_src/static/js/dtc_table.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const jsonFilePath = "static/dtc_table.json";
|
||||
|
||||
function getDescriptionForDTCNumber(number, callback) {
|
||||
fetch(jsonFilePath)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
const foundEntry = data.find((entry) => entry.num === number);
|
||||
|
||||
if (foundEntry) {
|
||||
const description = foundEntry.description;
|
||||
const title = foundEntry.title;
|
||||
callback(null, title, description);
|
||||
} else {
|
||||
// Wenn die Nummer nicht gefunden wurde, geben Sie einen Fehler zurück
|
||||
callback(`Beschreibung für Nummer ${number} nicht gefunden.`,null, null);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
// Im Fehlerfall geben Sie den Fehler zurück
|
||||
callback(error, null, null);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user