<div id="placeholder" style="width:600px;height:300px;"></div>
<script src="/static/js/flot/jquery.flot.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var d = [ null [% FOREACH prevbuild IN prevBuilds %][% IF prevbuild.resultInfo.starttime != 0 && (prevbuild.resultInfo.stoptime - prevbuild.resultInfo.starttime) != 0 %],[[% prevbuild.resultInfo.starttime * 1000 %],[% prevbuild.resultInfo.stoptime - prevbuild.resultInfo.starttime %]] [% END %] [% END %] ] ;
// helper for returning the weekends in a period
function weekendAreas(axes) {
var markings = [];
var d = new Date(axes.xaxis.min);
// go to the first Saturday
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
d.setUTCSeconds(0);
d.setUTCMinutes(0);
d.setUTCHours(0);
var i = d.getTime();
do {
// when we don't set yaxis, the rectangle automatically
// extends to infinity upwards and downwards
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
i += 7 * 24 * 60 * 60 * 1000;
} while (i < axes.xaxis.max);
return markings;
}
var now = (new Date()).getTime() ;
var minimum = now;
for (var i = 1; i < d.length; ++i)
if ( minimum > d[i][0] )
minimum = d[i][0] ;
var now = (new Date()).getTime() ;
var options = {
xaxis: { mode: "time", min: minimum, max: now,
},
points: { show: true },
lines: { show: true },
selection: { mode: "x" },
grid: { markings: weekendAreas }
};
$('#generic-tabs').bind('tabsshow', function(event, ui) {
if (ui.panel.id == "tabs-history") {
$.plot($("#placeholder"), [
{ data: d,
clickable : true,
hoverable : true,
},
], options );
}
})
});
</script>
</div>