OmenTree Documentation
Program and docs by Colin Tucker/OmenSoft
Program version: 1.0
OmenSoft on the web: http://omensoft.home.ml.org
E-mail the author: [email protected]


Introduction

Hello and thank you for downloading OmenTree - I hope that it and other quality OmenSoft products can be of use to you and your web site! Keep an eye on the OmenSoft web site for updates to OmenTree and releases of new products.


What is OmenTree?

In case you didn't already know, OmenTree is a hierarchial menu tree structure implemented using JavaScript. Bit of a mouthful? Well, put simply, OmenTree is a logically-presented menu that runs in a frame on your web site.

Hierarchial menu trees have been around for some time now. Do the names X-Tree, File Manager, and Windows Explorer ring bells? Well, if you've used one of these programs (and almost all of us have at sometime), you have used a hierarchial menu tree.

In fact, those of you familiar with Windows 95 use HMT's on virtually an everyday basis. OmenTree is based on the Windows Explorer interface, so it will be instantly recognisable and usable by regular Explorers.


Why use OmenTree?

One thing that was drilled into us students who studied Object-orientated Programming was that hierarchial structures are natural and familiar to us all - computer users or not. From birth, humans organise things into categories - it helps us understand and relate things together. Hierarchy is a logical way to present information - it is very easy to understand and comprehend.

I believe this is why such complex information structures (such as file systems) are stored and presented in a hierarchial format - otherwise they would be infinitely difficult to grasp and manage. Imagine having all of the files on your hard drive in the root directory - what a nightmare!

OmenTree is like a file structure for the web, except the files themselves are replaced by hyperlinks to local files, remote servers, and even newsgroups and e-mail addresses. Anything that can be pointed to by a URL (Universal Resource Locator) can be represented by a node in the OmenTree structure, and these nodes can in turn be categorised and organised logically.

Thus, by using OmenTree, you are giving the users of your web site a helping hand - especially if the site is large and difficult to navigate using conventional in-line hypertext links. Even if your site is relatively small, OmenTree can be used to create a fancy and nifty menu that you can show off to your friends! Make sure you tell them about it!


How can I use OmenTree?

OmenTree is an extremely versatile and useful little script, and I'm sure that you could find many uses for it - for any web-based task that requires more logical organisation and presentation, OmenTree is the solution. Here are some common suggestions for the use of OmenTree: These are just some of the many possible uses for OmenTree. Don't be afraid to take it to new heights! If you have done something truly spectacular with OmenTree, please e-mail me and let me know - I'll give you a link from the OmenSoft homepage!


How does OmenTree work?

It's pretty complex to go into the intricate details of exactly how n-ary hierarchial trees function, but put simply, to create an OmenTree menu, here's the three steps to follow:
  1. you modify the original script a little by providing your own OmenTree structure definitions - these are pretty easy to understand and create, more on that later;
  2. you add your own custom settings by modifying some other variables in the script - these change things like the background color, text colors, default target frames and icons etc. Again, these will be covered later.
  3. you slot the script into your index.html file, or better yet, just copy the pre-existing omentree.html file over as your index.
Ok, those among you who aren't that familiar with JavaScript have probably started running around the room screaming by now - don't panic - I've deliberately made OmenTree a learning experience so that you can understand some modern web publishing techniques a little better.

Even if you have never heard of JavaScript before, you can still create an OmenTree menu - I'll guide you step by step through the exact process - so take it easy! You'll create your own funky little menu in no time, and, you'll learn along the way!


What happens after all that?

Well, if all has gone smoothly - you've modified the script and placed it as your index.html file, your web site should be transformed!

Basically, once your index loads, and all of the pages in the frames have loaded, OmenTree starts up. It looks at your structure definitions, works out what the tree looks like and what goes where, and then draws the first branch of the tree - the root, and it's immediate children.

Through JavaScript commands, the tree then becomes dynamic - allowing the users of your site to click on folders so that they expand, and show hidden branches and nodes. Although it may sound complex, I can assure you, it really is quite easy, as you'll see.


Ok, so let's start

Right. Enough talk, let's start creating your own OmenTree!

Ok, let's start by making backups of all the original OmenTree files, just incase something goes wrong. Then, open up your favourite text editor (e.g. Notepad) and load up the omentree.html file - it's probably best to maximise the window, as well.

Now, the first thing you'll see is a lot of yucky code. Don't worry, this is the code responsible for drawing the tree, you won't even have to touch it - in fact, it's best left alone because if something goes wrong in there, OmenTree mightn't seem so funky after all!

For those who are interested, I've put some comment headers in front of all of the functions, so you can tell at a glance what they are there for. You might notice the drawBranch() function as you scroll down - huge, eh? This is the heart of OmenTree - a recursive function (meaning it calls itself from the inside) that is responsible for working out the hierarchy and writing the necessary HTML.

Keep going down until you get to a function called loadData(). This is where you will be concentrating 99% of your efforts. Again, especially with the default menu structure, it's a huge function - and probably a little overwhelming to start with - again, don't panic!


Ok, I'm at the loadData() function - now what?

Now we start making your first menu!

You'll notice that the loadData() function is divided into three distinct sections:

These three sections are where you will make changes to the script to suit your web site. Let's start from the bottom up.


Additional HTML Sources

