e, isDir) { renamePath = path; renameIsDir = isDir; document.getElementById('renameNew').value = name; document.getElementById('renameModal').classList.add('show'); document.getElementById('renameNew').focus(); document.getElementById('renameNew').select(); } function closeRename() { document.getElementById('renameModal').classList.remove('show'); } function doRename() { var newName = document.getElementById('renameNew').value; if (!newName) return; var parent = renamePath.split('/').slice(0, -1).join('/'); var dest = parent + '/' + newName; api('mv', {s: renamePath, d: dest}).then(function(d) { if (d.s === 'ok') { toast('Renamed', true); closeRename(); loadDir(curPath); } else toast('Rename failed', false); }); } function newFile() { var name = prompt('New file name:'); if (!name) return; var path = curPath + '/' + name; apiPost('write', {p: path}, 'c=').then(function(d) { if (d.s === 'ok') { toast('Created', true); loadDir(curPath); edit(path); } else toast('Failed', false); }); } function newDir() { var name = prompt('New directory name:'); if (!name) return; api('