36 |
# $gBaseURL = "http://localhost/~cricket/grapher.cgi"; |
# $gBaseURL = "http://localhost/~cricket/grapher.cgi"; |
37 |
my $hostname = `hostname -f`; |
my $hostname = `hostname -f`; |
38 |
chomp($hostname); |
chomp($hostname); |
39 |
$gBaseURL = "http://$hostname/cgi-bin/cricket/grapher.cgi"; |
$gBaseURL = "/cgi-bin/cricket/grapher.cgi"; |
40 |
|
|
41 |
# change this to destination directory |
# change this to destination directory |
42 |
$path = "/data/mon/"; |
$path = "/data/mon/"; |
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 |
|
|
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> |
print OUT "<html><head><title>$key</title>"; |
117 |
<meta content="no-cache" http-equiv="Pragma"> |
print OUT '<meta content="no-cache" http-equiv="Pragma"> |
118 |
<meta content="300" http-equiv="Refresh"> |
<meta content="300" http-equiv="Refresh">' if ($filename =~ m/Daily/i); |
119 |
</head><body>'; |
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 |
|
// default: show all |
246 |
|
new_cookie |= 1 << links[i].name; |
247 |
|
if (elmref.style.display=='none') { |
248 |
|
elmref.style.display=''; |
249 |
|
if (elmref0) elmref0.bgColor = '#eeeeee'; |
250 |
|
} else { |
251 |
|
// hide? no... |
252 |
|
//elmref.style.display = 'none'; |
253 |
|
//if (elmref0) elmref0.bgColor = '#e0e0e0'; |
254 |
|
if (elmref0) elmref0.bgColor = '#eeeeee'; |
255 |
|
} |
256 |
|
} |
257 |
|
} |
258 |
|
} |
259 |
|
if (new_cookie) Set_Cookie("##cookie_name##",new_cookie); |
260 |
|
</script> |
261 |
|
HTMLEND |
262 |
|
|
263 |
|
if ($dynamic_js) { |
264 |
|
my $cookie_name = $key; |
265 |
|
$cookie_name =~ s/[^a-zA-Z0-9]//g; |
266 |
|
$html =~ s/##cookie_name##/$cookie_name/g; |
267 |
|
print OUT $html; |
268 |
|
} |
269 |
|
|
270 |
print OUT "</body></html>"; |
print OUT "</body></html>"; |
271 |
close(OUT); |
close(OUT); |
272 |
|
|
274 |
|
|
275 |
exit; |
exit; |
276 |
|
|
277 |
|
sub do_html { |
278 |
|
my ($desc,$url,$img) = @_; |
279 |
|
if ($dynamic_js) { |
280 |
|
my $html =<<'HTMLEND'; |
281 |
|
<tr bgcolor='#e0e0e0' id=##id##_h0> |
282 |
|
<td><a name="##id##"><a href="###id##" id=DynMessLink name=##id## >##desc##</a></td> |
283 |
|
</tr> |
284 |
|
<tr id=##id##_h1 style='' bgcolor='#ffffff' > |
285 |
|
<td><a href="##url##"><img src="##img##"</td> |
286 |
|
</tr> |
287 |
|
HTMLEND |
288 |
|
$html =~ s/##desc##/$desc/; |
289 |
|
$html =~ s/##url##/$url/; |
290 |
|
$html =~ s/##img##/$img/; |
291 |
|
$html =~ s/##id##/$dynamic_js/g; |
292 |
|
$dynamic_js++; # increment usage counter |
293 |
|
return $html; |
294 |
|
} else { |
295 |
|
return "$desc<br><a href=\"$url\"><img src=\"$img\"></a><br>\n"; |
296 |
|
} |
297 |
|
} |
298 |
|
|
299 |
sub localHandleTargetInstance { |
sub localHandleTargetInstance { |
300 |
my($Name, $target) = @_; |
my($Name, $target) = @_; |
301 |
|
|
369 |
Info("Retrieving graph for $desc"); |
Info("Retrieving graph for $desc"); |
370 |
# getURL($URL,"$path/$name-$vname-$rangeLabel.png"); |
# getURL($URL,"$path/$name-$vname-$rangeLabel.png"); |
371 |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname"; |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y&view=$vname"; |
372 |
$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); |
373 |
} |
} |
374 |
} else { |
} else { |
375 |
$dslist = $ttRef->{'ds'}; |
$dslist = $ttRef->{'ds'}; |
388 |
|
|
389 |
# getURL($URL,"$path/$name-$rangeLabel.png"); |
# getURL($URL,"$path/$name-$rangeLabel.png"); |
390 |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y"; |
$tmp_URL = "$gBaseURL?target=$paramtarget&range=d:w:m:y"; |
391 |
$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); |
392 |
} |
} |
393 |
} |
} |
394 |
} |
} |