2022-01-24 22:56:57 +00:00
|
|
|
<template>
|
2022-03-31 04:22:24 +00:00
|
|
|
<v-app style="background: transparent !important">
|
2022-03-21 20:34:34 +00:00
|
|
|
<topNavigation
|
2022-03-21 23:47:11 +00:00
|
|
|
:search="search"
|
|
|
|
:page="page"
|
2022-03-21 20:34:34 +00:00
|
|
|
@close-search="search = !search"
|
|
|
|
@search-btn="searchBtn"
|
|
|
|
@text-changed="textChanged"
|
2022-03-24 04:55:38 +00:00
|
|
|
@scroll-to-top="$refs.pgscroll.scrollTop = 0"
|
2022-03-21 20:34:34 +00:00
|
|
|
/>
|
2022-01-24 23:16:53 +00:00
|
|
|
|
2022-03-31 04:22:24 +00:00
|
|
|
<div style="height: 100%; margin-top: 4rem">
|
2022-03-18 11:49:47 +00:00
|
|
|
<div
|
2022-03-21 20:34:34 +00:00
|
|
|
v-show="!search"
|
2022-04-01 00:15:13 +00:00
|
|
|
class="scrollcontainer"
|
2022-03-31 04:22:24 +00:00
|
|
|
style="overflow: hidden; height: calc(100vh - 8rem)"
|
2022-03-17 23:17:08 +00:00
|
|
|
>
|
2022-03-21 06:03:33 +00:00
|
|
|
<!-- element above removes artifacting from things like v-ripple by -->
|
2022-03-21 05:13:21 +00:00
|
|
|
<!-- scrollbox below must be a standalone div -->
|
2022-03-25 12:07:35 +00:00
|
|
|
<div ref="pgscroll" class="scroll-y" style="height: 100%">
|
2022-03-24 16:16:23 +00:00
|
|
|
<nuxt />
|
2022-03-21 20:34:34 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-show="search"
|
2022-04-01 00:15:13 +00:00
|
|
|
class="scrollcontainer"
|
|
|
|
style="overflow: hidden; height: calc(100vh - 4rem)"
|
2022-03-21 20:34:34 +00:00
|
|
|
>
|
|
|
|
<div class="scroll-y" style="height: 100%">
|
2022-03-21 23:47:11 +00:00
|
|
|
<div v-if="search" style="min-width: 180px">
|
2022-03-22 08:23:23 +00:00
|
|
|
<v-list-item
|
|
|
|
v-for="(item, index) in response"
|
|
|
|
:key="index"
|
|
|
|
class="px-0"
|
2022-04-13 10:15:26 +00:00
|
|
|
v-emoji
|
2022-03-22 08:23:23 +00:00
|
|
|
>
|
2022-03-21 05:13:21 +00:00
|
|
|
<v-btn
|
|
|
|
text
|
2022-03-22 01:13:48 +00:00
|
|
|
tile
|
2022-03-21 05:13:21 +00:00
|
|
|
dense
|
2022-04-13 01:43:32 +00:00
|
|
|
class="searchButton text-left"
|
2022-03-21 05:13:21 +00:00
|
|
|
@click="youtubeSearch(item)"
|
2022-03-22 01:13:48 +00:00
|
|
|
>
|
|
|
|
<v-icon class="mr-5">mdi-magnify</v-icon>
|
2022-04-11 01:00:42 +00:00
|
|
|
{{ item[0] || item.text }}
|
2022-03-22 01:13:48 +00:00
|
|
|
</v-btn>
|
2022-03-21 05:13:21 +00:00
|
|
|
</v-list-item>
|
|
|
|
</div>
|
2022-03-07 18:53:14 +00:00
|
|
|
</div>
|
2022-02-25 04:45:17 +00:00
|
|
|
</div>
|
2022-02-24 19:45:36 +00:00
|
|
|
</div>
|
2022-01-24 22:56:57 +00:00
|
|
|
|
2022-03-18 12:21:06 +00:00
|
|
|
<bottomNavigation v-if="!search" />
|
2022-01-24 22:56:57 +00:00
|
|
|
|
2022-03-13 20:16:00 +00:00
|
|
|
<updateChecker />
|
2022-01-24 22:56:57 +00:00
|
|
|
</v-app>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-03-21 05:13:21 +00:00
|
|
|
import { App as CapacitorApp } from "@capacitor/app";
|
|
|
|
import { mapState } from "vuex";
|
2022-04-11 01:00:42 +00:00
|
|
|
import constants from "~/plugins/constants";
|
2022-04-11 05:06:40 +00:00
|
|
|
import { linkParser } from "~/plugins/utils";
|
2022-04-11 01:00:42 +00:00
|
|
|
|
2022-03-07 18:53:14 +00:00
|
|
|
export default {
|
|
|
|
data: () => ({
|
|
|
|
search: false,
|
|
|
|
response: [],
|
|
|
|
}),
|
2022-03-23 13:30:24 +00:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
roundTweak: (state) => state.tweaks.roundTweak,
|
|
|
|
}),
|
|
|
|
page: function () {
|
|
|
|
const splitPath = this.$route.path.split("/");
|
|
|
|
let pageName = splitPath[splitPath.length - 1];
|
|
|
|
pageName = pageName.charAt(0).toUpperCase() + pageName.slice(1);
|
|
|
|
return pageName || "Home";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
// Watch for any changes in the route string
|
|
|
|
// When change is detected, scroll main div back to the top
|
|
|
|
$route() {
|
|
|
|
this.$refs.pgscroll.scrollTop = 0; // scroll back to top when moving to new route
|
2022-03-23 15:31:04 +00:00
|
|
|
// Exit fullscreen if currently in fullscreen
|
|
|
|
this.$vuetube.statusBar.show();
|
|
|
|
this.$vuetube.navigationBar.show();
|
2022-03-25 12:07:35 +00:00
|
|
|
},
|
2022-03-23 13:30:24 +00:00
|
|
|
},
|
|
|
|
|
2022-03-07 18:53:14 +00:00
|
|
|
mounted() {
|
2022-03-13 19:45:48 +00:00
|
|
|
//--- Back Button Listener ---//
|
2022-03-21 05:13:21 +00:00
|
|
|
CapacitorApp.addListener("backButton", ({ canGoBack }) => {
|
2022-03-13 19:45:48 +00:00
|
|
|
//--- Back Closes Search ---//
|
2022-03-13 18:20:43 +00:00
|
|
|
if (this.search) {
|
|
|
|
this.search = false;
|
2022-03-14 17:13:24 +00:00
|
|
|
|
2022-03-21 05:13:21 +00:00
|
|
|
//--- Back Goes Back ---//
|
|
|
|
} else if (!canGoBack) {
|
2022-03-07 18:53:14 +00:00
|
|
|
CapacitorApp.exitApp();
|
|
|
|
} else {
|
|
|
|
window.history.back();
|
2022-02-24 22:21:28 +00:00
|
|
|
}
|
2022-03-07 18:53:14 +00:00
|
|
|
});
|
2022-04-01 01:02:08 +00:00
|
|
|
|
2022-04-12 12:30:18 +00:00
|
|
|
// --- External URL Handling --- //
|
2022-04-01 01:02:08 +00:00
|
|
|
CapacitorApp.addListener("appUrlOpen", (event) => {
|
2022-04-12 05:26:33 +00:00
|
|
|
this.$logger("ExternalURL", event.url);
|
|
|
|
// We only push to the route if there is a url present
|
2022-04-13 01:43:32 +00:00
|
|
|
linkParser(event.url);
|
|
|
|
if (result) this.$router.push(result.pathname + result.search);
|
2022-04-01 01:02:08 +00:00
|
|
|
});
|
2022-04-07 07:32:24 +00:00
|
|
|
|
|
|
|
// --- Import Twemoji ---///
|
|
|
|
const plugin = document.createElement("script");
|
|
|
|
plugin.setAttribute("src", "//twemoji.maxcdn.com/v/latest/twemoji.min.js");
|
|
|
|
plugin.setAttribute("crossorigin", "anonymous");
|
|
|
|
document.head.appendChild(plugin);
|
2022-03-07 18:53:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2022-03-21 20:34:34 +00:00
|
|
|
textChanged(text) {
|
2022-04-11 05:06:40 +00:00
|
|
|
if (text.length <= 0) {
|
|
|
|
this.response = [];
|
|
|
|
return;
|
|
|
|
} // No text found, no point in calling API
|
2022-04-11 01:00:42 +00:00
|
|
|
|
|
|
|
//--- User Pastes Link, Direct Them To Video ---//
|
|
|
|
const isLink = linkParser(text);
|
|
|
|
if (isLink) {
|
2022-04-11 05:06:40 +00:00
|
|
|
this.response = [
|
|
|
|
{
|
2022-04-13 01:43:32 +00:00
|
|
|
text: `Watch Video from ID: ${isLink.searchParams.get("v")}`,
|
|
|
|
id: isLink.searchParams.get("v"),
|
2022-04-11 05:06:40 +00:00
|
|
|
},
|
|
|
|
];
|
2022-04-11 01:00:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
//--- End User Pastes Link, Direct Them To Video ---//
|
|
|
|
|
|
|
|
//--- Auto Suggest ---//
|
2022-03-21 20:34:34 +00:00
|
|
|
this.$youtube.autoComplete(text, (res) => {
|
2022-03-21 05:13:21 +00:00
|
|
|
const data = res.replace(/^.*?\(/, "").replace(/\)$/, ""); //Format Response
|
|
|
|
this.response = JSON.parse(data)[1];
|
2022-03-07 18:53:14 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
youtubeSearch(item) {
|
2022-04-11 05:06:40 +00:00
|
|
|
const link = item.id ? `/watch?v=${item.id}` : `/search?q=${item[0]}`;
|
2022-04-11 01:00:42 +00:00
|
|
|
this.$router.push(link);
|
2022-03-16 00:37:33 +00:00
|
|
|
this.search = false;
|
2022-03-17 22:25:13 +00:00
|
|
|
},
|
|
|
|
|
2022-03-21 20:34:34 +00:00
|
|
|
searchBtn(text) {
|
|
|
|
const query = text;
|
2022-03-17 22:25:13 +00:00
|
|
|
|
2022-03-22 08:23:23 +00:00
|
|
|
this.$logger(
|
|
|
|
constants.LOGGER_NAMES.search,
|
|
|
|
"Query: " + query + " this.search: " + this.search
|
|
|
|
);
|
|
|
|
|
2022-03-17 22:25:13 +00:00
|
|
|
if (this.search === true) {
|
2022-03-21 05:13:21 +00:00
|
|
|
if (query) {
|
2022-03-19 19:39:07 +00:00
|
|
|
this.$router.push(`/search?q=${query}`);
|
|
|
|
this.search = false;
|
|
|
|
}
|
2022-03-17 22:25:13 +00:00
|
|
|
} else {
|
|
|
|
this.search = true;
|
|
|
|
}
|
2022-03-21 05:13:21 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-01-24 22:56:57 +00:00
|
|
|
</script>
|
2022-03-23 13:30:24 +00:00
|
|
|
|
|
|
|
<style>
|
|
|
|
* {
|
|
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
|
|
|
|
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
|
|
|
}
|
2022-03-25 12:07:35 +00:00
|
|
|
*:focus::before {
|
|
|
|
opacity: 0 !important;
|
|
|
|
}
|
|
|
|
|
2022-04-01 00:15:13 +00:00
|
|
|
.scrollcontainer {
|
|
|
|
overflow: hidden;
|
|
|
|
/* ios notch & gesture nav */
|
|
|
|
padding: env(safe-area-inset-top) env(safe-area-inset-right)
|
|
|
|
env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
|
|
|
|
}
|
|
|
|
|
2022-03-23 13:30:24 +00:00
|
|
|
.scroll-y {
|
|
|
|
overflow-y: scroll !important; /* has to be scroll, not auto */
|
2022-03-31 04:22:24 +00:00
|
|
|
overflow-x: hidden !important;
|
2022-03-23 13:30:24 +00:00
|
|
|
-webkit-overflow-scrolling: touch !important;
|
|
|
|
}
|
|
|
|
html,
|
|
|
|
body {
|
2022-03-31 04:22:24 +00:00
|
|
|
background: var(--v-background-base);
|
2022-03-23 13:30:24 +00:00
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
p,
|
|
|
|
span,
|
|
|
|
div {
|
|
|
|
-webkit-user-select: none; /* Safari */
|
|
|
|
-moz-user-select: none; /* Firefox */
|
|
|
|
-ms-user-select: none; /* IE10+/Edge */
|
|
|
|
user-select: none; /* Standard */
|
|
|
|
}
|
|
|
|
|
|
|
|
.invert {
|
|
|
|
filter: invert(100%);
|
|
|
|
}
|
2022-04-13 03:55:29 +00:00
|
|
|
|
|
|
|
.emoji {
|
|
|
|
display: inline-block;
|
|
|
|
width: 1em;
|
|
|
|
height: 1em;
|
|
|
|
vertical-align: -0.1em;
|
|
|
|
}
|
2022-03-23 13:30:24 +00:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.searchButton {
|
|
|
|
width: 100%;
|
2022-04-13 01:43:32 +00:00
|
|
|
text-transform: none !important;
|
2022-03-23 13:30:24 +00:00
|
|
|
justify-content: left !important;
|
|
|
|
}
|
|
|
|
</style>
|