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