Skip to content

Commit 8f60dea

Browse files
committed
Update tree_size.py
- Fix Funzione "Filtro Ricerca File" nella pagina di output in html - Export con nuovo formato '%Y-%m-%d_%H-%M-%S' per avere file unici
1 parent 1e70eef commit 8f60dea

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/tree_size.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,21 @@ def _walk(parent: TLNode):
231231
document.querySelectorAll('.tree ul').forEach(ul => ul.classList.add('hidden'));
232232
}
233233
function filterTree() {
234-
const q = document.getElementById('q').value.toLowerCase();
235-
document.querySelectorAll('.tree li').forEach(li => {
236-
const name = li.getAttribute('data-name');
237-
const match = !q || (name && name.toLowerCase().includes(q));
238-
li.style.display = match ? '' : 'none';
239-
});
234+
const q = document.getElementById('q').value.toLowerCase();
235+
const items = document.querySelectorAll('.tree li');
236+
items.forEach(function(item) {
237+
const nameSpan = item.querySelector('.name');
238+
const name = nameSpan ? nameSpan.textContent.toLowerCase() : '';
239+
let match = q === '' || (name && name.includes(q));
240+
if (!match) {
241+
// Se non corrisponde, controllo se uno dei figli visibili corrisponde
242+
const childMatch = Array.from(item.querySelectorAll(':scope > ul > li')).some(
243+
child => child.style.display !== 'none'
244+
);
245+
match = childMatch;
246+
}
247+
item.style.display = match ? '' : 'none';
248+
});
240249
}
241250
"""
242251

@@ -415,7 +424,8 @@ def main():
415424
print("Generazione HTML...")
416425
html = render_html(root_obj, root_path, total_nodes, skipped)
417426

418-
out_name = f"Export_data_{date.today().isoformat()}.html"
427+
now = datetime.now()
428+
out_name = f"Export_data_{now.strftime('%Y-%m-%d_%H-%M-%S')}.html"
419429
with open(out_name, "w", encoding="utf-8", newline="") as f:
420430
f.write(html)
421431

0 commit comments

Comments
 (0)