2020-06-29 18:23:56 +00:00
|
|
|
<template>
|
|
|
|
<header id="search">
|
|
|
|
<div class="search__icon">
|
|
|
|
<i class="material-icons">search</i>
|
|
|
|
</div>
|
|
|
|
<input
|
|
|
|
id="searchbar"
|
|
|
|
autocomplete="off"
|
|
|
|
type="search"
|
|
|
|
name="searchbar"
|
|
|
|
value=""
|
2020-07-06 19:55:28 +00:00
|
|
|
placeholder="Search what you want (or just paste a link)"
|
2020-06-29 18:23:56 +00:00
|
|
|
autofocus
|
2020-07-06 19:55:28 +00:00
|
|
|
ref="searchbar"
|
|
|
|
@keyup="handleSearchBarKeyup($event)"
|
2020-06-29 18:23:56 +00:00
|
|
|
/>
|
|
|
|
</header>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-07-06 19:55:28 +00:00
|
|
|
import { isValidURL } from '@/js/utils.js'
|
|
|
|
import Downloads from '@/js/downloads.js'
|
|
|
|
import Tabs from '@/js/tabs.js'
|
|
|
|
import EventBus from '@/js/EventBus.js'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
handleSearchBarKeyup(keyEvent) {
|
|
|
|
// Enter key
|
|
|
|
if (keyEvent.keyCode !== 13) return
|
|
|
|
|
|
|
|
let term = this.$refs.searchbar.value
|
|
|
|
|
|
|
|
if (isValidURL(term)) {
|
|
|
|
if (keyEvent.ctrlKey) {
|
|
|
|
this.$root.$emit('QualityModal:open', term)
|
|
|
|
} else {
|
|
|
|
if (main_selected === 'analyzer_tab') {
|
|
|
|
Tabs.analyzeLink(term)
|
|
|
|
} else {
|
|
|
|
Downloads.sendAddToQueue(term)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (term === '') return
|
|
|
|
|
|
|
|
this.$root.$emit('mainSearch:showNewResults', term, main_selected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 18:23:56 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|