MCPcopy Create free account
hub / github.com/plotly/plotly.js / handleOnLoad

Function handleOnLoad

devtools/regl_codegen/devtools.js:83–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81var mocksList = document.getElementById('mocks-list');
82
83function handleOnLoad() {
84 var mocksByReglTrace = {};
85
86 reglTraces.forEach(function(trace) {
87 mocksByReglTrace[trace] = [];
88 mocks.forEach(function(mock) {
89 if(mock.keywords.indexOf(trace) !== -1) {
90 mocksByReglTrace[trace].push(mock);
91 }
92 });
93 });
94
95 Object.keys(mocksByReglTrace).forEach(function(trace) {
96 var thisMocks = mocksByReglTrace[trace];
97 var div = document.createElement('div');
98 div.className = 'mock-group';
99 div.innerHTML = '<h3>' + trace + '</h3>';
100 mocksList.appendChild(div);
101 thisMocks.forEach(function(mock) {
102 var a = document.createElement('a');
103 a.className = 'mock-link';
104 a.innerHTML = mock.name;
105 a.href = '#' + mock.name;
106 a.onclick = function() {
107 Tabs.plotMock(this.innerHTML);
108 };
109 div.appendChild(a);
110 div.appendChild(document.createElement('br'));
111 });
112 });
113
114 // visit the mocks one by one.
115 return Object.keys(mocksByReglTrace).reduce(function(p, trace) {
116 return p.then(function() {
117 var thisMocks = mocksByReglTrace[trace];
118 var generated = {};
119
120 return thisMocks.reduce(function(p, mock) {
121 return p.then(function() {
122 return Tabs.plotMock(mock.name).then(function(gd) {
123 var fullLayout = gd._fullLayout;
124 fullLayout._glcanvas.each(function(d) {
125 if(d.regl) {
126 console.log('found regl', d.regl);
127 var cachedCode = d.regl.getCachedCode();
128 Object.entries(cachedCode).forEach(function(kv) {
129 generated[kv[0]] = kv[1].toString();
130 });
131 console.log('merging entries', Object.keys(cachedCode));
132 }
133 });
134 });
135 });
136 }, Promise.resolve())
137 .then(function() {
138 console.log(window.__regl_codegen_cache);
139 var body = JSON.stringify({
140 generated: generated,

Callers

nothing calls this directly

Calls 1

fetchFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…