2017-09-20 23:15:29 -07:00
|
|
|
const React = require("react");
|
|
|
|
const ReactDOM = require("react-dom");
|
2017-09-21 00:01:54 -07:00
|
|
|
const request = require("request");
|
2017-09-20 23:15:29 -07:00
|
|
|
|
2017-09-21 00:01:54 -07:00
|
|
|
const serverAddress = "http://localhost:8000";
|
2017-09-20 23:46:46 -07:00
|
|
|
|
|
|
|
class CodeArea extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {value: ""};
|
|
|
|
this.handleChange = this.handleChange.bind(this);
|
|
|
|
this.submit = this.submit.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleChange(event) {
|
|
|
|
this.setState({value: event.target.value});
|
|
|
|
}
|
|
|
|
|
|
|
|
submit(event) {
|
|
|
|
console.log("This", this.state.value);
|
2017-09-21 00:01:54 -07:00
|
|
|
const options = {
|
|
|
|
url: `${serverAddress}/input`,
|
|
|
|
json: true,
|
|
|
|
body: {source: this.state.value}
|
|
|
|
};
|
|
|
|
request.post(options, (error, response, body) => {
|
|
|
|
console.log("resp", response);
|
|
|
|
console.log("body", body);
|
|
|
|
});
|
2017-09-20 23:46:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (<div>
|
|
|
|
<textarea value={ this.state.value } onChange={this.handleChange}>
|
|
|
|
</textarea>
|
|
|
|
<button onClick={ this.submit }>Run!</button>
|
|
|
|
</div>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-20 23:21:45 -07:00
|
|
|
const main = (<div>
|
|
|
|
<h1>Schala web input</h1>
|
|
|
|
<p>Write your source code here</p>
|
2017-09-20 23:46:46 -07:00
|
|
|
<CodeArea/>
|
2017-09-20 23:21:45 -07:00
|
|
|
</div>);
|
|
|
|
|
|
|
|
const rootDom = document.getElementById("main");
|
2017-09-20 23:46:46 -07:00
|
|
|
ReactDOM.render(main, rootDom);
|