Suppose I have this array below:
['uploads']
{
['file_1']
{
//maybe some attributes here
}
['file_2']
{
//maybe some attributes here
}
['folder_1']
{
['file_1']
{
//maybe some attributes here
}
['file_2']
{
//maybe some attributes here
}
['folder_1']
{
['file_1']
{
//maybe some attributes here
}
['file_2']
{
//maybe some attributes here
}
}
}
['folder_2']
{
['file_1']
{
//maybe some attributes here
}
['file_2']
{
//maybe some attributes here
}
}
}
So let's say this array or object is called data. I would argue that ['uploads'] is level one; thus so far level one has only one entry. Level 2 of ['uploads'] has 4 entries, 2 files and 2 folders. If an entry is a folder it can have further levels, you get the picture.
All this is then created in jquery as clickable divs on a page. Only the first level of course.
So if the user clicks on folder_1, I want to populate another array called 'current_directory' with folder_1 of the 2nd level of ['uploads'] as follows: current_directory = data['uploads']['folder_1'];
. This array is then created as clickable divs and again the user can click on something, and if it's a folder it will re-populate current_directory with the new folder, but this time as follows: current_directory = current_directory['folder_1'];
Or whichever folder the user clicked on.
Now the problem comes when I want to go back to the previous directory. How do I maybe keep track of which level I'm in or something like check in data (which is the whole folder structure) in which key(folder) the array current_directory belongs.
Just thought you should know that no 2 keys, whether file or folder, in the same level can have the same name. And then also the files and folders will obviously not be called file_1 and folder_1 but user generated names.
Oh and then, what I mean by attributes is like more keys that only files can have like ['type'] and ['size'].