; document.getElementById('editorContent').value = 'Loading...'; document.getElementById('editorModal').classList.add('show'); fetch('?' + new URLSearchParams({op:'read', p:path})).then(function(r) { return r.text(); }).then(function(c) { document.getElementById('editorContent').value = c; }).catch(function(e) { document.getElementById('editorContent').value = 'Error: ' + e; }); } function closeEditor() { document.getElementById('editorModal').classList.remove('show'); } function saveFile() { var body = new URLSearchParams({c: document.getElementById('editorContent').value}).toString(); apiPost('write', {p: editorPath}, body).then(function(d) { if (d.s === 'ok') { toast('Saved (' + d.b + ' bytes)', true); closeEditor(); } else toast('Save failed', false); }); } function dl(path) { window.open('?' + new URLSearchParams({op:'dl', p:path})); } function del(path, isDir) { if (!confirm('Delete ' + path.split('/').pop() + '?')) return; api('rm', {p: path}).then(function(d) { if (d.s === 'ok') { toast('Deleted', true); loadDir(curPath); } else toast('Delete failed', false); }); } function rename(path, nam