commit 6982850beb81f60c55d09c8df0aaac5cf7409fe0
Author: Hamish Coleman <hamish@zot.org>
Date:   Wed Jun 6 23:15:23 2007 +1000

    Add frameset based treemenu implementation

diff --git a/Makefile b/Makefile
index f2b8dce..9de1cb3 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,19 @@ all:
 
 install:
 	install mrtg.cgi $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ua.js $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftiens4.js $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2folderopen.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2vertline.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2mlastnode.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2mnode.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2plastnode.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2pnode.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2blank.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2lastnode.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2node.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2folderclosed.gif $(DESTDIR)/usr/share/WWW/mrtg/
+	install Treeview/ftv2doc.gif $(DESTDIR)/usr/share/WWW/mrtg/
 
 test:
 	install mrtg.cgi $(DESTDIR)/usr/share/WWW/mrtg/mrtg1.cgi
diff --git a/mrtg.cgi b/mrtg.cgi
index 28a946d..43de399 100755
--- a/mrtg.cgi
+++ b/mrtg.cgi
@@ -203,7 +203,7 @@ sub print_menu_table($$) {
 	if ($style eq 'wide') {
 		$target="_self";
 	} else {
-		$target="list";
+		$target="basefrm";
 	}
 
 	print "\n<table border=2 cellpadding=2 cellspacing=0 style=\"margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;\">\n";
@@ -247,6 +247,26 @@ sub print_menu_table($$) {
 	print "</table>\n";
 }
 
+sub print_treemenu($) {
+	my ($lists) = @_;
+
+	print "USETEXTLINKS = 1\n";
+	print "STARTALLOPEN = 0\n";
+	print "ICONPATH = ''\n";
+	print 'foldersTree = gFld("<i>Treeview Demo</i>", "javascript:true")',"\n";
+	print 'foldersTree.treeID = "Frameset"',"\n";
+	
+	# print contents
+	for my $i (sort keys %{$lists}) {
+
+		print "m$i = insFld(foldersTree, gFld(\"$i\", \"javascript:true\"))\n";
+
+		for my $j (sort keys %{$lists->{$i}}) {
+			print "insDoc(m$i, gLnk(\"R\", \"$j\", \"?page=list&list=$i,$j\"))\n";
+		}
+	}
+}
+
 sub print_list($$$) {
 	my ($lists,$graph,$list) = @_;
 
@@ -273,7 +293,7 @@ sub print_list($$$) {
 		$ysize = $router->{ysize};
 		$xsize = $router->{xsize};
 
-		print a({-href=>$router->{name}.".html",-target=>"list"},
+		print a({-href=>$router->{name}.".html",-target=>"basefrm"},
 			img{
 				-src=>$router->{name}."-$graph.".$router->{imagetype},
 				-height=>"$ysize",
@@ -321,7 +341,7 @@ sub print_graph_chooser($$) {
 		'(This List is ',param('list'),")\n";
 }
 
-my $page = param('page') || 'none';
+my $page = param('page') || 'treeview';
 my $this_host = hostname;
 my @tests;
 my $lists;
@@ -329,28 +349,23 @@ my $lists;
 if($page eq 'frame') {
 	print "Content-type: text/html\n\n";
 	print "<html><head><title>$this_host MRTG Index (V$VERSION)</title></head>\n";
-	print '<frameset cols="200,*">'; # FIXME onresize if navigator.family==nn4
-	print '<frame src="?page=menu" name=menu>';
-	print '<frame src="?page=list&list=OTHER,OTHER" name=list>';
+	print '<frameset cols="200,*">';
+	print '<frame src="?page=menu" name=treeframe>';
+	print '<frame src="?page=list&list=OTHER,OTHER" name=basefrm>';
 	print "</frameset>\n";
 	print "</html>\n";
 
-} elsif($page eq 'none') {
-	print header,
-		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
-		"\n";
-
-	@tests = init_tests(@config_files);
-	$lists = init_lists(@tests);
-	print table(
-		{-width=>"100\%"},
-		TR(td("Select which list to show"))
-	);
-	print_menu_table($lists,'wide');
-	print "\n","Direct questions and feedback to ",
-		a({-href=>"mailto:hamish\@zot.org"}, "Hamish"),
-		" (Version $VERSION)",
-		end_html;
+} elsif($page eq 'treeview') {
+	print "Content-type: text/html\n\n";
+	print "<html><head><title>$this_host MRTG Index (V$VERSION)</title></head>\n";
+	print "<script>\n";
+	print "function op() { }\n";
+	print "</script>\n";
+	print '<frameset cols="200,*">'; # FIXME onresize if navigator.family==nn4
+	print '<frame src="?page=treemenu" name=treeframe>';
+	print '<frame src="javascript:true" name=basefrm>';
+	print "</frameset>\n";
+	print "</html>\n";
 
 } elsif($page eq 'list') {
 	print header,
@@ -385,6 +400,24 @@ if($page eq 'frame') {
 	@tests = init_tests(@config_files);
 	$lists = init_lists(@tests);
 	print_menu_table($lists,'high');
+	print end_html;
+} elsif($page eq 'treemenu') {
+	print header,
+		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
+		"\n";
+
+	@tests = init_tests(@config_files);
+	$lists = init_lists(@tests);
+	
+	print '<script src="ua.js"></script>';
+	print '<script src="ftiens4.js"></script>';
+	print '<script>';
+	print_treemenu($lists);
+	print '</script>';
+	print '<DIV style="position:absolute; top:0; left:0;"><TABLE border=0><TR><TD><FONT size=-2><A style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>Javascript Tree Menu</A></FONT></TD></TR></TABLE></DIV>';
+	print '<script>initializeDocument()</script>';
+	print '<NOSCRIPT>A tree for site navigation will open here if you enable JavaScript in your browser.</NOSCRIPT>';
+
 	print end_html;
 } elsif($page eq 'noframe') {
 	print header,
@@ -423,6 +456,23 @@ if($page eq 'frame') {
 	print "</table>\n";
 	print end_html;
 	
+} elsif($page eq 'none') {
+	print header,
+		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
+		"\n";
+
+	@tests = init_tests(@config_files);
+	$lists = init_lists(@tests);
+	print table(
+		{-width=>"100\%"},
+		TR(td("Select which list to show"))
+	);
+	print_menu_table($lists,'wide');
+	print "\n","Direct questions and feedback to ",
+		a({-href=>"mailto:hamish\@zot.org"}, "Hamish"),
+		" (Version $VERSION)",
+		end_html;
+
 }
 
 if ($warnings) {
