From 06d4c96c018c2b80f2040d78d4bfe114becafdc4 Mon Sep 17 00:00:00 2001 From: Nikita Krupin Date: Sat, 14 May 2022 17:20:44 -0400 Subject: [PATCH] search suggestions update bugfix --- NUXT/components/topNavigation.vue | 3 ++- NUXT/layouts/default.vue | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/NUXT/components/topNavigation.vue b/NUXT/components/topNavigation.vue index 8464a85..7367cbd 100644 --- a/NUXT/components/topNavigation.vue +++ b/NUXT/components/topNavigation.vue @@ -29,6 +29,7 @@ $vuetify.theme.dark ? 'background lighten-1' : 'background darken-1' " @input="$emit('text-changed', text)" + @ @keyup.enter="$emit('search-btn', text)" /> @@ -80,7 +81,7 @@ export default { default: "Home", }, }, - events: ["searchBtn", "textChanged", "closeSearch"], + events: ["searchBtn", "textChanged", "closeSearch", "scrollToTop"], data: () => ({ text: "", }), diff --git a/NUXT/layouts/default.vue b/NUXT/layouts/default.vue index 90ea2d0..bd94d6f 100644 --- a/NUXT/layouts/default.vue +++ b/NUXT/layouts/default.vue @@ -4,9 +4,9 @@ :search="search" :page="page" style="z-index: 696969" - @close-search="search = !search" @search-btn="searchBtn" @text-changed="textChanged" + @close-search="search = !search" @scroll-to-top="$refs.pgscroll.scrollTop = 0" /> @@ -62,21 +62,17 @@ >
- + mdi-magnify - {{ item[0] || item.text }} + {{ item[0] }}
@@ -163,10 +159,17 @@ export default { return; } // No text found, no point in calling API + //--- Auto Suggest ---// + this.$youtube.autoComplete(text, (res) => { + const data = res.replace(/^.*?\(/, "").replace(/\)$/, ""); //Format Response + this.response = JSON.parse(data)[1]; + }); + //--- User Pastes Link, Direct Them To Video ---// const isLink = linkParser(text); if (isLink) { this.response = [ + `Watch Video from ID: ${isLink.searchParams.get("v")}`, { text: `Watch Video from ID: ${isLink.searchParams.get("v")}`, id: isLink.searchParams.get("v"), @@ -175,12 +178,6 @@ export default { return; } //--- End User Pastes Link, Direct Them To Video ---// - - //--- Auto Suggest ---// - this.$youtube.autoComplete(text, (res) => { - const data = res.replace(/^.*?\(/, "").replace(/\)$/, ""); //Format Response - this.response = JSON.parse(data)[1]; - }); }, youtubeSearch(item) {