Public
Edited
Nov 28, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
await webfigschemas(routerIp)
Insert cell
Insert cell
await webfiglist(routerIp)
Insert cell
Insert cell
function webfiglist(ip) {
return new Promise((done) => {
fetch(`https://${ip}/webfig/list`)
.then((req) => req.text())
.then((txt) => {
var results = {};
/* this is critical...
the /webfig/list is not valid JSON document, it's a JS "fragment"
...so we need eval() to "convert it" to a variable to then return */
eval(`results = [${txt}]`);
done(results);
});
});
}
Insert cell
function webfigschemas(ip) {
return webfiglist(ip).then((list) =>
Promise.all(
list
.filter((i) => i.unique)
.map((i) => {
return new Promise((done) => {
let file = i.name
fetch(`https://${ip}/webfig/${file}`)
.then((req) => req.text())
.then((txt) => {
/* same eval() trick as the webfiglist, except return a "tuple" with [filename, data] */
var results
eval(`results = ${txt}`)
done([ file, results ])
})
})
})
)
)
}

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more