Skip to content

Commit 7255f73

Browse files
committed
iframe inherit styles (themed)
1 parent fb7eb24 commit 7255f73

2 files changed

Lines changed: 23 additions & 40 deletions

File tree

src/client/jupyter/browser/main.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ function displayData(data: any, whiteBg: boolean): Promise<HTMLElement> {
2828
(window as any).initializeResults = (rootDirName: string, port: number, whiteBg: boolean) => {
2929
const results = (window as any).JUPYTER_DATA as any[];
3030
(window as any).__dirname = rootDirName;
31+
try {
32+
const color = decodeURIComponent(window.location.search.substring(window.location.search.indexOf('?color=') + 7, window.location.search.indexOf('&fontFamily=')));
33+
if (color.length > 0){
34+
window.document.body.style.color = color;
35+
}
36+
const fontFamily = decodeURIComponent(window.location.search.substring(window.location.search.indexOf('&fontFamily=') + 12));
37+
if (fontFamily.length > 0){
38+
window.document.body.style.fontFamily = fontFamily;
39+
}
40+
}
41+
catch (ex){
42+
}
43+
44+
debugger;
3145
try {
3246
if (typeof port === 'number' && port > 0) {
3347
var socket = (window as any).io.connect('http://localhost:' + port);

src/client/jupyter/display/resultView.ts

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ export class TextDocumentContentProvider extends Disposable implements vscode.Te
7070
<option value="append">Append</option>
7171
<option value="clear">Clear Previous Results</option>
7272
</select>
73-
<label for"bg">Background </label>
74-
<select id="bg">
75-
<option value="append">White</option>
76-
<option value="clear">Themed</option>
77-
</select>
73+
<span id='clearResults' class="octicon octicon-circle-slash" tooltip='Clear Results'></span>
7874
<br>
7975
-->
8076
<script type="text/javascript">
@@ -117,49 +113,22 @@ export class TextDocumentContentProvider extends Disposable implements vscode.Te
117113
<head><style type="text/css"> html, body{ height:100%; width:100%; } </style>
118114
<script type="text/javascript">
119115
function start(){
120-
console.log('starting');
121-
var ele = document.getElementById('x');
122-
try {
123-
ele.innerHTML = 'Color is ' + ele.style.color
124-
}
125-
catch(ex){
126-
console.log(ex.message);
127-
}
128-
try {
129-
console.log(ele.style.color);
130-
}
131-
catch(ex){
132-
console.log(ex.message);
133-
}
116+
var color = '';
117+
var fontFamily = '';
134118
try {
135-
console.log(window.getComputedStyle(ele));
119+
computedStyle = window.getComputedStyle(document.body);
120+
color = computedStyle.color + '';
121+
fontFamily = computedStyle.fontFamily;
136122
}
137123
catch(ex){
138-
console.log(ex.message);
139124
}
140-
try {
141-
console.log(window.getComputedStyle(ele).color);
142-
}
143-
catch(ex){
144-
console.log(ex.message);
145-
}
146-
try {
147-
console.log(JSON.stringify(window.getComputedStyle(ele)));
148-
}
149-
catch(ex){
150-
console.log(ex.message);
151-
}
152-
125+
document.getElementById('myframe').src = '${vscode.Uri.file(htmlFileName).toString()}?color=' + encodeURIComponent(color) + "&fontFamily=" + encodeURIComponent(fontFamily);
153126
}
154-
setTimeout(function() {
155-
start();
156-
}, 5000);
157127
</script>
158128
</head>
159129
<body onload="start()">
160-
<label id="x">Test</label>
161-
<iframe frameborder="0" style="border: 0px solid white;height:100%;width:100%;"
162-
src="${vscode.Uri.file(htmlFileName).toString()}" seamless></iframe></body></html>`;
130+
<iframe id="myframe" frameborder="0" style="border: 0px solid white;height:100%;width:100%;"
131+
src="" seamless></iframe></body></html>`;
163132

164133
let def = helpers.createDeferred<string>();
165134
fs.writeFile(htmlFileName, html, err => {

0 commit comments

Comments
 (0)