khoj/views/scripts/config.js
2021-11-27 14:39:05 -05:00

27 lines
No EOL
865 B
JavaScript

var showConfig = document.getElementById("show-config");
showConfig.addEventListener("click", () => {
var configForm = document.getElementById("config-form");
fetch("/config")
.then(response => response.json())
.then(data => {
configForm.style.display = "block";
processChildren(configForm, data);
});
});
function processChildren(element, data) {
for (let key in data) {
var child = document.createElement("div");
child.id = key;
child.className = "config-element";
child.appendChild(document.createTextNode(key + ": "));
if (data[key] === Object(data[key])) {
console.log(key, data[key]);
processChildren(child, data[key]);
} else {
child.textContent+=data[key];
}
element.appendChild(child);
}
}