Made web app a bit more useful
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Schala Metainterpreter Web Evaluator</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
|
||||
@@ -7,7 +7,7 @@ const serverAddress = "http://localhost:8000";
|
||||
class CodeArea extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {value: ""};
|
||||
this.state = {value: "", lastOutput: null};
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.submit = this.submit.bind(this);
|
||||
}
|
||||
@@ -17,25 +17,36 @@ class CodeArea extends React.Component {
|
||||
}
|
||||
|
||||
submit(event) {
|
||||
/*
|
||||
console.log("This", this.state.value);
|
||||
console.log("Event", this.state.value);
|
||||
const source = this.state.value;
|
||||
|
||||
const options = {
|
||||
url: `${serverAddress}/input`,
|
||||
json: true,
|
||||
body: {source: this.state.value}
|
||||
body: { source }
|
||||
};
|
||||
request.post(options, (error, response, body) => {
|
||||
console.log("resp", response);
|
||||
console.log("body", body);
|
||||
this.setState({lastOutput: body.text})
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
renderOutput() {
|
||||
if (!this.state.lastOutput) {
|
||||
return null;
|
||||
}
|
||||
return <textarea readOnly value={ this.state.lastOutput } />;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (<div>
|
||||
<textarea value={ this.state.value } onChange={this.handleChange}>
|
||||
</textarea>
|
||||
<button onClick={ this.submit }>Run!</button>
|
||||
<div className="input">
|
||||
<textarea value={ this.state.value } onChange={this.handleChange}>
|
||||
</textarea>
|
||||
<button onClick={ this.submit }>Run!</button>
|
||||
</div>
|
||||
<div className="output">
|
||||
{ this.renderOutput() }
|
||||
</div>
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user