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(); } registerProtocol() { let url = window.location.origin + window.location.pathname + "?open=%s"; try { navigator.registerProtocolHandler("irc", url); navigator.registerProtocolHandler("ircs", url); } catch (err) { console.error("Failed to register protocol handler: ", err); } } render() { let protocolHandler = null; if (this.props.showProtocolHandler) { protocolHandler = html`