diff --git a/static/app.js b/static/app.js index 58b2442..d5969ca 100644 --- a/static/app.js +++ b/static/app.js @@ -84,6 +84,24 @@ $("#lib-form").addEventListener("submit", async (e) => { } catch (err) { toast(err.message, true); } }); +// path autocompletion for the library form +{ + const pathInput = document.querySelector('#lib-form [name=root_path]'); + const datalist = $("#path-suggestions"); + let pathTimer; + pathInput.addEventListener("input", () => { + clearTimeout(pathTimer); + const value = pathInput.value; + if (!value.startsWith("/")) return; + pathTimer = setTimeout(async () => { + try { + const res = await api("/api/fs/browse?path=" + encodeURIComponent(value)); + datalist.innerHTML = res.dirs.map((d) => `