commit ebfd527a2ae59c68d37b165d5d58c0c0f5e48fa7
Author: Hamish Coleman <colemah3@osiris.localdomain>
Date:   Tue Aug 14 12:18:36 2007 +1000

    Initial implentation of frameless menus

diff --git a/mrtg.cgi b/mrtg.cgi
index 371033c..60a2a63 100755
--- a/mrtg.cgi
+++ b/mrtg.cgi
@@ -10,7 +10,7 @@
 #
 # Requires the CGI package (in mandriva this is perl-CGI)
 
-our $VERSION=3;
+our $VERSION=4;
 
 use strict;
 use warnings;
@@ -240,23 +240,35 @@ sub print_menu_table($$$$) {
 	print "</table>\n";
 }
 
-sub print_treemenu($) {
-	my ($lists) = @_;
+sub print_treemenu($$) {
+	my ($style,$lists) = @_;
 
+	my $page = 'list';
+	my $target = 'R';
+
+	if ($style ne 'frame') {
+		print "USEFRAMES = 0\n";
+		print "PRESERVESTATE =1\n";
+		# USEICONS = 0
+		# WRAPTEXT = 1
+		$page=$style;	
+		$target='S';
+	}
 	print "USETEXTLINKS = 1\n";
 	print "STARTALLOPEN = 0\n";
 	print "HIGHLIGHT = 1\n";
 	print "ICONPATH = ''\n";
-	print 'foldersTree = gFld("<i>MRTG Tree</i>", "javascript:parent.op()")',"\n";
-	print 'foldersTree.treeID = "Frameset"',"\n";
+
+	print 'foldersTree = gFld("<i>MRTG Tree</i>", "javascript:undefined")',"\n";
+	print 'foldersTree.treeID = "Frameless"',"\n";
 	
 	# print contents
 	for my $i (sort keys %{$lists}) {
 
-		print "m$i = insFld(foldersTree, gFld(\"$i\", \"javascript:parent.op()\"))\n";
+		print "m$i = insFld(foldersTree, gFld(\"$i\", \"javascript:undefined\"))\n";
 
 		for my $j (sort keys %{$lists->{$i}}) {
-			print "insDoc(m$i, gLnk(\"R\", \"$j\", \"?page=list&list=$i,$j\"))\n";
+			print "insDoc(m$i, gLnk(\"$target\", \"$j\", \"?page=$page&list=$i,$j\"))\n";
 		}
 	}
 }
@@ -337,6 +349,16 @@ sub print_graph_chooser($$$$) {
 	print '(This List is ',param('list'),")\n";
 }
 
+sub print_menutypelist() {
+	print a({-href=>"?page=none",-target=>"_top"}, "Old menu");
+	print br;
+	print a({-href=>"?page=noframe",-target=>"_top"}, "No frames");
+	print br;
+	print a({-href=>"?page=frame",-target=>"_top"}, "Basic frames");
+	print br;
+	print a({-href=>"?page=treenf",-target=>"_top"}, "Menu (NF)");
+}
+
 my $page = param('page') || 'treeview';
 my $this_host = hostname;
 my @tests;
@@ -406,21 +428,149 @@ if($page eq 'frame') {
 
 	@tests = init_tests(@config_files);
 	$lists = init_lists(@tests);
-	
+
+	print <<EOF;
+  <STYLE>
+    BODY {
+      background-color: white;}
+    TD {
+      font-size: 10pt; 
+      font-family: verdana,helvetica; 
+      text-decoration: none;
+      white-space:nowrap;}
+    A {
+      text-decoration: none;
+      color: black;}
+    .specialClass {
+      font-family:garamond; 
+      font-size:12pt;
+      color:green;
+      font-weight:bold;
+      text-decoration:underline}
+  </STYLE>
+EOF
 	print '<script src="ua.js"></script>';
 	print '<script src="ftiens4.js"></script>';
 	print '<script>';
-	print_treemenu($lists);
+	print_treemenu('frame',$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 hr;
-	print a({-href=>"?page=none",-target=>"_top"}, "Old menu");
-	print br;
-	print a({-href=>"?page=noframe",-target=>"_top"}, "No frames");
-	print br;
-	print a({-href=>"?page=frame",-target=>"_top"}, "Basic frames");
+	print_menutypelist();
+
+	print end_html;
+} elsif($page eq 'treenf') {
+	print header,
+		start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)",
+			-bgcolor=>"white",
+			-leftmargin=>"0", -topmargin=>"0",
+			-marginheight=>"0", -marginwidth=>"0",
+			-onResize=>"if (navigator.family == 'nn4') window.location.reload()" ),
+		"\n";
+
+	@tests = init_tests(@config_files);
+	$lists = init_lists(@tests);
+
+	print <<EOF;
+  <STYLE>
+   /*                                                          */
+   /* Styles for the tree.                                     */
+   /*                                                          */
+   SPAN.TreeviewSpanArea A {
+     font-size: 10pt; 
+     font-family: verdana,helvetica; 
+     text-decoration: none;
+     color: black;}
+   SPAN.TreeviewSpanArea A:hover {
+     color: '#820082';}
+
+   /*                                                          */
+   /* Styles for the remainder of the document.                */
+   /*                                                          */
+   BODY {
+     background-color: white;}
+   TD {
+     font-size: 10pt; 
+     font-family: verdana,helvetica;}
+  </STYLE>
+EOF
+	print '<script src="ua.js"></script>';
+	print '<script src="ftiens4.js"></script>';
+	print '<script>';
+	print_treemenu('treenf',$lists);
+	print '</script>';
+	print <<EOF;
+ <TABLE cellpadding="0" cellspacing="0" border="0" width="772">
+  <TR>
+   <TD width="178" valign="top">
+
+    <TABLE cellpadding="4" cellspacing="0" border="0" width="100%">
+     <TR>
+      <TD bgcolor="#ECECD9">
+
+        <TABLE cellspacing="0" cellpadding="2" border="0" width="100%">
+         <TR>
+          <TD bgcolor="white">
+
+ <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>
+
+ <SPAN class=TreeviewSpanArea>
+  <SCRIPT>initializeDocument()</SCRIPT>
+  <NOSCRIPT>
+   A tree for site navigation will open here if you enable JavaScript in your browser.
+  </NOSCRIPT>
+ </SPAN>
+EOF
+
+	print hr;
+	print_menutypelist();
+	print <<EOF;
+          </TD>
+         </TR>
+        </TABLE>
+
+       </TD>
+      </TR>
+     </TABLE>
+
+    </TD>
+    <TD bgcolor="white" valign="top">
+
+     <TABLE cellpadding="10" cellspacing="0" border="0" width="100%">
+      <TR>
+       <TD>
+EOF
+
+	# Time the next update to occur a little while after the next interval completes
+	my $interval = 300; # 5 min update interval
+	my $guardband = 15; # updates occur this many seconds after predicted gif completion
+	my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
+	$refresh = $interval if $refresh <= $guardband;
+	my $expires = gmtime (time + $interval * 2 + $guardband);
+
+	my $list = param('list');
+	my $graph = param('graph') || 'day';
+
+	print
+		"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
+		"<meta http-equiv=\"refresh\" content=$refresh>\n";
+	if ($list) {
+		print_graph_chooser($graph,$list,$page,'none');
+		print "<br/>";
+		print_list($lists,$graph,$list,'basefrm');
+	}
+
+	print <<EOF;
+       </TD>
+      </TR>
+     </TABLE>
+
+    </TD>
+   </TR>
+  </TABLE>
+EOF
 
 	print end_html;
 } elsif($page eq 'noframe') {
