Tutorials > A settings page that saves config > Files PLUGIN.JS (2/3) ${row('Save books to', '')}
Stored unencrypted on the SD card in ${api.dir}/${CONFIG}.
`; const out = (msg, ok = true) => { $('[data-out]').textContent = msg; $('[data-out]').style.color = ok ? 'var(--success-color)' : 'var(--danger-color)'; }; const inputs = [...container.querySelectorAll('[data-k]')]; // ---------- load ---------- const cfg = await readConfig(); for (const el of inputs) el.value = cfg[el.dataset.k] ?? ''; // ---------- save ---------- $('[data-act=save]').onclick = async () => { for (const el of inputs) { const v = el.value.trim(); if (v) cfg[el.dataset.k] = v; else delete cfg[el.dataset.k]; } if (cfg.server) cfg.server = cfg.server.replace(/\/+$/, ''); // no trailing slash if (cfg.dest_dir && !cfg.dest_dir.startsWith('/')) cfg.dest_dir = '/' + cfg.dest_dir; try { await writeConfig(cfg); out('Saved.'); } catch (e) { out('Save failed: ' + e.message, false); } }; // ---------- test through the reader (no CORS!) ---------- Next: 05 plugin.js (3/3)