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:
@@ -21,7 +21,7 @@
|
||||
|
||||
<body>
|
||||
<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>
|
||||
</py-box>
|
||||
</body>
|
||||
|
||||
@@ -132,7 +132,7 @@ export class BaseEvalElement extends HTMLElement {
|
||||
// @ts-ignore
|
||||
out.write.callKwargs(output, { append : true});
|
||||
|
||||
if (!this.hasAttribute('target')) {
|
||||
if (!this.hasAttribute('output')) {
|
||||
this.outputElement.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export class PyRepl extends BaseEvalElement {
|
||||
|
||||
currentComponentDetails.set([
|
||||
{key: "auto-generate", value: true},
|
||||
{key:"target", value: "default"},
|
||||
{key:"output", value: "default"},
|
||||
{key: "source", value: "self"},
|
||||
{key: "output-mode", value: "clear"}
|
||||
])
|
||||
@@ -160,8 +160,8 @@ export class PyRepl extends BaseEvalElement {
|
||||
this.setAttribute("root", this.id);
|
||||
}
|
||||
|
||||
if (this.hasAttribute('target')) {
|
||||
this.outputElement = document.getElementById(this.getAttribute('target'));
|
||||
if (this.hasAttribute('output')) {
|
||||
this.outputElement = document.getElementById(this.getAttribute('output'));
|
||||
|
||||
// in this case, the default output-mode is append, if hasn't been specified
|
||||
if (!this.hasAttribute('output-mode')) {
|
||||
@@ -174,7 +174,7 @@ export class PyRepl extends BaseEvalElement {
|
||||
this.outputElement.hidden = true;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ export class PyRepl extends BaseEvalElement {
|
||||
newPyRepl.setAttribute('root', this.getAttribute('root'));
|
||||
newPyRepl.id = this.getAttribute('root') + "-" + nextExecId.toString();
|
||||
newPyRepl.setAttribute('auto-generate', null);
|
||||
if (this.hasAttribute('target')){
|
||||
newPyRepl.setAttribute('target', this.getAttribute('target'));
|
||||
if (this.hasAttribute('output')){
|
||||
newPyRepl.setAttribute('output', this.getAttribute('output'));
|
||||
}
|
||||
|
||||
newPyRepl.setAttribute('exec-id', nextExecId.toString());
|
||||
|
||||
@@ -56,10 +56,10 @@ type PyodideInterface = {
|
||||
class Script {
|
||||
source: string;
|
||||
state: string;
|
||||
target: string;
|
||||
output: string;
|
||||
|
||||
constructor(source: string, target: string) {
|
||||
this.target = target;
|
||||
constructor(source: string, output: string) {
|
||||
this.output = output;
|
||||
this.source = source;
|
||||
this.state = 'waiting';
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class Script {
|
||||
output = pyodide.runPython(this.source);
|
||||
}
|
||||
|
||||
if (this.target){
|
||||
if (this.output){
|
||||
// this.editorOut.innerHTML = s;
|
||||
}
|
||||
// if (output !== undefined){
|
||||
@@ -161,7 +161,7 @@ export class PyScript extends BaseEvalElement {
|
||||
|
||||
currentComponentDetails.set([
|
||||
{key: "auto-generate", value: true},
|
||||
{key:"target", value: "default"},
|
||||
{key:"output", value: "default"},
|
||||
{key: "source", value: "self"}
|
||||
])
|
||||
}
|
||||
@@ -172,15 +172,15 @@ export class PyScript extends BaseEvalElement {
|
||||
|
||||
mainDiv.appendChild(eDiv);
|
||||
|
||||
if (this.hasAttribute('target')) {
|
||||
this.outputElement = document.getElementById(this.getAttribute('target'));
|
||||
if (this.hasAttribute('output')) {
|
||||
this.outputElement = document.getElementById(this.getAttribute('output'));
|
||||
}else{
|
||||
// Editor Output Div
|
||||
this.outputElement = document.createElement('div');
|
||||
this.outputElement.classList.add("output");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user