Home Register FAQ Members List Calendar Game Links Gallery
Go Back   Joystick Required Forums > Jumpgate TRI Forums > Jump's Jumpgate Tool Shed > JOSSH II
About This Page About This Page: This is a discussion on Station Production Database within the JOSSH II forums, part of the Jump's Jumpgate Tool Shed category, at Joystick Required Forums. Sweet! Thanks a bunchness. I didn't know you where a js coder. Better not give me your phone number. LOL I was looking at the wrong function. I changed
Welcome to Joystick Required! Membership is easy and its free! And membership removes this giant ad space.

Closed Thread
 
LinkBack Thread Tools

Old 02-15-2005, 02:04 PM   #31 (permalink)
Big Daddy
 
Jump's Avatar
 
Pilot Name: JumpDemon
Faction: Solrain
Joystick: MS FF2
Join Date: May 2004
Location: Tracy, Ca.
Posts: 6,959
Jump has a spectacular aura aboutJump has a spectacular aura about
<!-- google_ad_section_start(weight=ignore) -->Jump<!-- google_ad_section_end --> is a Solrain pilot
Sweet! Thanks a bunchness. I didn't know you where a js coder. Better not give me your phone number. LOL

I was looking at the wrong function.

I changed

Code:
this.root.id + 1
to

Code:
this.root.id + 2
Then the makes and ingredients windows close each other. I'm not shure if that is better but they seem to be seperate issues.

Thanks again.

Jump

__________________
Currently working hard to break the server...

>> Help support JSR through our Amazon store
Jump is offline  Send a message via ICQ to Jump Send a message via Yahoo to Jump
Sponsored Links


Old 02-15-2005, 02:13 PM   #32 (permalink)
Member
 
Evolution's Avatar
 
Faction: Octavius
Joystick: Cyborg evo
Join Date: Jan 2005
Location: Chicagoland
Posts: 190
Evolution is on a distinguished road
<!-- google_ad_section_start(weight=ignore) -->Evolution<!-- google_ad_section_end --> is a Octavius pilot
Quote:
Originally Posted by Jump
I didn't know you where a js coder.
I'm not really specifically a JS coder, but I'm a programmer by trade [mostly C, Delphi(pascal), Flash(ActionScript)]. JS just happens to be one of those languages that's so much like others that it's easy to figure out when you're used to similar languages.

Quote:
Originally Posted by Jump
I changed

Code:
this.root.id + 1
to

Code:
this.root.id + 2
Then the makes and ingredients windows close each other. I'm not shure if that is better but they seem to be seperate issues.
Yeah I couldn't decide which way it should be heh.
Evolution is offline  

Old 02-15-2005, 02:25 PM   #33 (permalink)
Big Daddy
 
Jump's Avatar
 
Pilot Name: JumpDemon
Faction: Solrain
Joystick: MS FF2
Join Date: May 2004
Location: Tracy, Ca.
Posts: 6,959
Jump has a spectacular aura aboutJump has a spectacular aura about
<!-- google_ad_section_start(weight=ignore) -->Jump<!-- google_ad_section_end --> is a Solrain pilot
There are more advanced js tree scripts out there. But I like this one because it really lends itself to dynamic output.

Thanks again.
Jump is offline  Send a message via ICQ to Jump Send a message via Yahoo to Jump

Old 02-15-2005, 03:00 PM   #34 (permalink)
Member
 
Evolution's Avatar
 
Faction: Octavius
Joystick: Cyborg evo
Join Date: Jan 2005
Location: Chicagoland
Posts: 190
Evolution is on a distinguished road
<!-- google_ad_section_start(weight=ignore) -->Evolution<!-- google_ad_section_end --> is a Octavius pilot
You know.. that + 2 thing just doesn't sit well with me. Mostly because it won't work if you tried to put commodities down on the bottom, for example. That only works because commodities is the first category. It would also stop working if you added more siblings to "Ingredients" down in the equipment list. I'm finishing up a little rewrite as we speak because otherwise I wouldn't be able to sleep tonight :P Basically I wrote a function to figure out the level of the current node (as an integer) and then the if statement can check that value to decide whether or not to close other branches. That way your solrain_core.js (or whatever other file is using dtree.js) can set the level to go down to as a configuration option.
Evolution is offline  

Old 02-15-2005, 03:06 PM   #35 (permalink)
Big Daddy
 
Jump's Avatar
 
Pilot Name: JumpDemon
Faction: Solrain
Joystick: MS FF2
Join Date: May 2004
Location: Tracy, Ca.
Posts: 6,959
Jump has a spectacular aura aboutJump has a spectacular aura about
<!-- google_ad_section_start(weight=ignore) -->Jump<!-- google_ad_section_end --> is a Solrain pilot
Quote:
Originally Posted by Evolution
I'm finishing up a little rewrite as we speak because otherwise I wouldn't be able to sleep tonight :P
hehe, I know that feeling all to well my friend.
Jump is offline  Send a message via ICQ to Jump Send a message via Yahoo to Jump

Old 02-15-2005, 03:19 PM   #36 (permalink)
Member
 
Evolution's Avatar
 
Faction: Octavius
Joystick: Cyborg evo
Join Date: Jan 2005
Location: Chicagoland
Posts: 190
Evolution is on a distinguished road
<!-- google_ad_section_start(weight=ignore) -->Evolution<!-- google_ad_section_end --> is a Octavius pilot
Ok got it. First thing to do is paste this in as a new function. I put it right above the dTree.prototype.o function declaration just cause it was near where I was working that way. The new function returns the tree level of the node id you give it. Mmmmmm recursion. The Solrain Core node is level 0, then commodities/capacitors/etc are level 1, and so on.

