22
33/* global Plotly:false */
44
5- var Fuse = require ( 'fuse.js/dist/fuse.common.js' ) ;
65var mocks = require ( '../../build/test_dashboard_mocks.json' ) ;
76var reglTraces = require ( '../../build/regl_traces.json' ) ;
8- var credentials = require ( '../../build/credentials.json' ) ;
97var Lib = require ( '@src/lib' ) ;
108
119// Our gracious testing object
1210var Tabs = {
1311
14- // Set plot config options
15- setPlotConfig : function ( ) {
16- Plotly . setPlotConfig ( {
17-
18- // use local topojson files
19- topojsonURL : '../../node_modules/sane-topojson/dist/' ,
20-
21- // register mapbox access token
22- // run `npm run preset` if you haven't yet
23- mapboxAccessToken : credentials . MAPBOX_ACCESS_TOKEN ,
24-
25- // show all logs in console
26- logging : 2
27- } ) ;
28- } ,
29-
3012 // Return the specified plot container (or default one)
3113 getGraph : function ( id ) {
3214 id = id || 'graph' ;
@@ -86,74 +68,6 @@ var Tabs = {
8668 } ;
8769 } )
8870 } ,
89-
90- // Save a png snapshot and display it below the plot
91- snapshot : function ( id ) {
92- var gd = Tabs . getGraph ( id ) ;
93-
94- if ( ! gd . _fullLayout || ! gd . _fullData ) {
95- console . error ( 'no graph with id ' + id + ' found.' ) ;
96- return ;
97- }
98-
99- var image = new Image ( ) ;
100-
101- Plotly . Snapshot . toImage ( gd , { format : 'png' } ) . on ( 'success' , function ( img ) {
102- image . src = img ;
103-
104- var imageDiv = document . getElementById ( 'snapshot' ) ;
105- imageDiv . appendChild ( image ) ;
106-
107- console . warn ( 'Snapshot complete!' ) ;
108- } ) ;
109- } ,
110-
111- // Remove all plots and snapshots from the page
112- purge : function ( ) {
113- var plots = document . getElementsByClassName ( 'dashboard-plot' ) ;
114- var images = document . getElementById ( 'snapshot' ) ;
115-
116- while ( images . firstChild ) {
117- images . removeChild ( images . firstChild ) ;
118- }
119-
120- for ( var i = 0 ; i < plots . length ; i ++ ) {
121- Plotly . purge ( plots [ i ] ) ;
122- }
123- } ,
124-
125- // Specify what to do after each plotly.js script reload
126- onReload : function ( ) {
127- return ;
128- } ,
129-
130- // Refreshes the plotly.js source without needing to refresh the page
131- reload : function ( ) {
132- var source = document . getElementById ( 'source' ) ;
133- var reloaded = document . getElementById ( 'reload-time' ) ;
134-
135- source . remove ( ) ;
136-
137- window . Plotly = null ;
138-
139- source = document . createElement ( 'script' ) ;
140- source . id = 'source' ;
141- source . src = '../../build/plotly.js' ;
142-
143- document . body . appendChild ( source ) ;
144-
145- var reloadTime = new Date ( ) . toLocaleTimeString ( ) ;
146- console . warn ( 'plotly.js reloaded at ' + reloadTime ) ;
147- reloaded . textContent = 'last reload at ' + reloadTime ;
148-
149- var interval = setInterval ( function ( ) {
150- if ( window . Plotly ) {
151- clearInterval ( interval ) ;
152- handleOnLoad ( ) ;
153- Tabs . onReload ( ) ;
154- }
155- } , 100 ) ;
156- }
15771} ;
15872
15973
@@ -167,43 +81,7 @@ setInterval(function() {
16781 window . fullData = window . gd . _fullData ;
16882} , 1000 ) ;
16983
170- // Mocks search and plotting
171- var fuse = new Fuse ( mocks , {
172- // isCaseSensitive: false,
173- // includeScore: false,
174- // shouldSort: true,
175- // includeMatches: false,
176- // findAllMatches: false,
177- // minMatchCharLength: 1,
178- // location: 0,
179- // threshold: 0.6,
180- // distance: 100,
181- // useExtendedSearch: false,
182- keys : [ {
183- name : 'name' ,
184- weight : 0.7
185- } , {
186- name : 'keywords' ,
187- weight : 0.3
188- } ]
189- } ) ;
190-
191- var transformInput = document . getElementById ( 'css-transform' ) ;
192- var mockInput = document . getElementById ( 'mocks-search' ) ;
19384var mocksList = document . getElementById ( 'mocks-list' ) ;
194- var plotArea = document . getElementById ( 'plots' ) ;
195-
196- function getNameFromHash ( ) {
197- return window . location . hash . replace ( / ^ # / , '' ) ;
198- }
199-
200- function plotFromHash ( ) {
201- var initialMock = getNameFromHash ( ) ;
202-
203- if ( initialMock . length > 0 ) {
204- Tabs . plotMock ( initialMock ) ;
205- }
206- }
20785
20886async function handleOnLoad ( ) {
20987 var mocksByReglTrace = { } ;
@@ -260,4 +138,8 @@ async function handleOnLoad() {
260138 body
261139 } ) ;
262140 }
141+
142+ // close
143+ await fetch ( "/api/codegen-done" ) ;
144+ window . close ( ) ;
263145}
0 commit comments