473,607 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tree functions

Hello!

I need a tree (of folders), can anyone give me some ideas/input, how
do I control collapse, explode etc?

Showing the entire tree will be too much, so I need to show a part of
it only....

BR
Sonnich

Mar 25 '07 #1
1 2523
On 25 Mar, 21:37, "jodleren" <sonn...@hot.ee wrote:
Hello!

I need a tree (of folders), can anyone give me some ideas/input, how
do I control collapse, explode etc?

Showing the entire tree will be too much, so I need to show a part of
it only....

BR
Sonnich
You could use jquery's tree view:
http://be.twixt.us/jquery/treeView.php

with an XHR call.

An example would be a tree of mp3s to be browsed.

You could return using XHR the exact folders paths as xhtml snippets,
(or pure json if a purist)
<ul>
<li><a class="dir" href="/path/to/folder">/path/to/folder</a></li>
<li><a class="file" href="/path/to/folder/track01.mp3">/path/to/
folder/track01.mp3</a></li>
</ul>

you would insert this into the DOM at the node clicked on, and bind an
onclick even to the link.
I guess you could use jQuery of prototype/scriptaculous, perhaps
behaviour to bind based on className

when clicked it would XHR to list.php which returns the next snippet,
or sends the URL to an embedded player.

You would get the actual tree like so, sorry for any typos:

function returnData($str Dir,$strReturnT ype)
{
$arrResults = array();
$entry = '';
$d = '';
$boolDirs = false;
$boolFiles = false;
if($strReturnTy pe =='files')
{
$boolFiles = true;
}
else
{
$boolDirs = true;
}
$d = dir($strDir);
while ( false !== ($entry = $d->read()) )
{
if( $boolDirs )
{
if( is_dir($strDir. $entry) && ($entry!='.') && ($entry!='..') )
{
$arrResults[] = $entry;
}
}
else
{
if( !is_dir($strDir .$entry)
&& (strpos($entry, 'tmp') === false)
&& ($entry!='404.m p3'))
{
$arrResults[] = $entry;
}
}
}
$d->close();
return $arrResults;
}

calling it like this:

$arrResults = returnData($str Dir,$strReturnT ype);
$arrResultsFile s = returnData($str Dir,"files");

it's inefficient I guess, but would get you what you need
For a more apache based way, you could use javascript to hijack the
link returning false, but using XHR to request the page which
using rewrites would change the requested path from
/music/path/to/folder to
/list.php?path=/music/path/to/folder

I guess the key is hijacking the links, so your javascript is
unobtrusive, and using javascript/rewrites to request the appropriate
data, which you then insert as first child of the parent node (you
clicked on)
Fisheye has uses something similar to browse the code
http://fisheye5.cenqua.com
bottom left

Mar 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2654
by: Xah Lee | last post by:
Here's the belated Java solution. import java.util.List; import java.util.ArrayList; import java.lang.Math; class math { public static List range(double n) { return range(1,n,1); }
6
2150
by: Nobody | last post by:
This is sort of my first attempt at writing a template container class, just wanted some feedback if everything looks kosher or if there can be any improvements. This is a template class for a binary search tree. Note there is a requirement for this to be a Win32/MFC "friendly" class, thus the use of CObject and POSITION. There is also a requirement for there not to be a separate iterator class. template <class TYPE, class ARG_TYPE =...
4
806
by: Jerry Khoo | last post by:
Thanks for the answer, and by the way, i would like to know that in C++, how u create a tree using a recursive envronment. It seems that most people used struct to create a node than, using recursive function to build it up, but than is there any way around i could built a tree using iterative method like for .. loop?
4
2823
by: Henry Jordon | last post by:
I have everything pretty much done but I need to fix something in my coding. I want to be able to enter strings such as "love", "hate", "the", etc. but am unable to figure how to do this. I have put my .cpp and my .h code below. Please help and thank you very much. // include files #ifndef BINTREE_H #define BINTREE_H #include <iostream> #include <iomanip>
4
9013
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working, even the removal, I just don't know how to keep track of the parent, so that I can set its child to the child of the node to be removed. IE - if I had C / \ B D
6
4009
by: Melkor Ainur | last post by:
Hello, I'm attempting to build an interpreter for a pascal-like language. Currently, I don't generate any assembly. Instead, I just build an abstract syntax tree representing what I've parsed from a user's program and use a C backend to evaluate the tree. I'm using Lex, Yacc and C. Now, there are some functions that are built into this language and others which are not. The problem I'm having is that I haven't found a way to represent...
3
2189
by: asianmuscle | last post by:
Hi I am relearning datastructure... but got kinda stuck in a basic delete node operation. what it does is to delete the first node it finds when the item is equal the input item. the end result is that the node is deleted and the b-tree is still kept as b-tree. CAn someone critique on my implementation? Any suggestion for improvement? Thanks The code I have as follows: #include <iostream>
2
14699
by: aemado | last post by:
I am writing a program that will evaluate expressions using binary trees. Most of the code has been provided, I just have to write the code for the class functions as listed in the header file. However, I am really new to recursion and trees...and this program uses public functions and private helper functions, which I am completely lost in. Here is the header file: struct CTNode { NodeType type; int operand; CTNode *left, *right; };
13
1540
by: Bill Cunningham | last post by:
pgs 140-1 of kandr2 talk about recursion. I tried typing in the code char by char and couldn't find the bugs so I just read the code and a new concept to me jumped out. Maybe this is what it means by recursion. struct tnode *addtree (struct tnode *, char *); is declared on p 140. But I noticed this on p 141. struct tnode *addtree (struct tnode *p, char *w);
0
8049
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8469
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8463
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5997
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3953
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2461
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.