print "Content-Type: text/plain\n\n";
}
+our @navsettings;
+
+sub navsetting ($) {
+ my ($nav) = @_;
+ my $var= $nav->{Variable};
+ $$var= param($nav->{Param});
+ $$var= $nav->{Default} if !defined $$var;
+ die $nav->{Param} unless grep { $_ eq $$var } @{ $nav->{Values} };
+ push @navsettings, $nav;
+}
+
+our $section;
+
+navsetting({
+ Desc => 'Section',
+ Param => 'section',
+ Variable => \$section,
+ Default => $sections[0],
+ Values => [@sections],
+ Show => sub { return $_[0]; }
+});
+
+
my $gname= param('graph');
-my $section= param('section');
-$section ||= $sections[0];
-die unless $sections{$section};
if ($gname) {
my $g= $graphs{$section,$gname};
sub start_page ($) {
my ($title) = @_;
print header(), start_html($title);
- my $delim= '';
- foreach my $s2 (@sections) {
- print $delim;
- if ($s2 eq $section) {
- print "<b>$section</b>";
- } else {
- print "<a href=\"$self";
- if ($s2 ne $sections[0]) { print "?section=$s2"; }
- print "\">$s2</a>";
+ my $outerdelim= '';
+ foreach my $nav (@navsettings) {
+ print $outerdelim;
+ print $nav->{Desc}, ": ";
+ my $delim= '';
+ my $current= $nav->{Variable}; $current= $$current;
+ foreach my $couldbe (@{ $nav->{Values} }) {
+ print $delim;
+ my $show= $nav->{Show}($couldbe);
+ if ($couldbe eq $current) {
+ print "<b>$show</b>";
+ } else {
+ print "<a href=\"$self";
+ my $delim2= '?';
+ foreach my $nav2 (@navsettings) {
+ my $current2= $nav2->{Variable}; $current2= $$current2;
+ $current2= $couldbe if $nav2->{Param} eq $nav->{Param};
+ next if $current2 eq $nav2->{Default};
+ print $delim2, "$nav2->{Param}=$current2";
+ $delim2= '&';
+ }
+ print "\">$show</a>";
+ }
+ $delim= ' | ';
}
- $delim= ' | ';
+ $outerdelim= "<br>\n";
}
+ print "\n";
+
print h1("$title");
}
exit 0;
}
+our $sloth;
+
+navsetting({
+ Desc => 'Time interval',
+ Param => 'sloth',
+ Variable => \$sloth,
+ Default => 1,
+ Values => [0..2],
+ Show => sub {
+ my ($sl) = @_;
+ return ('Narrower', 'Normal', 'Wider')[$sl];
+ }
+});
+
if (param('debug')) {
use Data::Dumper;
print Dumper(\%graphs);
foreach my $gname (@{ $sections{$section} }) {
my $g= $graphs{$section,$gname};
print "<a href=\"$self?detail=$gname§ion=$section\">";
- my $end= $timeranges[$g->{Slower}+1];
+ my $end= $timeranges[$g->{Slower}+$sloth];
my $imgurl= "$self?graph=$gname§ion=$section&end=$end";
print "<img src=\"$imgurl\"></a>\n";
}