User:Dominic/tinderbox 03a
? tinderbox_3a.diff Index: defaultStyle.css
Contents
=======================================================
RCS file: defaultStyle.css diff -N defaultStyle.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ defaultStyle.css 14 Dec 2007 20:54:30 -0000 @@ -0,0 +1,17 @@ +body { + font-family: Verdana, Sans-Serif; + text-align: center; +} + +#tindertable tr th { + background-color: #AAA; +} + +#tindertable tr td { + vertical-align: top; + +} +/* needed because regular background-color overwrites tinderbox colors! */ +.bgcolor { + background-color: #EEE; +} Index: index.html
=======================================================
RCS file: /cvsroot/mozilla/webtools/tinderbox/index.html,v retrieving revision 1.2 diff -u -8 -p -r1.2 index.html --- index.html 31 Jan 2002 04:22:39 -0000 1.2 +++ index.html 14 Dec 2007 20:54:30 -0000 @@ -1,12 +1,16 @@ -<TITLE>tinderbox</TITLE> -<META HTTP-EQUIV="Refresh" CONTENT="0; URL=showbuilds.cgi"> -<BODY BGCOLOR="#FFFFFF" TEXT="#000000" - LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
-
- -You're probably looking for -<A HREF="showbuilds.cgi">showbuilds.cgi</A>. - - |
+<html> + <script src="panelLoad.js"></script> + <link rel="stylesheet" type="text/css" href="defaultStyle.css" />
+Tinderbox
+This page refreshes every 5 minutes
+<a href="showbuilds.cgi">For showbuilds.cgi click here</a>
+ <body onload="init();"> +
++
++ </body> +</html> + Index: panelLoad.js
=======================================================
RCS file: panelLoad.js diff -N panelLoad.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ panelLoad.js 14 Dec 2007 20:54:30 -0000 @@ -0,0 +1,73 @@ + /*extern ActiveXObject, XMLHttpRequest, document, window */ + var last_modified = new Date(0); + + function init() { + loadAllTreeData(); + } + + function loadAllTreeData() { + var url = 'showbuilds.cgi?tree_list_json=1'; + var req; + + + if (window.XMLHttpRequest) { + req = new XMLHttpRequest(); + } else if (window.ActiveXObject) { + req = new ActiveXObject("Microsoft.XMLHTTP"); + } + + req.open('GET', url, true); + req.setRequestHeader('If-Modified-Since', last_modified); + req.onreadystatechange = function() { + var jsonDat; + if (req.readyState != 4) { + return; + } + if (req.status == 200) { + last_modified = req.getResponseHeader('Last-Modified'); + try { + jsonDat = eval("(" + req.responseText.substring(0, req.responseText.length-2) + ")"); + + // alert(req.responseText); + + var quicklinks = "";
+ var tindertable = "Desc. | Common Trees (Excluding l10n trees) | ||
---|---|---|---|
<a name='" + tree + "'>" + tree + "</a> | ";" + bldr + " "; + //alert("bldr : " + bldr);
+ for(var property in jsonDat[tree][build][bldr]) {
+ tindertable += " " +property + " : " + jsonDat[tree][build][bldr][property] + " | ";
+ }
+ tindertable += "</th>";
+ }
+ }
+ tindertable += "</table>";
+
+ document.getElementById("quicklinks").innerHTML = quicklinks;
+ document.getElementById("tindertable").innerHTML = tindertable;
+
+
+ } catch(e) {
+ alert("could not parse JSON data:" + e);
+ }
+ } else if (req.status == 304) {
+ return;
+ } else {
+ div.innerHTML = "Error code " + req.status + " loading " + url;
+ }
+ }
+
+ req.send(null);
+ return;
+ }
+
+ setInterval('init()', 300000); // 5 minute refresh cycle
Index: showbuilds.cgi
foreach (@list) {print " |
}
+## +# Return list of trees as JSON +## + +sub show_tree_list_json($) { + print "Content-type: text/javascript\n"; + print "Content-Access-Control: allow <*>\n\n"; + + my @requestedtreelist = &make_tree_list(); + + my %all_tree_data = (); + foreach my $tt (@requestedtreelist) { + next unless grep {$tt eq $_} @requestedtreelist; + tb_load_treedata($tt); + my %tree_data = (); + if (&is_tree_state_available($tt)) { + my $tree_state = &is_tree_open($tt) ? 'open' : 'closed'; + my $bonsai_tree = $::global_treedata->{$tt}->{bonsai_tree}; + $tree_data{'tree_state'} = $tree_state; + $tree_data{'bonsai_tree'} = $bonsai_tree; + } + + my (%quickdata); + #tb_loadquickparseinfo($tt, $::nowdate, \%quickdata); + open(QP, "< $tt/quickparse.txt"); + my @quickparse = <QP>; + close(QP); + foreach my $line (@quickparse) { + my ($type, $tree, $name, $status, $starttime, $binaryurl) = + split('\|', $line); + next unless ($type eq 'Build'); + $all_tree_data{$tt}->{'builders'}->{$name} = { + status => $status, + starttime => $starttime, + binaryurl => $binaryurl, + }; + } + } + print "tinderbox_data = "; + dump_json(\%all_tree_data); + +# print Dumper(%all_tree_data); +} + +sub dump_json { + my ($data) = @_; + $Data::Dumper::Indent = 0; + my $line = Dumper($data); + $line =~ s/=>/:/g; + $line =~ s/\$VAR1//g; + $line =~ s/^ = //g; + $line =~ s/undef/'undef'/g; + $line =~ s/\n//g; + $line =~ s/\r//g; + $line =~ s/: ,/: ,/g; + print "$line\n"; +} +
sub lock_datafile { my ($file) = @_; my $lock_fh = new FileHandle ">>$file" or die "Couldn't open semaphore file, $file: $!"; # Get an exclusive lock with a non-blocking request unless (flock($lock_fh, LOCK_EX|LOCK_NB)) {