1
0
mirror of https://github.com/pyscript/pyscript.git synced 2022-05-01 19:47:48 +03:00

rename target attribute to output

This commit is contained in:
Fabio Pliger
2022-04-18 18:56:49 -05:00
parent 00b571d3df
commit 4ba90a9250
4 changed files with 16 additions and 16 deletions

View File

@@ -21,7 +21,7 @@
<body> <body>
<py-box widths="2/3;1/3"> <py-box widths="2/3;1/3">
<py-repl id="my-repl" auto-generate="true" target="output"> </py-repl> <py-repl id="my-repl" auto-generate="true" output="output"> </py-repl>
<div id="output"></div> <div id="output"></div>
</py-box> </py-box>
</body> </body>

View File

@@ -132,7 +132,7 @@ export class BaseEvalElement extends HTMLElement {
// @ts-ignore // @ts-ignore
out.write.callKwargs(output, { append : true}); out.write.callKwargs(output, { append : true});
if (!this.hasAttribute('target')) { if (!this.hasAttribute('output')) {
this.outputElement.hidden = false; this.outputElement.hidden = false;
} }
} }

View File

@@ -134,7 +134,7 @@ export class PyRepl extends BaseEvalElement {
currentComponentDetails.set([ currentComponentDetails.set([
{key: "auto-generate", value: true}, {key: "auto-generate", value: true},
{key:"target", value: "default"}, {key:"output", value: "default"},
{key: "source", value: "self"}, {key: "source", value: "self"},
{key: "output-mode", value: "clear"} {key: "output-mode", value: "clear"}
]) ])
@@ -160,8 +160,8 @@ export class PyRepl extends BaseEvalElement {
this.setAttribute("root", this.id); this.setAttribute("root", this.id);
} }
if (this.hasAttribute('target')) { if (this.hasAttribute('output')) {
this.outputElement = document.getElementById(this.getAttribute('target')); this.outputElement = document.getElementById(this.getAttribute('output'));
// in this case, the default output-mode is append, if hasn't been specified // in this case, the default output-mode is append, if hasn't been specified
if (!this.hasAttribute('output-mode')) { if (!this.hasAttribute('output-mode')) {
@@ -174,7 +174,7 @@ export class PyRepl extends BaseEvalElement {
this.outputElement.hidden = true; this.outputElement.hidden = true;
this.outputElement.id = this.id + "-" + this.getAttribute("exec-id"); this.outputElement.id = this.id + "-" + this.getAttribute("exec-id");
// add the output div id there's not target // add the output div id if there's not output pre-defined
mainDiv.appendChild(this.outputElement); mainDiv.appendChild(this.outputElement);
} }
@@ -195,8 +195,8 @@ export class PyRepl extends BaseEvalElement {
newPyRepl.setAttribute('root', this.getAttribute('root')); newPyRepl.setAttribute('root', this.getAttribute('root'));
newPyRepl.id = this.getAttribute('root') + "-" + nextExecId.toString(); newPyRepl.id = this.getAttribute('root') + "-" + nextExecId.toString();
newPyRepl.setAttribute('auto-generate', null); newPyRepl.setAttribute('auto-generate', null);
if (this.hasAttribute('target')){ if (this.hasAttribute('output')){
newPyRepl.setAttribute('target', this.getAttribute('target')); newPyRepl.setAttribute('output', this.getAttribute('output'));
} }
newPyRepl.setAttribute('exec-id', nextExecId.toString()); newPyRepl.setAttribute('exec-id', nextExecId.toString());

View File

@@ -56,10 +56,10 @@ type PyodideInterface = {
class Script { class Script {
source: string; source: string;
state: string; state: string;
target: string; output: string;
constructor(source: string, target: string) { constructor(source: string, output: string) {
this.target = target; this.output = output;
this.source = source; this.source = source;
this.state = 'waiting'; this.state = 'waiting';
} }
@@ -78,7 +78,7 @@ class Script {
output = pyodide.runPython(this.source); output = pyodide.runPython(this.source);
} }
if (this.target){ if (this.output){
// this.editorOut.innerHTML = s; // this.editorOut.innerHTML = s;
} }
// if (output !== undefined){ // if (output !== undefined){
@@ -161,7 +161,7 @@ export class PyScript extends BaseEvalElement {
currentComponentDetails.set([ currentComponentDetails.set([
{key: "auto-generate", value: true}, {key: "auto-generate", value: true},
{key:"target", value: "default"}, {key:"output", value: "default"},
{key: "source", value: "self"} {key: "source", value: "self"}
]) ])
} }
@@ -172,15 +172,15 @@ export class PyScript extends BaseEvalElement {
mainDiv.appendChild(eDiv); mainDiv.appendChild(eDiv);
if (this.hasAttribute('target')) { if (this.hasAttribute('output')) {
this.outputElement = document.getElementById(this.getAttribute('target')); this.outputElement = document.getElementById(this.getAttribute('output'));
}else{ }else{
// Editor Output Div // Editor Output Div
this.outputElement = document.createElement('div'); this.outputElement = document.createElement('div');
this.outputElement.classList.add("output"); this.outputElement.classList.add("output");
this.outputElement.hidden = true; this.outputElement.hidden = true;
// add the output div id there's not target // add the output div id there's no output element
mainDiv.appendChild(this.outputElement); mainDiv.appendChild(this.outputElement);
} }