var maxResults = 10, valueLimit = 0.5, diffLimit = 0.025, restUrl, legendText, svgHeight = 600, navPosition = 1, xAxisLabel, reportTypeValue; //Array to store the fps graph data var fpsGraphArrays; function initPage() { initHeaderAndFilters(null); // no header populatePerfBuilds(); populatePerfChangelists(); $("#sub-header select#cs-changelist").change(function () { if ($("#sub-header input[name=report-type-radio]:radio:checked").val() == "Changelist") generateReport(); }); $("#sub-header select#cs-build").change(function () { if ($("#sub-header input[name=report-type-radio]:radio:checked").val() == "Build") generateReport(); }); $("#sub-header input[name=report-type-radio]:radio").change(function () { generateReport(); }); generateReport(); } function updateReportInputs() { fpsGraphArrays = [] var urlVars = getUrlVars(); if (urlVars.hasOwnProperty("Changelist")) setReportVars("Changelist", urlVars["Changelist"]); else if (urlVars.hasOwnProperty("Build")) setReportVars("Build", urlVars["Build"]); else if ($("#sub-header input[name=report-type-radio]:radio:checked").val() == "Changelist") { setReportVars("Changelist", $("#cs-changelist").val()) } else if ($("#sub-header input[name=report-type-radio]:radio:checked").val() == "Build") { setReportVars("Build", $("#cs-build").val()) } else return; } function setReportVars(reportType, metricValue) { var restSubUrl; if (reportType == "Changelist") restSubUrl = config.captureStatsChangelistPath; else if (reportType == "Build") restSubUrl = config.captureStatsBuildsPath; restUrl = config.restHost + config.captureStats + restSubUrl + metricValue + "/" + config.captureStatsZonesPath; legendText = "Capture Stats :: Per " + reportType + " Report #" + metricValue; xAxisLabel = reportType; reportTypeValue = metricValue; } function generateReport() { $("#report").empty(); updateReportInputs(); if (!reportTypeValue) return; $("#report") .append( $("") .append( $("") .text(legendText) ) ); block(); $.ajax({ url: restUrl, type: "GET", dataType: "json", data: {}, success: function(jsonZones, textStatus, jqXHR) { var fpsGraphId = "fps_graph"; $("#report") .append( $("
") .attr("id", fpsGraphId) .addClass("report-graph") .append( $("") .html("Average FPS (Click to render)") ) .click(function() { if ($(this).find("svg").size() == 0) { initSvg(fpsGraphId, svgHeight); drawLinegraph(fpsGraphArrays, fpsGraphId, xAxisLabel, "Average FPS"); generateGraphTable(fpsGraphArrays, fpsGraphId); $(this).css("height", "auto"); $(this).find("svg").css("height", svgHeight); //console.log(fpsGraphArrays); } }) ); // For each zone $.each(jsonZones.Items, function(i, zone) { generateZoneReport(zone.Hash, i+1); }); repopulateNavigation(jsonZones.Items); }, error: function (xhr, ajaxOptions, thrownError) { Sexy.alert(this.url + "\n" + ajaxOptions + " " + xhr.status + " " + thrownError); }, complete: function() { unBlock(); } }); } // end of generateReport() function generateZoneReport(zoneHash, index) { //block(); var fixedZoneName; $.ajax({ url: restUrl + "/" + zoneHash + "/" + config.captureStatsHistoricalPath, type: "GET", dataType: "json", async: false, // synchronise each zone job data: { maxResults: maxResults }, success: function(jsonZone, textStatus, jqXHR) { populateZoneTables(jsonZone, index); }, error: function (xhr, ajaxOptions, thrownError) { console.error("Failed loading content"); }, complete: function() { //unBlock(); } }); } // end of generateZoneReport() function populateZoneTables(zone, index) { var zoneTitle = index + ". " + zone.ZoneName; var fixedZoneName = replaceNonWord(zone.ZoneName); $("#report") .append( $("") .attr("id", index) .append( $("") .append( $("
") .addClass("title") .append( $("") .click(function(e) { e.preventDefault(); $("#" + fixedZoneName).toggle("blind", {}, "slow"); }) .attr("title", zoneTitle) .attr("href", "#") .text(zoneTitle) ) ) ) ) .append( $("
") .attr("id", fixedZoneName) //.addClass("collapsed") .append( $("