-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathRunButton.js
52 lines (41 loc) · 1.27 KB
/
RunButton.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React,{Component} from 'react';
import {Button} from 'reactstrap';
class RunCodeButton extends Component {
constructor(props){
super(props);
this.submitCode = this.submitCode.bind(this);
}
submitCode(event) {
event.preventDefault()
const codeText = this.props.editor.getValue()
const codeLanguage = this.props.language.toLowerCase()
const isCustomInput = this.props.isCustomInput
var stdin = ''
if(isCustomInput){
stdin = document.getElementById('customInput').value
}
var data = {
content: codeText,
language: codeLanguage,
customInput: isCustomInput,
stdin: stdin,
submit: false
}
if(this.props.customFunction === undefined){
console.error('No Run Function is defined for the TextIDE Component')
}
else {
this.props.customFunction(data)
}
}
render(){
return (
<div>
<Button className="btn btn-outline-primary" onClick= {this.submitCode} style={{color:'white'}}>
Run Code
</Button>
</div>
)
}
}
export default RunCodeButton;