Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Fix loading of Browserscope visualization (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens authored and jdalton committed Mar 28, 2017
1 parent 3b05e96 commit 1fe5071
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions plugin/ui.browserscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,30 @@
iframe.frameBorder = 0;
iframe.scrolling = 'no';

addListener(iframe, 'load', function() {
// the element the charts are inserted into
me.container = query('#bs-chart', idoc)[0];

if (!me.container) return;

// Browserscope's UA div is inserted before an element with the id of "bs-ua-script"
loadScript('https://www.browserscope.org/ua?o=js', me.container).id = 'bs-ua-script';

// the "autoload" string is created following the guide at
// https://developers.google.com/loader/?hl=en#auto-loading
loadScript(
'https://www.google.com/jsapi?autoload=' + encodeURIComponent('{' +
'modules:[{' +
'name:"visualization",' +
'version:1,' +
'packages:["corechart","table"],' +
'callback:ui.browserscope.load' +
'}]' +
'}'),
idoc
);
});

placeholder.parentNode.replaceChild(iframe, placeholder);

var iwin = frames[name],
Expand Down Expand Up @@ -1043,26 +1067,6 @@

// the frame window of the charts
me.chartWindow = iwin;

// ensure that content in iframe is processed by executing on next tick
setTimeout(function() {
// the element the charts are inserted into
me.container = query('#bs-chart', idoc)[0];

// Browserscope's UA div is inserted before an element with the id of "bs-ua-script"
loadScript('https://www.browserscope.org/ua?o=js', me.container).id = 'bs-ua-script';

// the "autoload" string is created following the guide at
// https://developers.google.com/loader/?hl=en#auto-loading
loadScript('https://www.google.com/jsapi?autoload=' + encodeURIComponent('{' +
'modules:[{' +
'name:"visualization",' +
'version:1,' +
'packages:["corechart","table"],' +
'callback:ui.browserscope.load' +
'}]' +
'}'), idoc);
}, 1);
});

// hide the chart while benchmarks are running
Expand Down

0 comments on commit 1fe5071

Please sign in to comment.