Skip to content

Commit

Permalink
#37 accidentily fixed unrelated error
Browse files Browse the repository at this point in the history
  • Loading branch information
Almenon committed Mar 6, 2018
1 parent e2d7497 commit fcd1408
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/HTMLDocumentContentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class HtmlDocumentContentProvider implements vscode.TextDocumentC
css:string
jsonRendererScript: string;
errorContainer = ''
userVarContainer = `<div id="results"></div>`;
jsonRendererCode = `<div id="results"></div>`;
printContainer = `<br><b>Print Output:</b><div id="print"></div>`;
timeContainer = `<p style="position:absolute;left:96%;top:96%;"></p>`;
settings:vscode.WorkspaceConfiguration;
Expand Down Expand Up @@ -51,9 +51,19 @@ export default class HtmlDocumentContentProvider implements vscode.TextDocumentC
}

public updateContent(){

// todo: handle different themes. check body class: https://code.visualstudio.com/updates/June_2016
this.html = this.css + this.jsonRendererScript + this.errorContainer +
this.userVarContainer + this.printContainer + this.timeContainer;
this.html = `<head>
${this.css}
${this.jsonRendererScript}
${this.jsonRendererCode}
</head>
<body>
${this.errorContainer}
<div id="results"></div>
${this.printContainer}
${this.timeContainer}
</body>`

// issue #1: need to make sure html is new each time or wierd crap happens
this.html += `<div id="${Math.random()}" style="display:none"></div>`
Expand Down Expand Up @@ -88,15 +98,15 @@ export default class HtmlDocumentContentProvider implements vscode.TextDocumentC
// escape end script tag or else the content will escape its container and WREAK HAVOC
userVarsCode = userVarsCode.replace(/<\/script>/g,'<\\/script>')

let jsonRendererCode = `<script>
${userVarsCode}
let jsonRenderer = renderjson.set_icons('+', '-') // default icons look a bit wierd, overriding
.set_show_to_level(${this.settings.get('show_to_level')})
.set_max_string_length(${this.settings.get('max_string_length')});
document.getElementById("results").appendChild(jsonRenderer(userVars));
</script>`

this.userVarContainer = `<div id="results">${jsonRendererCode}</div>`
this.jsonRendererCode = `<script>
window.onload = function(){
${userVarsCode}
let jsonRenderer = renderjson.set_icons('+', '-') // default icons look a bit wierd, overriding
.set_show_to_level(${this.settings.get('show_to_level')})
.set_max_string_length(${this.settings.get('max_string_length')});
document.getElementById("results").appendChild(jsonRenderer(userVars));
}
</script>`
}

private updateTime(time:number){
Expand Down

0 comments on commit fcd1408

Please sign in to comment.