Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, dr_panther, 2 invisible), 1,056 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Dynamic sorted gamestudio manual #310638
02/16/10 07:08
02/16/10 07:08
Joined: Mar 2009
Posts: 112
Germany
K
KDuke Offline OP
Member
KDuke  Offline OP
Member
K

Joined: Mar 2009
Posts: 112
Germany
Hello people. I somehow got fedup with the navigation-structure of the Online Manual so I wrote a small javascript-Tool which rebuilds the navigation structure dynamically and provides a foldable navigation.

I tested it successfully with Firefox 3.6, 3.0.15, 2.0.0.20 and Internet Explorer 8 which works flawlessly.

Follow this link for the guide

Now you should be able to unfold and fold the menus by clicking on the book-images in front of the links.

Here is the code again in readable form.
Code:
function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else{
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
} 


function CreateTree(TreeData, Level) {
 var Counter = 0;
 var SearchString = '\\n';
 for(Counter = 0; Counter < Level; Counter++) {
  SearchString += '\\s\\s\\s';
 }
 SearchString += '\\<';
 var RegularExp = new RegExp(SearchString, '');
 var NewTree = TreeData.split(RegularExp);
 var Length = NewTree.length;
 
 var SearchString = '\\n';
 for(Counter = 0; Counter < Level+1; Counter++) {
  SearchString += '\\s\\s\\s';
 }
 SearchString += '\\<';
 RegularExp = new RegExp(SearchString, '');
 
 for (Counter = 0; Counter < Length; Counter++) {
  if(typeof(NewTree) == 'object') {
   if(NewTree[Counter].charAt(0) != '<') {
    NewTree[Counter] = '<'+NewTree[Counter];
   }
   if(NewTree[Counter].match(RegularExp)) {
    NewTree[Counter] = CreateTree(NewTree[Counter], Level + 1);
   }
  } else {
   if(NewTree.charAt(0) != '<') {
    NewTree = '<'+NewTree;
   }
  }
 }
 return NewTree;
}

function genTreeHTML(Tree, Level) {
 var Output = '<ul style=\'display:none\' class=\'Cat'+Level+'\' id=\'Cat'+Level+'\'>';
 var Element;
 var Counter = 0;
 for(Counter = 0; Counter <  Tree.length; Counter++) {
  if(typeof(Tree[Counter]) != 'object') {
   Output += '<li class=\'Ebene'+Level+'\' id=\'Menu'+Level+'.'+Counter+'\'>'+Tree[Counter]+'</li>';
  } else {
   Output += '<li class=\'Ebene'+Level+'\' id=\'Menu'+Level+'.'+Counter+'\'>'+Tree[Counter][0];
   Tree[Counter].splice(0,1);
   Output += genTreeHTML(Tree[Counter], Level+'.'+Counter)+'</li>';
  }
 }
 Output += '</ul>';
 return Output;
}

function HandleMouse(evt) {
	var pointer;
	if(evt.target) { var MyTarget = evt.target;}
	else { var MyTarget = evt.srcElement;}
	if(MyTarget.tagName == 'IMG') {
		var MenuTarget = MyTarget.parentNode.lastChild;
		if(MenuTarget.tagName == 'UL') {
			if(MenuTarget.style.display == 'none') {
				MenuTarget.style.display = 'inline';
			} else {
				MenuTarget.style.display = 'none';
			}
		}
	} 
}

function GenTree() {
	var Test = document.getElementsByName('menue')[0];
	var UsingIE = false;
	if(Test.contentDocument != null) {
		Test = Test.contentDocument;
	} else {
		Test = Test.contentWindow.document;
	}
    
	var MyStyle = document.createElement('link');
	MyStyle.setAttribute('type','text/css');
	MyStyle.setAttribute('rel','stylesheet');
	MyStyle.setAttribute('href','http://gpi-studios.com/3dgs/gsdynmenu.css');
	Test.getElementsByTagName('head')[0].appendChild(MyStyle);
	var preObj = Test.getElementsByTagName('pre')[0];
	var MyTree = CreateTree(preObj.innerHTML, 0);
	var MenuContainer = Test.createElement('div');
	MenuContainer.setAttribute('id','Menu');
	Test.body.appendChild(MenuContainer);
	preObj.style.display = 'none';
	Test.getElementById('Menu').innerHTML = genTreeHTML(MyTree, '0');
	AttachEvent(Test, 'click', HandleMouse, false);
	Test.getElementById('Cat0').style.display = 'inline';
}



