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

Function saveNvs

webUi/scripts.js:58–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56 x.send();
57}
58function saveNvs() {
59 const out = {};
60 for (const ns in _nvsData) {
61 out[ns] = _nvsData[ns].map(f => {
62 const el = document.getElementById(_nvsId(ns, f.k));
63 if (!el) return f;
64 let v = _nvsIsCheckbox(f) ? (el.checked ? 1 : 0) : _nvsInts.has(f.t) ? parseInt(el.value) : el.value;
65 return {k: f.k, t: f.t, v};
66 });
67 }
68 const x = new XMLHttpRequest();
69 x.open('POST', '/nvs');
70 x.setRequestHeader('Content-Type', 'application/json');
71 x.onload = () => { _('status').innerHTML = x.responseText === 'OK' ? 'NVS saved!' : x.responseText; _('nvs').style.display = 'none'; };
72 x.send(JSON.stringify(out));
73}
74
75function httpRequest(method, url, { async = true, body, headers = {}, onload, onerror } = {}) {
76 const xhr = new XMLHttpRequest();

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected