/[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.6 by dpavlin, Mon Sep 9 15:17:54 2002 UTC revision 1.12 by dpavlin, Sat May 24 13:22:24 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 = "/data/mon/";          $path = "/data/mon/";
# Line 55  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 105  foreach my $key (keys %html_file) { Line 113  foreach my $key (keys %html_file) {
113          }          }
114          Info("Dumping HTML for $key to $filename.");          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><head><title>$key</title></head><body>";          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 '</head><body>';
120            my $html=<<'HTMLEND';
121    
122    <script language="JavaScript">
123    var Selected = "";
124    
125    function Switch(elm)
126    {
127            var cookie = Get_Cookie("##cookie_name##");
128    
129            var elmref;
130    
131            // uncomment following lines for just 1 selected content
132    /*
133            if (Selected != "")
134            {
135                    elmref = eval("document.getElementById('" + Selected + "_h1')");
136                    if (elmref) elmref.style.display = 'none';
137                    elmref = eval("document.getElementById('" + Selected + "_h0')");
138                    // roll-up color
139                    if (elmref) elmref.bgColor = '#e0e0e0';
140            }
141            if (Selected != elm.name)
142            {
143                    Selected = elm.name;
144                    elmref = eval("document.getElementById('" + Selected + "_h1')");
145                    if (elmref)
146                    {
147                            if (elmref.style.display=='none') elmref.style.display='';
148                            else elmref.style.display = 'none';
149                    }
150                    elmref = eval("document.getElementById('" + Selected + "_h0')");
151                    // roll-down color
152                    if (elmref) elmref.bgColor = '#ffffff';
153            }
154            else
155                    Selected="";
156    */
157    
158            // or use this to unroll more than one line
159            Selected = elm.name;
160            elmref = eval("document.getElementById('" + Selected + "_h1')");
161            elmref0 = eval("document.getElementById('" + Selected + "_h0')");
162            if (elmref)
163            {
164                    if (elmref.style.display=='none') {
165                            elmref.style.display='';
166                            if (elmref0) elmref0.bgColor = '#eeeeee';
167                    } else {
168                            elmref.style.display = 'none';
169                            if (elmref0) elmref0.bgColor = '#e0e0e0';
170                    }
171                    cookie ^= 1 << Selected;
172            }
173    
174            Set_Cookie("##cookie_name##",cookie);
175            return false;
176    }
177    
178    function SwitchThis()
179    {
180            return Switch(this);
181    }
182    
183    
184    </script>
185    
186    <table border=0 id=DynamicTable bgColor='#e0e0e0' cellpadding=2 cellspacing=1>
187    
188    HTMLEND
189            if ($dynamic_js) {
190                    my $cookie_name = $key;
191                    $cookie_name =~ s/[^a-zA-Z0-9]//g;
192                    $html =~ s/##cookie_name##/$cookie_name/g;
193                    print OUT $html;
194            }
195    
196          print OUT $html_file{$key};          print OUT $html_file{$key};
197            $html = <<'HTMLEND';
198    </table>
199    
200    <script language=javascript>
201    
202    function Get_Cookie(name) {
203        var start = document.cookie.indexOf(name+"=");
204        var len = start+name.length+1;
205        if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
206        if (start == -1) return null;
207        var end = document.cookie.indexOf(";",len);
208        if (end == -1) end = document.cookie.length;
209        return unescape(document.cookie.substring(len,end));
210    }
211    
212    function Set_Cookie(name,value,expires,path,domain,secure) {
213        document.cookie = name + "=" +escape(value) +
214            ( (expires) ? ";expires=" + expires.toGMTString() : "") +
215            ( (path) ? ";path=" + path : "") +
216            ( (domain) ? ";domain=" + domain : "") +
217            ( (secure) ? ";secure" : "");
218    }
219    
220    function Delete_Cookie(name,path,domain) {
221        if (Get_Cookie(name)) document.cookie = name + "=" +
222           ( (path) ? ";path=" + path : "") +
223           ( (domain) ? ";domain=" + domain : "") +
224           ";expires=Thu, 01-Jan-70 00:00:01 GMT";
225    }
226    
227    var table = document.getElementById("DynamicTable");
228    var links = table.getElementsByTagName("a");
229    var cookie = Get_Cookie("##cookie_name##");
230    var new_cookie = 0;
231    for (var i = 0; i < links.length; i++) {
232        if (links[i].id == "DynMessLink") {
233            links[i].onclick = SwitchThis;
234            elmref = eval("document.getElementById('" + links[i].name + "_h1')");
235            elmref0 = eval("document.getElementById('" + links[i].name + "_h0')");
236            if (elmref && cookie) {
237                    if (cookie & 1 << links[i].name) {
238                            elmref.style.display='';
239                            if (elmref0) elmref0.bgColor = '#eeeeee';
240                    } else {
241                            elmref.style.display = 'none';
242                            if (elmref0) elmref0.bgColor = '#e0e0e0';
243                    }
244            } else if(elmref) {
245                    if (elmref.style.display=='none') {
246                            elmref.style.display='';
247                            new_cookie |= 1 << links[i].name;
248                            if (elmref0) elmref0.bgColor = '#eeeeee';
249                    } else {
250                            elmref.style.display = 'none';
251                            //new_cookie &= !( 1 << links[i].name );
252                            if (elmref0) elmref0.bgColor = '#e0e0e0';
253                    }
254            }
255        }
256    }
257    if (new_cookie) Set_Cookie("##cookie_name##",new_cookie);
258    </script>
259    HTMLEND
260    
261            if ($dynamic_js) {
262                    my $cookie_name = $key;
263                    $cookie_name =~ s/[^a-zA-Z0-9]//g;
264                    $html =~ s/##cookie_name##/$cookie_name/g;
265                    print OUT $html;
266            }
267    
268          print OUT "</body></html>";          print OUT "</body></html>";
269          close(OUT);          close(OUT);
270    
# Line 114  foreach my $key (keys %html_file) { Line 272  foreach my $key (keys %html_file) {
272    
273  exit;  exit;
274    
275    sub do_html {
276            my ($desc,$url,$img) = @_;
277            if ($dynamic_js) {
278                    my $html =<<'HTMLEND';
279    <tr bgcolor='#e0e0e0' id=##id##_h0>
280    <td><a href="#" id=DynMessLink name=##id## >##desc##</a></td>
281    </tr>
282    <tr id=##id##_h1 style='display:none' bgcolor='#ffffff' >
283    <td><a href="##url##"><img src="##img##"</td>
284    </tr>
285    HTMLEND
286                    $html =~ s/##desc##/$desc/;
287                    $html =~ s/##url##/$url/;
288                    $html =~ s/##img##/$img/;
289                    $html =~ s/##id##/$dynamic_js/g;
290                    $dynamic_js++;                  # increment usage counter
291                    return $html;
292            } else {
293                    return "$desc<br><a href=\"$url\"><img src=\"$img\"></a><br>\n";
294            }
295    }
296    
297  sub localHandleTargetInstance {  sub localHandleTargetInstance {
298          my($Name, $target) = @_;          my($Name, $target) = @_;
299    
# Line 187  sub localHandleTargetInstance { Line 367  sub localHandleTargetInstance {
367                                                  Info("Retrieving graph for $desc");                                                  Info("Retrieving graph for $desc");
368  #                                               getURL($URL,"$path/$name-$vname-$rangeLabel.png");  #                                               getURL($URL,"$path/$name-$vname-$rangeLabel.png");
369                                                  $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname";                                                  $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname";
370                                                  $html{"$rangeLabel\t$paramtarget"}.="$desc<br><a href=\"$tmp_URL\"><img src=$URL></a><br>\n";                                                  $html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL);
371                                          }                                          }
372                                  } else {                                  } else {
373                                          $dslist = $ttRef->{'ds'};                                          $dslist = $ttRef->{'ds'};
# Line 206  sub localHandleTargetInstance { Line 386  sub localHandleTargetInstance {
386    
387  #                                       getURL($URL,"$path/$name-$rangeLabel.png");  #                                       getURL($URL,"$path/$name-$rangeLabel.png");
388                                          $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y";                                          $tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y";
389                                          $html{"$rangeLabel\t$paramtarget"}.="$desc:<br><a href=\"$tmp_URL\"><img src=$URL><a/><br>";                                          $html{"$rangeLabel\t$paramtarget"}.=do_html($desc,$tmp_URL,$URL);
390                                  }                                  }
391                          }                          }
392                  }                  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.26