From 9a2e13ab43762eb0ff6fea1934314198d6e84400 Mon Sep 17 00:00:00 2001 From: semanticdata Date: Thu, 15 Jan 2026 08:43:44 -0600 Subject: [PATCH 1/2] new export script --- .gitignore | 2 ++ scripts/copy-shared.js | 2 +- scripts/watch-shared.js | 2 +- shared/export.js | 61 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 shared/export.js diff --git a/.gitignore b/.gitignore index 8b164bc..c7e062c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,10 @@ packages/sidebar/styles.css packages/sidebar/script.js packages/sidebar/icon.svg packages/sidebar/preload.js +packages/sidebar/export.js packages/newtab/styles.css packages/newtab/script.js packages/newtab/icon.svg packages/newtab/preload.js +packages/newtab/export.js web-ext-artifacts diff --git a/scripts/copy-shared.js b/scripts/copy-shared.js index 0bb54d3..d957e60 100644 --- a/scripts/copy-shared.js +++ b/scripts/copy-shared.js @@ -6,7 +6,7 @@ const path = require('path'); // Configuration const sharedDir = path.join(__dirname, '../shared'); const packagesDir = path.join(__dirname, '../packages'); -const sharedFiles = ['script.js', 'styles.css', 'icon.svg', 'preload.js']; +const sharedFiles = ['script.js', 'styles.css', 'icon.svg', 'preload.js', 'export.js']; const targets = ['newtab', 'sidebar']; // Colors for console output diff --git a/scripts/watch-shared.js b/scripts/watch-shared.js index 19cf409..7f9c77f 100644 --- a/scripts/watch-shared.js +++ b/scripts/watch-shared.js @@ -8,7 +8,7 @@ const { build } = require('./copy-shared.js'); // Configuration const sharedDir = path.join(__dirname, '../shared'); -const sharedFiles = ['script.js', 'styles.css', 'icon.svg']; +const sharedFiles = ['script.js', 'styles.css', 'icon.svg', 'preload.js', 'export.js']; // Colors for console output const colors = { diff --git a/shared/export.js b/shared/export.js new file mode 100644 index 0000000..f57ac21 --- /dev/null +++ b/shared/export.js @@ -0,0 +1,61 @@ +// Export functionality for NoteKeeper +const exportEls = { + exportButton: document.getElementById("export-button"), + notes: document.getElementById("notes"), + status: document.getElementById("save-status"), +}; + +// Generate timestamped filename: YYYYMMDDThhmm-notekeeper.txt +const generateFilename = () => { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, "0"); + const day = String(now.getDate()).padStart(2, "0"); + const hours = String(now.getHours()).padStart(2, "0"); + const minutes = String(now.getMinutes()).padStart(2, "0"); + + return `${year}${month}${day}T${hours}${minutes}-notekeeper.txt`; +}; + +// Export notes to local file +const exportNotes = () => { + const content = exportEls.notes.value; + + if (!content.trim()) { + exportEls.status.textContent = "Nothing to export"; + setTimeout(() => { + exportEls.status.textContent = "Ready"; + }, 2000); + return; + } + + try { + const filename = generateFilename(); + const blob = new Blob([content], { type: "text/plain;charset=utf-8" }); + const url = URL.createObjectURL(blob); + + const a = document.createElement("a"); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + + exportEls.status.textContent = "Exported"; + setTimeout(() => { + exportEls.status.textContent = "Ready"; + }, 2000); + } catch (error) { + console.error("Export error:", error); + exportEls.status.textContent = "Export failed"; + setTimeout(() => { + exportEls.status.textContent = "Ready"; + }, 2000); + } +}; + +// Initialize export functionality +if (exportEls.exportButton && exportEls.notes && exportEls.status) { + exportEls.exportButton.addEventListener("click", exportNotes); +} From 1df80e08708d7d9be1e2321164388a86bf1de895 Mon Sep 17 00:00:00 2001 From: semanticdata Date: Thu, 15 Jan 2026 08:43:55 -0600 Subject: [PATCH 2/2] new export to txt functionality --- packages/newtab/newtab.html | 11 +++++++++++ packages/sidebar/panel.html | 11 +++++++++++ shared/styles.css | 4 +++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/newtab/newtab.html b/packages/newtab/newtab.html index 8b54b91..7b9934e 100644 --- a/packages/newtab/newtab.html +++ b/packages/newtab/newtab.html @@ -71,6 +71,16 @@ + + +