Code:
dTree.prototype.getNodeLevel = function(id) {
if(this.aNodes[id].pid > -1) {
	return 1 + this.getNodeLevel(this.aNodes[id].pid);
} else {
	return 0;
}
};
Ok.. then modify the other function so it looks like this.
Code:
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) {
	if (this.getNodeLevel(id) <= this.config.maxCollapseLevel) {
	 this.closeLevel(cn);
	}
}
if (this.config.useCookies) this.updateCookie();
};
Now if you want you can add maxCollapseLevel as a config property up at the top.
Code:
// Tree object
function dTree(objName) {
this.config = {
target	 : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines	: true,
useIcons	: true,
useStatusText : false,
closeSameLevel : false,
inOrder	 : false,
maxCollapseLevel :3
}
Then you can set the maxCollapseLevel in your other JS files that create the tree. Example: in solrain_core.js
Code:
d = new dTree('d');
d.config.closeSameLevel=true;
d.config.folderLinks=false;
d.config.inOrder=true;
d.config.maxCollapseLevel=3;
blahblah adding nodes.

If you already have all of those created and don't feel like messing with that whole thing then just replace the this.config.maxCollapseLevel in the if statement under the o function with an integer. 3 in this case.

After all of that stuff the tree will collapse all sibling nodes whenever you click on a node if the node you clicked on is level 3 or lower. Whew. I'll be able to sleep.
Evolution is offline  

Old 02-15-2005, 03:26 PM   #37 (permalink)
Big Daddy
 
Jump's Avatar
 
Pilot Name: JumpDemon
Faction: Solrain
Joystick: MS FF2
Join Date: May 2004
Location: Tracy, Ca.
Posts: 6,959
Jump has a spectacular aura aboutJump has a spectacular aura about
<!-- google_ad_section_start(weight=ignore) -->Jump<!-- google_ad_section_end --> is a Solrain pilot
Works great! That would have taken me a couple of nights of research. Now I'm way ahead. Thanks.
Jump is offline  Send a message via ICQ to Jump Send a message via Yahoo to Jump

Old 02-15-2005, 03:31 PM   #38 (permalink)
Member
 
QrazyKermi's Avatar
 
Join Date: Jul 2004
Location: CT
Posts: 577
QrazyKermi is on a distinguished road
Get a room, you two.
QrazyKermi is offline  

Old 02-15-2005, 03:46 PM   #39 (permalink)
Big Daddy
 
Jump's Avatar
 
Pilot Name: JumpDemon
Faction: Solrain
Joystick: MS FF2
Join Date: May 2004
Location: Tracy, Ca.
Posts: 6,959
Jump has a spectacular aura aboutJump has a spectacular aura about
<!-- google_ad_section_start(weight=ignore) -->Jump<!-- google_ad_section_end --> is a Solrain pilot
Quote:
Originally Posted by Evolution


If you already have all of those created and don't feel like messing with that whole thing then just replace the this.config.maxCollapseLevel in the if statement under the o function with an integer. 3 in this case..
No worries there. All the station js files are created dynamically when I run the update scripts. Or at least they will be. So it will only need to be set once for this particular application.

Now I need to get to work on better tree graphics that fit Jumpgate better. *looks around for fluid.*
Jump is offline  Send a message via ICQ to Jump Send a message via Yahoo to Jump

Old 02-15-2005, 04:34 PM   #40 (permalink)
Member
 
Evolution's Avatar
 
Faction: Octavius
Joystick: Cyborg evo
Join Date: Jan 2005
Location: Chicagoland
Posts: 190
Evolution is on a distinguished road
<!-- google_ad_section_start(weight=ignore) -->Evolution<!-- google_ad_section_end --> is a Octavius pilot
Sorta nitpicky... but you might want to change one little thing. I'm not even sure if the tree would work properly if for some reason the nodes you added didn't get set up with the first node you add being id = 0 with pid = -1. If for some reason your first node was id=1 with pid=0 or some other weird thing, the getNodeLevel function would stop working correctly. Just change the -1 in the if statement to this.root.id
Code:
 dTree.prototype.getNodeLevel = function(id) {
 	if(this.aNodes[id].pid > this.root.id) {
 		return 1 + this.getNodeLevel(this.aNodes[id].pid);
 	} else {
 		return 0;
 	}
 };
That way you're covered if your id's don't start at -1

Of course we still have to assume that no matter where the id starts it always gets greater as you add nodes. You couldn't have a node with an id less than the root's pid. Just gonna have to assume that. The line must be drawn somewhere.
Evolution is offline  

Old 02-15-2005, 04:42 PM   #41 (permalink)
Member
 
Evolution's Avatar
 
Faction: Octavius
Joystick: Cyborg evo
Join Date: Jan 2005
Location: Chicagoland
Posts: 190
Evolution is on a distinguished road
<!-- google_ad_section_start(weight=ignore) -->Evolution<!-- google_ad_section_end --> is a Octavius pilot
Quote:
Originally Posted by QrazyKermi
Get a room, you two.
I already have a room with you, baby.


Glad I could help, Jump.
Evolution is offline  

Old 02-15-2005, 05:25 PM   #42 (permalink)
Big Daddy
 
Jump's Avatar
 
Pilot Name: JumpDemon
Faction: Solrain
Joystick: MS FF2
Join Date: May 2004
Location: Tracy, Ca.
Posts: 6,959
Jump has a spectacular aura aboutJump has a spectacular aura about
<!-- google_ad_section_start(weight=ignore) -->Jump<!-- google_ad_section_end --> is a Solrain pilot
I believe the root node must have a pid of -1. That's what the config file says anyway.
Jump is offline  Send a message via ICQ to Jump Send a message via Yahoo to Jump