@@ -51,56 +51,63 @@ export class TextDocumentContentProvider implements vscode.TextDocumentContentPr
5151 width:100%;
5252 }
5353 </style>` ;
54+ // Don't put this, stuffs up SVG hrefs
55+ // <basex href="${path.join(__dirname, '..', '..', '..', '..')}" target="_blank">
56+ const dirNameForScripts = path . join ( __dirname , '..' , '..' , '..' , 'out' ) ;
5457 const html = `
58+ <!DOCTYPE html>
59+ <html>
5560 <head>
5661 </head>
57- <body onload="initializeResults()">
62+ <body onload="initializeResults('' )">
5863 <script type="text/javascript">
5964 window.JUPYTER_DATA = ${ JSON . stringify ( this . results ) } ;
6065 </script>
6166 <script src="${ this . getScriptFilePath ( 'bundle.js' ) } ?x=${ new Date ( ) . getMilliseconds ( ) } "></script>
6267 </body>
68+ </html>
6369 ` ;
6470 // fs.writeFileSync('/Users/donjayamanne/.vscode/extensions/pythonVSCode/results.html', html);
65- return Promise . resolve ( html ) ;
71+ // return Promise.resolve(html);
6672
67- // let htmlFile: helpers.Deferred<string> = helpers.createDeferred<string>();
68- // if (this.tmpHtmlFile) {
69- // fs.exists(this.tmpHtmlFile, exists => {
70- // if (exists) {
71- // return htmlFile.resolve(this.tmpHtmlFile);
72- // }
73- // helpers.createTemporaryFile('.html').then(tmpFile => {
74- // htmlFile.resolve(tmpFile.filePath);
75- // });
76- // });
77- // }
78- // else {
79- // helpers.createTemporaryFile('.html').then(tmpFile => {
80- // htmlFile.resolve(tmpFile.filePath);
81- // });
82- // }
73+ let htmlFile : helpers . Deferred < string > = helpers . createDeferred < string > ( ) ;
74+ if ( this . tmpHtmlFile ) {
75+ fs . exists ( this . tmpHtmlFile , exists => {
76+ if ( exists ) {
77+ return htmlFile . resolve ( this . tmpHtmlFile ) ;
78+ }
79+ helpers . createTemporaryFile ( '.html' ) . then ( tmpFile => {
80+ htmlFile . resolve ( tmpFile . filePath ) ;
81+ } ) ;
82+ } ) ;
83+ }
84+ else {
85+ helpers . createTemporaryFile ( '.html' ) . then ( tmpFile => {
86+ htmlFile . resolve ( tmpFile . filePath ) ;
87+ } ) ;
88+ }
8389
84- // return htmlFile.promise.then(htmlFileName => {
85- // const htmlContent = `
86- // <head>
87- // <style type="text/css">
88- // html, body{
89- // height:100%;
90- // width:100%;
91- // }
92- // </style>
93- // </head>
94- // <body><iframe frameborder="0" style="border: 0px solid white;height:100%;width:100%;" src="${htmlFileName}" seamless></iframe></body>`;
95- // return new Promise<string>((resolve, reject) => {
96- // fs.writeFile(htmlFileName, html, err => {
97- // if (err) {
98- // return reject(err);
99- // }
100- // fs.writeFileSync('/Users/donjayamanne/.vscode/extensions/pythonVSCode/results.html', htmlContent);
101- // resolve(htmlContent);
102- // });
103- // });
104- // });
90+ return htmlFile . promise . then ( htmlFileName => {
91+ const htmlContent = `
92+ <!DOCTYPE html>
93+ <head>
94+ <style type="text/css">
95+ html, body{
96+ height:100%;
97+ width:100%;
98+ }
99+ </style>
100+ </head>
101+ <body><iframe frameborder="0" style="border: 0px solid white;height:100%;width:100%;" src="${ vscode . Uri . file ( htmlFileName ) . toString ( ) } " seamless></iframe></body></html>` ;
102+ return new Promise < string > ( ( resolve , reject ) => {
103+ fs . writeFile ( htmlFileName , html , err => {
104+ if ( err ) {
105+ return reject ( err ) ;
106+ }
107+ // fs.writeFileSync('/Users/donjayamanne/.vscode/extensions/pythonVSCode/results.html', htmlContent);
108+ resolve ( htmlContent ) ;
109+ } ) ;
110+ } ) ;
111+ } ) ;
105112 }
106113}
0 commit comments