Commit 47140694 authored by cbruni's avatar cbruni Committed by Commit bot

[tools] Add support for replacing the default content in callstats.html

BUG=
NOTRY=true

Review-Url: https://codereview.chromium.org/2376103003
Cr-Commit-Position: refs/heads/master@{#39865}
parent fecd09ce
...@@ -247,6 +247,9 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -247,6 +247,9 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
var selectedPage; var selectedPage;
var baselineVersion; var baselineVersion;
var selectedEntry; var selectedEntry;
// Marker to programatically replace the defaultData.
var defaultData = /*default-data-start*/undefined/*default-data-end*/;
function initialize() { function initialize() {
// Initialize the stats table and toggle lists. // Initialize the stats table and toggle lists.
...@@ -1008,15 +1011,21 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1008,15 +1011,21 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
// EventHandlers // EventHandlers
function handleBodyLoad() { function handleBodyLoad() {
$('uploadInput').focus(); $('uploadInput').focus();
if (window.location.protocol !== 'file:') tryLoadDefaultResults(); if (defaultData) {
handleLoadJSON(defaultData);
} else if (window.location.protocol !== 'file:') {
tryLoadDefaultResults();
}
} }
function tryLoadDefaultResults() { function tryLoadDefaultResults() {
// Try to load a results.json file adjacent to this day. // Try to load a results.json file adjacent to this day.
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', 'results.json', true); // The markers on the following line can be used to replace the url easily
// with scripts.
xhr.open('GET', /*results-url-start*/'results.json'/*results-url-end*/, true);
xhr.onreadystatechange = function(e) { xhr.onreadystatechange = function(e) {
if (this.readyState != 4 || this.status != 200) return; if(this.readyState !== XMLHttpRequest.DONE || this.status !== 200) return;
handleLoadText(this.responseText); handleLoadText(this.responseText);
}; };
xhr.send(); xhr.send();
...@@ -1035,7 +1044,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file. ...@@ -1035,7 +1044,11 @@ code is governed by a BSD-style license that can be found in the LICENSE file.
function handleLoadText(text) { function handleLoadText(text) {
pages = new Pages(); pages = new Pages();
versions = Versions.fromJSON(JSON.parse(text)); handleLoadJSON(JSON.parse(text));
}
function handleLoadJSON(json) {
versions = Versions.fromJSON(json);
initialize() initialize()
showPage(versions.versions[0].pages[0]); showPage(versions.versions[0].pages[0]);
selectEntry(selectedPage.total); selectEntry(selectedPage.total);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment