2022-02-25 12:52:17 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2022-03-02 17:35:38 +00:00
|
|
|
|
|
|
|
|
2022-02-25 12:52:17 +00:00
|
|
|
<v-text-field
|
|
|
|
label="Search"
|
2022-02-25 18:54:15 +00:00
|
|
|
v-model="text"
|
|
|
|
@input="textChanged"
|
2022-03-02 13:18:17 +00:00
|
|
|
class="searchBar"
|
2022-02-25 12:52:17 +00:00
|
|
|
/>
|
2022-03-02 17:35:38 +00:00
|
|
|
|
|
|
|
<div style="min-width: 180px;">
|
2022-02-26 20:15:30 +00:00
|
|
|
<v-list-item v-for="(item, index) in response" :key="index">
|
2022-03-02 17:35:38 +00:00
|
|
|
<v-btn text dense class="info--text searchButton text-left" @click="search(item)" v-text="item[0]" />
|
2022-02-26 20:15:30 +00:00
|
|
|
</v-list-item>
|
2022-03-02 17:35:38 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2022-02-25 12:52:17 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2022-02-25 18:54:15 +00:00
|
|
|
|
2022-03-02 13:18:17 +00:00
|
|
|
<style scoped>
|
|
|
|
.searchBar {
|
|
|
|
margin: 0 1em 1em 1em;
|
|
|
|
}
|
2022-03-02 17:35:38 +00:00
|
|
|
.searchButton {
|
|
|
|
width: 100%;
|
|
|
|
justify-content: left !important;
|
|
|
|
}
|
2022-03-02 13:18:17 +00:00
|
|
|
</style>
|
|
|
|
|
2022-02-25 18:54:15 +00:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
text: null,
|
2022-02-26 20:15:30 +00:00
|
|
|
response: [],
|
2022-02-25 18:54:15 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
textChanged() {
|
2022-02-26 19:45:34 +00:00
|
|
|
this.$youtube.autoComplete(this.text, (res) => {
|
2022-03-03 17:56:17 +00:00
|
|
|
const data = res.replace(/^.*?\(/,'').replace(/\)$/,''); //Format Response
|
2022-02-26 20:15:30 +00:00
|
|
|
this.response = JSON.parse(data)[1]
|
2022-02-25 18:54:15 +00:00
|
|
|
});
|
2022-03-02 17:35:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
search(item) {
|
2022-03-04 02:25:30 +00:00
|
|
|
location.href="/search?q="+item[0];
|
2022-02-25 18:54:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|