Ok, this would have to be the easiest section. When you have created your OmenTree, what happens if you want to put some extra bits before and after the actual menu structure? In the old version of OmenTree (then known as WebBrancher) you couldn't do it, and enough thought and comments from people convinced me that it would be a good idea to include a facility for adding in additional HTML before and after the menu structure.

This is where the Additional HTML Sources section comes in. You'll notice two variables:

Basically, if you want some HTML to be displayed before the menu structure, place the code in the prefixHTML variable, and conversely, any HTML you wish to be displayed after the structure goes into the suffixHTML variable - it's that easy.

You'll notice that the suffixHTML variable already has some HTML stored there. This is for the default OmenTree menu, and if you do not want anything displayed after your menu, you can just clear the HTML - but make sure you leave the empty quote marks, like this: "".

prefixHTML is great for inserting a logo image or something similar for your site in the top-left corner, and suffixHTML is mostly used for brief comments or 'last modified' dates.


User Defined Variables

Moving up the script we see the next section - user defined variables. This is where you define some additional things about the appearance and function of the OmenTree.

Let's go through each variable individually:

That should be enough to cover the user defined variables - they are all pretty self-explainatory, and you can try some harmless experimentation and combinations to see what you get!


Tree Structure Definitions

Ok, here comes the biggie - this is what OmenTree is all about - the menu tree structure definitions. Before we delve into this topic, why don't you take a look at the original source code. Examine the default menu structure and try to understand what is happening, and how it all connects together.

Basically, all of your menu tree definitions are stored in a big array - or in this instance, a Collection (a term borrowed from Smalltalk programming - a Collection is like an Array, but it does not have a fixed size, and you do not specify indexes when placing data inside).

Each line in the definitions section of the source code is adding a new node to the tree. Each tree has only one root node, and must only have one. Imagine a tree with two trunks!!

The rest of the definitions consist of link nodes, and link nodes sub-branched into folder nodes.

The Root Node

Your menu definitions MUST have only one root node, and this root node MUST be the first node in the Collection - i.e. it is added first. No questions asked, no democracy here - this is how it must be! Don't put in more than one, or you'll have trouble.

Root Node Syntax:

treeData.add(new RootNode('<ID>','<NAME>','<URL>','<TARGET>','<ALT ICON>'));

where:

Folder Nodes

Folder nodes work in much the same way as root nodes but have a slighly different syntax. Note also, that while the root node is supposed to be an orphan - i.e. without any parent nodes - folder nodes MUST have a parent node.

Folder nodes, however, do not link to anything - they are simply containers for other folder and link nodes.

Folder Node Syntax:

treeData.add(new FolderNode('<ID>','<PARENT ID>','<NAME>','<ALT ICON CLOSED>','<ALT ICON OPEN>'));

where:

Link Nodes

This is where the true purpose of OmenTree comes into play - links! Their syntax is very simple and is similar to that of the root node.

Link Node Syntax:

treeData.add(new LinkNode('<PARENT ID>','<NAME>','<URL>','<TARGET>','<ALT ICON>'));

where:

And that's it for the menu tree structure definitions - not that hard, really! If you are still a bit confused, take a good look at the original definitions and try to see how that relate together.


Hints and Tips

During the course of creating OmenTree, and from the many comments of happy tree-er's, I've come up with a few hints and tips to help make the whole experience a little easier:
  1. It doesn't really matter what order you put your nodes into the Collection (except the root of course, it HAS to be first!) - OmenTree will work out which node goes where from the id values of each node, but...
  2. It DOES matter if you want a particular order for each node in a branch. It's difficult to explain, but basically when you open an OmenTree folder, it goes off and finds all the children of that folder node (by looking for all nodes that have a parent which is the folder), but it scans the Collection from start to finish, in order. So nodes which are higher up in the Collection appear before nodes that are after them - does this make sense?
  3. To help you when you edit your definitions, it is best to keep the definitions approximately in an order that you can understand - i.e. don't have nodes 'willy-nilly' everywhere.
  4. Use the tab key! When writing your definitions, use good programming practise and 'tab' in the hierarchy of the definitions, to help you tell what the structure looks like. This also helps when you go to edit the definitions later on.
  5. Think of the end-user when creating your tree. Make sure it's categorised well, set-up correctly, and looks nice!
  6. When creating your own custom icons, make sure they are 16 pixels wide by 16 pixels high, and watch the transparency of GIFs (especially if you use background images) - this is why if you look at some of my original images in a paint program, they have funky green backgrounds - this is the transparent color!
  7. Remember to set the <TITLE> of your index file (up the top), otherwise you'll end up with your site having a title of OmenTree.
  8. Above all, have fun - trust me, it's worth all the effort - you'll be very pleased when you've completed your very own OmenTree!

Additional Notes

Here's some extra information I thought I'd throw in to help you! Aren't I nice?

Frame definitions

One thing I haven't mentioned so far is that little extra teensy bit on the bottom of your index.html (or the omentree.html) file - the frame definitions. Here's some more tyranny:

That's about all you should remember about your frames, except for one more thing - be careful about the sizing of your frames - i.e. try not to have a hugely hierarchial (deep) tree in a really thin frame. It's best to leave the frames resizable as well, so the user can resize the tree as they desire.


That's about it!

Well, that's about it for the OmenTree documentation. If you have any further questions, please contact Colin Tucker and OmenSoft at:

..or visit the OmenSoft homepage.

I hope that OmenTree can prove itself beneficial and useful for your site!