MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / loadNvs

Function loadNvs

webUi/scripts.js:30–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28function _nvsIsCheckbox(f) { return f.t === 'u8' && (f.v === 0 || f.v === 1); }
29function _nvsId(ns, k) { return 'nvs__' + ns + '__' + k; }
30function loadNvs() {
31 _('nvs').style.display = 'block';
32 _('nvs-body').innerHTML = 'Loading...';
33 const x = new XMLHttpRequest();
34 x.open('GET', '/nvs');
35 x.onload = () => {
36 _nvsData = JSON.parse(x.responseText);
37 const inp = 'style="width:100px;background:#303134;color:#0d0;border:1px solid #0d0;padding:2px"';
38 const inps = 'style="width:220px;background:#303134;color:#0d0;border:1px solid #0d0;padding:2px"';
39 let h = '';
40 for (const ns in _nvsData) {
41 h += '<h3 style="margin:8px 0 4px;color:#0d0">' + ns + '</h3>';
42 _nvsData[ns].forEach(f => {
43 const id = _nvsId(ns, f.k);
44 h += '<div style="margin:4px 0"><label style="display:inline-block;width:150px;font-size:0.9em">' + f.k + ':</label>';
45 if (_nvsIsCheckbox(f))
46 h += '<input type="checkbox" id="' + id + '"' + (f.v ? ' checked' : '') + '>';
47 else if (_nvsInts.has(f.t))
48 h += '<input type="number" id="' + id + '" value="' + f.v + '" ' + inp + '>';
49 else
50 h += '<input type="text" id="' + id + '" value="' + f.v + '" ' + inps + '>';
51 h += ' <small style="color:#888">' + f.t + '</small></div>';
52 });
53 }
54 _('nvs-body').innerHTML = h;
55 };
56 x.send();
57}
58function saveNvs() {
59 const out = {};
60 for (const ns in _nvsData) {

Callers

nothing calls this directly

Calls 4

_Function · 0.85
_nvsIdFunction · 0.85
_nvsIsCheckboxFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected