0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-08 04:25:07 +00:00
VueTube/NUXT/components/searchOverlay.vue

56 lines
960 B
Vue
Raw Normal View History

<template>
<div>
2022-03-02 17:35:38 +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-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>
</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() {
this.$youtube.autoComplete(this.text, (res) => {
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>