diff --git a/internal/web/static/app.js b/internal/web/static/app.js
index 0bf15d9..d862a5b 100644
--- a/internal/web/static/app.js
+++ b/internal/web/static/app.js
@@ -346,6 +346,12 @@ function openSettings() {
document.getElementById('setSave').onclick = saveSettings;
document.getElementById('setBrowse').onclick = () =>
loadBrowse(parentDir(document.getElementById('setKnow').value));
+ }).catch(() => {
+ const ov = document.getElementById('settingsOverlay');
+ ov.innerHTML = '
Could not load settings.
' +
+ '
';
+ ov.hidden = false;
+ document.getElementById('setClose').onclick = closeSettings;
});
}
@@ -371,7 +377,13 @@ function saveSettings() {
function parentDir(path) {
if (!path) return '';
- return path.replace(/\/[^/]*$/, '');
+ const i = path.lastIndexOf('/');
+ if (i <= 0) return '/';
+ return path.slice(0, i);
+}
+
+function esc(s) {
+ return String(s).replace(/&/g, '&').replace(/ {
const items = [];
if (d.parent && d.parent !== d.dir) {
- items.push(``);
+ items.push(``);
}
for (const e of d.entries) {
if (e.is_dir) {
- items.push(``);
+ items.push(``);
} else {
- items.push(``);
+ items.push(``);
}
}
- pane.innerHTML = `${d.dir}
`;
+ pane.innerHTML = `${esc(d.dir)}
`;
pane.querySelectorAll('button[data-dir]').forEach(b =>
b.onclick = () => loadBrowse(b.getAttribute('data-dir')));
pane.querySelectorAll('button[data-file]').forEach(b =>