From b6afb36c7375249210d392a5e172091b218104b2 Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Sat, 8 Nov 2025 12:28:31 +0100 Subject: [PATCH] removed duplicaetd code --- frontend/app.js | 217 ++++++++++++++++++++++---------------------- frontend/index.html | 71 +-------------- 2 files changed, 109 insertions(+), 179 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index 194b125..ff54173 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -380,128 +380,127 @@ function noteApp() { }, // Render folder recursively (helper for deep nesting) - renderFolderRecursive(folder, level = 0) { + renderFolderRecursive(folder, level = 0, isTopLevel = false) { if (!folder) return ''; let html = ''; - const baseIndent = level * 12; + const isExpanded = this.expandedFolders.has(folder.path); - // First, render child folders (if any) - if (folder.children && Object.keys(folder.children).length > 0) { - const children = Object.entries(folder.children).sort((a, b) => - a[1].name.toLowerCase().localeCompare(b[1].name.toLowerCase()) - ); - - children.forEach(([childKey, childFolder]) => { - const isExpanded = this.expandedFolders.has(childFolder.path); - - // Folder header HTML (no margin - it's inside folder-contents which provides the indent) - html += ` -
-
-
- - - ${childFolder.name} - ${childFolder.notes.length === 0 && (!childFolder.children || Object.keys(childFolder.children).length === 0) ? '(empty)' : ''} - -
-
- - - - -
-
- `; - - // If expanded, recursively render this folder's contents (notes + subfolders) - if (isExpanded) { - html += `
`; - html += this.renderFolderRecursive(childFolder, 0); // Reset level to 0 for relative positioning - html += `
`; - } - - html += `
`; - }); - } - - // Then, render notes in this folder (after subfolders) - if (folder.notes && folder.notes.length > 0) { - folder.notes.forEach(note => { - const isCurrentNote = this.currentNote === note.path; - html += ` -
- ${note.name} + // Render this folder's header + html += ` +
+
+
+ + ${folder.name} + ${folder.notes.length === 0 && (!folder.children || Object.keys(folder.children).length === 0) ? '(empty)' : ''} + +
+
+ + + +
- `; - }); +
+ `; + + // If expanded, render folder contents (child folders + notes) + if (isExpanded) { + html += `
`; + + // First, render child folders (if any) + if (folder.children && Object.keys(folder.children).length > 0) { + const children = Object.entries(folder.children).sort((a, b) => + a[1].name.toLowerCase().localeCompare(b[1].name.toLowerCase()) + ); + + children.forEach(([childKey, childFolder]) => { + html += this.renderFolderRecursive(childFolder, 0, false); + }); + } + + // Then, render notes in this folder (after subfolders) + if (folder.notes && folder.notes.length > 0) { + folder.notes.forEach(note => { + const isCurrentNote = this.currentNote === note.path; + html += ` +
+ ${note.name} + +
+ `; + }); + } + + html += `
`; // Close folder-contents } + html += `
`; // Close folder wrapper return html; }, diff --git a/frontend/index.html b/frontend/index.html index f1ceaa3..2db161c 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -689,76 +689,7 @@