NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<!DOCTYPE html>
<html>
<head>
<title>Recursive Folder Structure</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('.folder').click(function() {
$(this).next('.contents').toggle();
let path = $(this).data('path');
updateBreadcrumb(path);
});

$('.file').click(function() {
let path = $(this).data('path');
let rootFolder = getRootFolder(path);
updateBreadcrumb(rootFolder);

// Send the selected file path to the backend
sendFilePathToBackend(path);
});

function updateBreadcrumb(path) {
let breadcrumb = [];
breadcrumb.push('<i class="fas fa-folder"></i>');
breadcrumb.push(path);
$('#breadcrumb').html(breadcrumb.join('/') + '/');
}

function getRootFolder(path) {
let parts = path.split('/');
return parts[0];
}





function sendFilePathToBackend(path) {
// Send AJAX request to the backend with the selected file path
$.ajax({
url: '/process-file/',
method: 'POST',
data: { 'file_path': path },
success: function(response) {
console.log('File path sent to backend:', path);
console.log('Response from backend:', response);
if (response['signal_names'] && Array.isArray(response['signal_names'])) {
// Update the specific <div> with the list of items
let itemsList = response['signal_names'].map(item => `<li>${item}</li>`).join('');
console.log('Items List:', itemsList);

$(`div[data-path="${path}"] .contents`).html(`<ul>${itemsList}</ul>`);
}
else {
console.error('Response items is not an array:', response.items);
}
},
error: function(error) {
console.error('Error sending file path to backend:', error);
}
});
}
});
</script>
<style>
.folder > i {
margin-right: 5px;
}
.contents {
display: none;
padding-left: 20px;
}
.file > i {
margin-right: 5px;
}
</style>
</head>
<body>
<h1>Recursive Folder Structure</h1>
<div id="breadcrumb"><i class="fas fa-folder"></i> foldericon/</div>
<div id="folder_contents">
{% for folder in folder_structure.folders %}
<div class="folder" data-path="{{ folder.path }}"><i class="fas fa-folder"></i>{{ folder.name }}</div>
<div class="contents">
{% for subfolder in folder.folders %}
<div class="folder" data-path="{{ subfolder.path }}"><i class="fas fa-folder"></i>{{ subfolder.name }}</div>
<div class="contents">
{% for file in subfolder.files %}
<div class="file" data-path="{{ file.path }}"><i class="fas fa-file"></i>{{ file.name }}</div>
{% endfor %}
</div>
{% endfor %}
{% for file in folder.files %}
<div class="file" data-path="{{ file.path }}"><i class="fas fa-file"></i>{{ file.name }}</div>
{% endfor %}
</div>
{% endfor %}
</div>
</body>
</html>
Modify above code. I want to append items list to corresponding filepath
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.