mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
82 lines
1.7 KiB
JavaScript
82 lines
1.7 KiB
JavaScript
import { html, Component } from "../lib/index.js";
|
|
|
|
export default class SettingsForm extends Component {
|
|
state = {};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state.secondsInTimestamps = props.settings.secondsInTimestamps;
|
|
this.state.bufferEvents = props.settings.bufferEvents;
|
|
|
|
this.handleChange = this.handleChange.bind(this);
|
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
}
|
|
|
|
handleChange(event) {
|
|
let target = event.target;
|
|
let value = target.type == "checkbox" ? target.checked : target.value;
|
|
this.setState({ [target.name]: value }, () => {
|
|
this.props.onChange(this.state);
|
|
});
|
|
}
|
|
|
|
handleSubmit(event) {
|
|
event.preventDefault();
|
|
this.props.onClose();
|
|
}
|
|
|
|
render() {
|
|
return html`
|
|
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
|
|
<label>
|
|
<input
|
|
type="checkbox"
|
|
name="secondsInTimestamps"
|
|
checked=${this.state.secondsInTimestamps}
|
|
/>
|
|
Show seconds in time indicator
|
|
</label>
|
|
<br/><br/>
|
|
|
|
<label>
|
|
<input
|
|
type="radio"
|
|
name="bufferEvents"
|
|
value="fold"
|
|
checked=${this.state.bufferEvents === "fold"}
|
|
/>
|
|
Show and fold chat events
|
|
</label>
|
|
<br/>
|
|
<label>
|
|
<input
|
|
type="radio"
|
|
name="bufferEvents"
|
|
value="expand"
|
|
checked=${this.state.bufferEvents === "expand"}
|
|
/>
|
|
Show and expand chat events
|
|
</label>
|
|
<br/>
|
|
<label>
|
|
<input
|
|
type="radio"
|
|
name="bufferEvents"
|
|
value="hide"
|
|
checked=${this.state.bufferEvents === "hide"}
|
|
/>
|
|
Hide chat events
|
|
</label>
|
|
<br/><br/>
|
|
|
|
<button type="button" class="danger" onClick=${() => this.props.onDisconnect()}>
|
|
Disconnect
|
|
</button>
|
|
<button>
|
|
Close
|
|
</button>
|
|
</form>
|
|
`;
|
|
}
|
|
}
|