mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
Working example for reading and display the config.yml
This commit is contained in:
@@ -1,13 +1,26 @@
|
|||||||
var showConfig = document.getElementById("show-config");
|
var showConfig = document.getElementById("show-config");
|
||||||
var configForm = document.getElementById("config-form");
|
|
||||||
showConfig.addEventListener("click", () => {
|
showConfig.addEventListener("click", () => {
|
||||||
|
var configForm = document.getElementById("config-form");
|
||||||
fetch("/config")
|
fetch("/config")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
configForm.style.display = "block";
|
configForm.style.display = "block";
|
||||||
for (let key in data) {
|
processChildren(configForm, data);
|
||||||
console.log('key: ', key);
|
|
||||||
console.log(data[key]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function processChildren(element, data) {
|
||||||
|
for (let key in data) {
|
||||||
|
var child = document.createElement("div");
|
||||||
|
child.id = key;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user