/**
* Crawler simulation module
* @author Hai Zheng
*/
class CrawlerSimulate extends React.Component {
constructor(props) {
super(props);
this.state = {
list: props.list,
};
this.handleInputChange = this.handleInputChange.bind(this);
this.delRow = this.delRow.bind(this);
this.addNew = this.addNew.bind(this);
}
handleInputChange(e, index) {
const target = e.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const list = this.state.list;
list[index][target.dataset.type] = value;
this.setState({
list: list,
});
}
delRow(index) {
const data = this.state.list;
data.splice(index, 1);
this.setState({ list: data });
}
addNew() {
const list = this.state.list;
list.push({ name: '', vals: '' });
this.setState({ list: list });
}
render() {
return (