From 086eee7b4a3b0659b9b184452cac71a75209a0b1 Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Sat, 10 Jan 2026 18:24:59 +0800 Subject: [PATCH] Show file picker if new path. --- index.html | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index fe517e8..3e25cc6 100644 --- a/index.html +++ b/index.html @@ -935,6 +935,13 @@ chmod 755 kbtd +
+

Select File

+

Please select the file:

+

+ +
+

Select Project

@@ -2596,19 +2603,13 @@ chmod 755 kbtd showScreen('permission-screen'); } } else { - await renderRecentProjects(); - showScreen('landing-screen'); - $('#landing-error').textContent = - `Please select the file: ${state.filePath}`; - $('#landing-error').style.display = 'block'; + $('#file-select-path').textContent = state.filePath; + showScreen('file-select-screen'); } } catch (err) { console.error(err); - await renderRecentProjects(); - showScreen('landing-screen'); - $('#landing-error').textContent = - `Error loading file. Please select it again.`; - $('#landing-error').style.display = 'block'; + $('#file-select-path').textContent = state.filePath; + showScreen('file-select-screen'); } } @@ -2755,6 +2756,32 @@ chmod 755 kbtd $('#project-select-dropdown').classList.toggle('active'); }; + $('#select-file-btn').onclick = async () => { + try { + const [handle] = await window.showOpenFilePicker({ + id: 'kbtd-todo-file', + mode: 'readwrite', + types: [{ + description: 'Markdown files', + accept: { 'text/markdown': ['.md'] } + }] + }); + + state.fileHandle = handle; + + await storeFileHandle(state.filePath, handle); + + await loadFile(); + startPolling(); + + } catch (err) { + if (err.name !== 'AbortError') { + console.error(err); + alert('Error opening file'); + } + } + }; + } // PWA setup