You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
document.addEventListener('DOMContentLoaded', () => { |
|
// Charger les valeurs actuelles |
|
fetch('conf.json') |
|
.then(r => r.json()) |
|
.then(conf => { |
|
for (const key in conf) { |
|
const el = document.getElementById(key.toLowerCase()); |
|
if (el) el.value = conf[key]; |
|
} |
|
}); |
|
|
|
// Sauvegarder à l'appui sur VALIDER |
|
document.getElementById('validate').onclick = function() { |
|
const data = {}; |
|
['ssid','password','kp','ki','kd'].forEach(key => { |
|
const el = document.getElementById(key); |
|
if (el) data[key] = el.value; |
|
}); |
|
fetch('/save_config', { |
|
method: 'POST', |
|
headers: {'Content-Type': 'application/json'}, |
|
body: JSON.stringify(data) |
|
}).then(r => { |
|
if (r.ok) alert('Configuration enregistrée !'); |
|
else alert('Erreur lors de l\'enregistrement'); |
|
}); |
|
}; |
|
}); |
|
fetch('conf.json') |
|
.then(r => r.json()) |
|
.then(conf => { |
|
for (const key in conf) { |
|
const el = document.getElementById(key); |
|
if (el) el.value = conf[key]; |
|
} |
|
}); |