/[cricket]/generate-overview.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /generate-overview.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Fri Jun 28 09:28:36 2002 UTC revision 1.10 by dpavlin, Sat May 24 12:21:42 2003 UTC
# Line 34  BEGIN { Line 34  BEGIN {
34          # You need to update this to point to the URL          # You need to update this to point to the URL
35          # you use to access Cricket.          # you use to access Cricket.
36  #       $gBaseURL = "http://localhost/~cricket/grapher.cgi";  #       $gBaseURL = "http://localhost/~cricket/grapher.cgi";
37          $gBaseURL = "http://romul.pliva.hr/cgi-bin/cricket/grapher.cgi";          my $hostname = `hostname -f`;
38            chomp($hostname);
39            $gBaseURL = "http://$hostname/cgi-bin/cricket/grapher.cgi";
40    
41          # change this to destination directory          # change this to destination directory
42          $path = "/home/dpavlin/public_html";          $path = "/data/mon/";
         # this is basename of all html files  
         $name = "overview";  
43  }  }
44    
45  #use lib "$gInstallRoot/../lib";  #use lib "$gInstallRoot/../lib";
# Line 57  use Common::Map; Line 57  use Common::Map;
57  use Common::Options;  use Common::Options;
58  use Common::Log;  use Common::Log;
59    
60    #
61    # Set this option to 0 if you don't want JavaScript roll-up/roll-down
62    # of images to be created
63    #
64    my $dynamic_js = 1;
65    
66  Common::Options::commonOptions( 'baseURL=s' => \$gBaseURL );  Common::Options::commonOptions( 'baseURL=s' => \$gBaseURL );
67  initConst();  initConst();
68    
# Line 87  foreach $subtree (@ARGV) { Line 93  foreach $subtree (@ARGV) {
93      }      }
94  }  }
95    
96  foreach my $filename (keys %html) {  my %html_file;
97    
98    foreach my $item (sort keys %html) {
99            my ($range,$target) = split(/\t/,$item,2);
100            my (undef,$service,$arg) = split(/\//,$target,3);
101    
102            $html_file{"$range/$service"} .= $html{$item};
103            $html_file{"overview-$range"} .= $html{$item};
104    }
105    
106    foreach my $key (keys %html_file) {
107    
108            my $filename = "$path/$key.html";
109            my($dir) = dirname($filename);
110            if (! -d $dir) {
111               Info("Making directory $dir to hold file $filename.");
112               Common::Util::MkDir($dir);
113            }
114            Info("Dumping HTML for $key to $filename.");
115          open(OUT,"> $filename") || die "can't open output html '$filename': $!";          open(OUT,"> $filename") || die "can't open output html '$filename': $!";
116          print OUT $html{$filename},"</body></html>";          print OUT "<html><head><title>$key</title>";
117            print OUT '<meta content="no-cache" http-equiv="Pragma">
118                    <meta content="300" http-equiv="Refresh">' if ($filename =~ m/Daily/i);
119            print OUT <<'HTMLEND' if ($dynamic_js);
120    
121    <script language="JavaScript">
122    var Selected = "";
123    
124    function Switch(elm)
125    {
126            var cookie = Get_Cookie("overview");
127    
128            var elmref;
129    
130            // uncomment following lines for just 1 selected content
131    /*
132            if (Selected != "")
133            {
134                    elmref = eval("document.getElementById('" + Selected + "_h1')");
135                    if (elmref) elmref.style.display = 'none';
136                    elmref = eval("document.getElementById('" + Selected + "_h0')");
137                    // roll-up color
138                    if (elmref) elmref.bgColor = '#eeeeee';
139            }
140            if (Selected != elm.name)
141            {
142                    Selected = elm.name;
143                    elmref = eval("document.getElementById('" + Selected + "_h1')");
144                    if (elmref)
145                    {
146                            if (elmref.style.display=='none') elmref.style.display='';
147                            else elmref.style.display = 'none';
148                    }
149                    elmref = eval("document.getElementById('" + Selected + "_h0')");
150                    // roll-down color
151                    if (elmref) elmref.bgColor = '#ffffff';
152            }
153            else
154                    Selected="";
155    */
156    
157            // or use this to unroll more than one line
158            Selected = elm.name;
159            elmref = eval("document.getElementById('" + Selected + "_h1')");
160            if (elmref)
161            {
162                    if (elmref.style.display=='none') elmref.style.display='';
163                    else elmref.style.display = 'none';
164                    cookie ^= 1 << Selected;
165            }
166    
167            Set_Cookie("overview",cookie);
168            return false;
169    }
170    
171    function SwitchThis()
172    {
173            return Switch(this);
174    }
175    
176    
177    </script>
178    
179    <table border=0 id=DynamicTable bgColor='#e0e0e0' cellpadding=2 cellspacing=1>
180    
181    HTMLEND
182            print OUT "</head><body>";
183            print OUT $html_file{$key};
184            print OUT <<'HTMLEND' if ($dynamic_js);
185    </table>
186    
187    <script language=javascript>
188    
189    function Get_Cookie(name) {
190        var start = document.cookie.indexOf(name+"=");
191        var len = start+name.length+1;
192        if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
193        if (start == -1) return null;
194        var end = document.cookie.indexOf(";",len);
195        if (end == -1) end = document.cookie.length;
196        return unescape(document.cookie.substring(len,end));
197    }
198    
199    function Set_Cookie(name,value,expires,path,domain,secure) {
200        document.cookie = name + "=" +escape(value) +
201            ( (expires) ? ";expires=" + expires.toGMTString() : "") +
202            ( (path) ? ";path=" + path : "") +
203            ( (domain) ? ";domain=" + domain : "") +
204            ( (secure) ? ";secure" : "");
205    }
206    
207    function Delete_Cookie(name,path,domain) {
208        if (Get_Cookie(name)) document.cookie = name + "=" +
209           ( (path) ? ";path=" + path : "") +
210           ( (domain) ? ";domain=" + domain : "") +
211           ";expires=Thu, 01-Jan-70 00:00:01 GMT";
212    }
213    
214    var table = document.getElementById("DynamicTable");
215    var links = table.getElementsByTagName("a");
216    var cookie = Get_Cookie("overview");
217    var new_cookie = 0;
218    for (var i = 0; i < links.length; i++) {
219        if (links[i].id == "DynMessLink") {
220            links[i].onclick = SwitchThis;
221            elmref = eval("document.getElementById('" + links[i].name + "_h1')");
222            if (elmref && cookie) {
223                    if (cookie & 1 << links[i].name) {
224                            elmref.style.display='';
225                    } else {
226                            elmref.style.display = 'none';
227                    }
228            } else if(elmref) {
229                    if (elmref.style.display=='none') {
230                            elmref.style.display='';
231                            new_cookie |= 1 << links[i].name;
232                    } else {
233                            elmref.style.display = 'none';
234                            //new_cookie &= !( 1 << links[i].name );
235                    }
236            }
237        }
238    }
239    if (new_cookie) Set_Cookie("overview",new_cookie);
240    </script>
241    HTMLEND
242    
243            print OUT "</body></html>";
244          close(OUT);          close(OUT);
245    
246  }  }
247    
248  exit;  exit;
249    
250    sub do_html {
251            my ($desc,$url,$img) = @_;
252            if ($dynamic_js) {
253                    my $html =<<'HTMLEND';
254    <tr bgcolor='#eeeeee' id=##id##_h0>
255    <td><a href="#" id=DynMessLink name=##id## >##desc##</a></td>
256    </tr>
257    <tr id=##id##_h1 style='display:none' bgcolor='#ffffff' >
258    <td><a href="##url##"><img src="##img##"</td>
259    </tr>
260    HTMLEND
261                    $html =~ s/##desc##/$desc/;
262                    $html =~ s/##url##/$url/;
263                    $html =~ s/##img##/$img/;
264                    $html =~ s/##id##/$dynamic_js/g;
265                    $dynamic_js++;                  # increment usage counter
266                    return $html;
267            } else {
268                    return "$desc<br><a href=\"$url\"><img src=\"$img\"></a><br>\n";
269            }
270    }
271    
272  sub localHandleTargetInstance {  sub localHandleTargetInstance {
273          my($Name, $target) = @_;          my($Name, $target) = @_;
274    
# Line 145  sub localHandleTargetInstance { Line 319  sub localHandleTargetInstance {
319    
320                                  my($dslist);                                  my($dslist);
321    
                                 my($filename)="$path/$name-$rangeLabel.html";  
                                 if (! defined $html{$filename}) {  
                                         $html{$filename}="<html><head><title>$rangeLabel</title></head><body>";  
                                 }  
                                 my($dir) = dirname($filename);  
                                 if (! -d $dir) {  
                                    Info("Making directory $dir to hold file $filename.");  
                                    Common::Util::MkDir($dir);  
                                 }  
   
322                                  if (defined($ttRef->{'view'}))                                  if (defined($ttRef->{'view'}))
323                                  {                                  {
324                                          my($v);                                          my($v);
# Line 169  sub localHandleTargetInstance { Line 333  sub localHandleTargetInstance {
333    
334                                                  $URL = "$gBaseURL?type=png&target=$paramtarget";                                                  $URL = "$gBaseURL?type=png&target=$paramtarget";
335                                                  $URL .= "&dslist=$dslist&range=$paramrange";                                                  $URL .= "&dslist=$dslist&range=$paramrange";
336                                                  my $desc = "view: ";                                                      my $desc = "$paramtarget $vname";
337                                                    $desc .= " <b>".$target->{'short-desc'}."</b>" if (defined $target->{'short-desc'});
338                                                  if ($paraminst ne "") {                                                  if ($paraminst ne "") {
339                                                          $URL .= "&inst=$paraminst";                                                          $URL .= "&inst=$paraminst";
                                                         $desc.="$paraminst $paramtarget $vname";  
                                                 } else {  
                                                         $desc.="$paramtarget $vname";  
340                                                  }                                                  }
341    
342                                                  Info("Retrieving graph for $desc");                                                  Info("Retrieving graph for $desc");
343  #                                               getURL($URL,"$path/$name-$vname-$rangeLabel.png");  #                                               getURL($URL,"$path/$name-$vname-$rangeLabel.png");
344                                                  $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname";                                                  $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname";
345                                                  $html{$filename}.="$desc<br><a href=\"$tmp_URL\"><img src=$URL></a><br>";                                                  $html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL);
346                                          }                                          }
347                                  } else {                                  } else {
348                                          $dslist = $ttRef->{'ds'};                                          $dslist = $ttRef->{'ds'};
# Line 189  sub localHandleTargetInstance { Line 351  sub localHandleTargetInstance {
351    
352                                          $URL = "$gBaseURL?type=png&target=$paramtarget";                                          $URL = "$gBaseURL?type=png&target=$paramtarget";
353                                          $URL .= "&dslist=$dslist&range=$paramrange";                                          $URL .= "&dslist=$dslist&range=$paramrange";
354                                          my $desc = "ds: ";                                                my $desc ="$paraminst $rangeLabel";
355                                            $desc .= " <b>".$target->{'short-desc'}."</b>" if (defined $target->{'short-desc'});
356                                          if ($paraminst ne "") {                                          if ($paraminst ne "") {
357                                                  $URL .= "&inst=$paraminst";                                                  $URL .= "&inst=$paraminst";
                                                 $desc.="$paraminst $rangeLabel"  
                                         } else {  
                                                 $desc.="$paramtarget $rangeLabel";  
358                                          }                                          }
359    
360                                          Info("Retrieving graph for $desc");                                          Info("Retrieving graph for $desc");
361    
362  #                                       getURL($URL,"$path/$name-$rangeLabel.png");  #                                       getURL($URL,"$path/$name-$rangeLabel.png");
363                                          $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y";                                          $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y";
364                                          $html{$filename}.="$desc:<br><a href=\"$tmp_URL\"><img src=$URL><a/><br>";                                          $html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL);
365                                  }                                  }
366                          }                          }
367                  }                  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.26