refactor and fix some things

This commit is contained in:
David Ralph
2021-01-16 18:39:03 +00:00
parent 5c579ee0a2
commit 0a735384df
23 changed files with 122 additions and 117 deletions

View File

@@ -18,13 +18,12 @@ export default class Search extends React.PureComponent {
startSpeechRecognition() {
const voiceSearch = new window.webkitSpeechRecognition();
voiceSearch.start();
voiceSearch.onresult = (event) => document.getElementById('searchtext').value = event.results[0][0].transcript;
voiceSearch.onend = () => setTimeout(() => window.location.href = this.state.url + `?${this.state.query}=` + document.getElementById('searchtext').value, 1000);
const searchText = document.getElementById('searchtext');
voiceSearch.onresult = (event) => searchText.value = event.results[0][0].transcript;
voiceSearch.onend = () => setTimeout(() => window.location.href = this.state.url + `?${this.state.query}=` + searchText.value, 1000);
}
render() {
if (localStorage.getItem('searchBar') === 'false') return null;
let url;
let query = 'q';
@@ -52,8 +51,8 @@ export default class Search extends React.PureComponent {
}
return (
<div id='searchBar' className='searchbar'>
<form id='searchBar' className='searchbarform' action={url}>
<div id='searchBar'>
<form action={url}>
{microphone}
<SearchIcon onClick={() => searchButton()} id='searchButton' />
<input type='text' placeholder={this.props.language} name={query} id='searchtext' className='searchtext'/>