Please let me know how it works for you.

PS: I hope this is the right forum for this. If not please move it to a more appropriate place.

greetings
K-Duke

Last edited by KDuke; 02/17/10 21:07.

Using A7 Free
Click and join the 3dgs irc community!
Room: #3dgs
Re: Dynamic sorted gamestudio manual [Re: KDuke] #310678
02/16/10 14:32
02/16/10 14:32
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Like this?

"http://conitec.net/beta/javascript:"

I tried different ways, but I can't get it working. I always get something like "OMG - You broke the internet.."
I tried it with Netscape, Firefox and Explorer, nothing worked.
I never could paste more than one line in the adress row.
I have Win XP. Do I need to have anything special installed?

Re: Dynamic sorted gamestudio manual [Re: Pappenheimer] #310682
02/16/10 14:42
02/16/10 14:42
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
i tried and did see a format change but wasnt exactly sure what i was to be looking for though laugh

Re: Dynamic sorted gamestudio manual [Re: KDuke] #310703
02/16/10 16:20
02/16/10 16:20
Joined: Jun 2006
Posts: 214
Germany, NRW
T
TheThinker Offline
Member
TheThinker  Offline
Member
T

Joined: Jun 2006
Posts: 214
Germany, NRW
I like it.

Firefox 3.6 - no problems

Re: Dynamic sorted gamestudio manual [Re: TheThinker] #310709
02/16/10 16:46
02/16/10 16:46
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Firefox 3.0.15 doesn't work, too. At least I can see the whole code in the adress row now.

Re: Dynamic sorted gamestudio manual [Re: Pappenheimer] #310712
02/16/10 16:59
02/16/10 16:59
Joined: May 2009
Posts: 137
Ohio, U.S.A.
PigHunter Offline
Member
PigHunter  Offline
Member

Joined: May 2009
Posts: 137
Ohio, U.S.A.
Nice. Working here, Firefox 3.6. Thank you!

Re: Dynamic sorted gamestudio manual [Re: PigHunter] #310728
02/16/10 18:20
02/16/10 18:20
Joined: Mar 2009
Posts: 112
Germany
K
KDuke Offline OP
Member
KDuke  Offline OP
Member
K

Joined: Mar 2009
Posts: 112
Germany
Maybe I didn't explain it quite well. Well I made a small "guide" on using this. I had to put it onto my webserver as a small html-page as the array operators '[' and ']' don't allow me to put the code into ubb url tags here.

Follow this link for the guide

I as well edit the first post to include that.

For those this doesn't work would you please give me a description of what happens on you and which browser you are using as well as its version.
I will try to make this work for every browser.

EDIT: Oh yeah! Please give critics (positive and negative) as well as suggestions for further features. But cross-browser compatabilty is my highest priority right now.

Last edited by KDuke; 02/16/10 18:31.

Using A7 Free
Click and join the 3dgs irc community!
Room: #3dgs
Re: Dynamic sorted gamestudio manual [Re: KDuke] #310736
02/16/10 18:54
02/16/10 18:54
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Firefox 3.57.4 - Works laugh

Re: Dynamic sorted gamestudio manual [Re: Rei_Ayanami] #310745
02/16/10 19:29
02/16/10 19:29
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Firefox 3.6, works perfectly. Thanks! laugh

Re: Dynamic sorted gamestudio manual [Re: Cowabanga] #310765
02/16/10 21:18
02/16/10 21:18
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
It works with the last instructions, via bookmark. At least it seems, because I don't see the difference, and therefor the advantage.
But, I'll take a closer look as soon as I have more time.
What do you mean by 'foldable navigation'?

Page 1 of 2 1 2

Moderated by  aztec, Blink, HeelX 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1