...

View Full Version : Need to Take a List of Strings add to array, then tree-it



KellCOMnet.us
08-19-2004, 02:15 AM
I have a list of folders generated by a server side loop, it outputs in the following format:.

<script>kcAddToArray(,'Inbox');</script>
<script>kcAddToArray('Drafts');</script>
<script>kcAddToArray('Sent');</script>
<script>kcAddToArray('Sent Items');</script>
<script>kcAddToArray('Spam');</script>
<script>kcAddToArray('Test Folder');</script>
<script>kcAddToArray('Test Folder/SubLevel -1');</script>
<script>kcAddToArray('Test Folder/SubLevel -1/SubSubLevel -1');</script>
<script>kcAddToArray('Test Folder/SubLevel -2');</script>
<script>kcAddToArray('Trash');</script>

What I need to do is:
A) Figure out how to take each folder and add them to a common array.
B) Put them in some kind of NON-COLLAPSING tree (example follows).

USERNAME <--Added Elsewhere
|_Inbox
|_Drafts
|_Sent
|_Sent Items
|_Spam
|_Test Folder
| |_SubLevel -1
| | |_SubSubLevel -1
| |_SubLevel -2
|_Trash

C) Now for the biggie, it needs to support an infinite number of sub folders.

I would be gratefully appreciative for any assistance provided.


What I have been doing, is very different from how I would like it to be, This only work partway and not very well:

function kcTreeIt(kcDisplay)
{
kcLevel = kcDisplay.split("/");
var kcString = "";
var i;
for(i = 0; i <= kcLevel.length - 1; i ++)
{
if (i <= kcLevel.length - 2)
{
if (kcLevel.length > 0)
{
if (i >= 1)
{
kcString = kcString + "<img src='/nwimg/mail/KellCOMnet/gui/folderlist/fld_blank.png'>";
}
else
{
kcString = kcString + "<img src='/nwimg/mail/KellCOMnet/gui/folderlist/fld_left.png'>";
}
}
}
else
{
kcString = kcString + "<img src='/nwimg/mail/KellCOMnet/gui/folderlist/fld_sub.png'>";
}
}
kcString = kcString + " <a href=\"||action||\">" + kcLevel[kcLevel.length - 1] + "</a>";

document.write(kcString);
}

Vladdy
08-19-2004, 02:48 AM
Have server side generate nested lists (www.vladdy.net/Demos/Tree.html) and go from there...

KellCOMnet.us
08-19-2004, 02:54 AM
Thank You for Your Reply,

But unfortunately that will not work, because the server side engine will only output the folder name with complete path as in "Root/Folder/SubFolder/SubSubfolder"

Any display has to be clientside the "kcAddToArray" is hardcoded



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum