- resolved issues
- added validation URL for custom instance
- added theater
- fixed efy_select component (show description, show recommendation, and autoloop)  only saves localstorage to autoplay when switched
- fixed chapter card model's width when thumbnail error
This commit is contained in:
SubTeno 2022-10-12 13:57:53 +00:00
parent 2e48c60f8e
commit f85fbd6dc4
7 changed files with 81 additions and 29 deletions

View file

@ -1,13 +1,13 @@
<template> <template>
<NavBar /> <NavBar />
<div class="pp-base min-h-screen px-1vw reset" :class="[theme]"> <div class="pp-base min-h-screen reset">
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<keep-alive :max="5"> <keep-alive :max="5">
<component :is="Component" :key="$route.fullPath" /> <component :is="Component" :key="$route.fullPath" />
</keep-alive> </keep-alive>
</router-view> </router-view>
</div> </div>
<label :class="[theme]"> <label>
<FooterComponent /> <FooterComponent />
</label> </label>
</template> </template>

View file

@ -1,6 +1,13 @@
<template> <template>
<!-- desktop view --> <!-- desktop view -->
<div v-if="!mobileLayout" class="pp-chapters flex-col overflow-y-scroll max-h-75vh min-h-64 lt-lg:hidden"> <div
v-if="!mobileLayout"
:class="
theater
? 'pp-chapters flex-col overflow-y-scroll max-h-90vh min-h-64 lt-lg:hidden'
: 'pp-chapters flex-col overflow-y-scroll max-h-75vh min-h-64 lt-lg:hidden'
"
>
<h6 aria-label="chapters" title="chapters">{{ $t("video.chapters") }} - {{ chapters.length }}</h6> <h6 aria-label="chapters" title="chapters">{{ $t("video.chapters") }} - {{ chapters.length }}</h6>
<div <div
:key="chapter.start" :key="chapter.start"
@ -56,6 +63,10 @@ import { defineProps, defineEmits } from "vue";
const props = defineProps({ const props = defineProps({
chapters: Object, chapters: Object,
theater: {
type: Boolean,
default: () => false,
},
mobileLayout: { mobileLayout: {
type: Boolean, type: Boolean,
default: () => true, default: () => true,

View file

@ -5,7 +5,7 @@
<div class="text-center"> <div class="text-center">
<select v-model="selectedInstance"> <select v-model="selectedInstance">
<option <option
v-for="(instance, pointer) in custominstance" v-for="(instance, pointer) in customInstances"
:key="pointer" :key="pointer"
:value="pointer" :value="pointer"
v-text="instance.name" v-text="instance.name"
@ -45,34 +45,45 @@
<script> <script>
import ModalComponent from "./ModalComponent.vue"; import ModalComponent from "./ModalComponent.vue";
const isUrl = string => {
try {
return Boolean(new URL(string));
} catch (e) {
return false;
}
};
export default { export default {
data() { data() {
return { return {
custominstance: [], customInstances: [],
}; };
}, },
mounted() { mounted() {
if (this.testLocalStorage) { if (this.testLocalStorage) {
if (localStorage.getItem("custominstance") === null) { if (localStorage.getItem("custominstances") === null) {
localStorage.setItem("custominstance", "[]"); localStorage.setItem("custominstances", "[]");
} }
this.custominstance = JSON.parse(localStorage.getItem("custominstance")); this.customInstances = JSON.parse(localStorage.getItem("custominstances"));
} }
}, },
methods: { methods: {
add() { add() {
if (this.testLocalStorage) { if (this.testLocalStorage) {
this.custominstance.push({ if (!isUrl(this.url)) {
alert("Not a valid URL");
return;
}
this.customInstances.push({
name: this.name, name: this.name,
api_url: this.url, api_url: this.url,
}); });
localStorage.setItem("custominstance", JSON.stringify(this.custominstance)); localStorage.setItem("custominstance", JSON.stringify(this.customInstances));
} }
}, },
remove() { remove() {
if (this.testLocalStorage) { if (this.testLocalStorage) {
this.custominstance.splice(this.selectedInstance); this.customInstances.splice(this.selectedInstance);
localStorage.setItem("custominstance", JSON.stringify(this.custominstance)); localStorage.setItem("custominstance", JSON.stringify(this.customInstances));
window.location = "/preferences"; window.location = "/preferences";
} }
}, },

View file

@ -399,7 +399,7 @@ export default {
authInstance: false, authInstance: false,
selectedAuthInstance: null, selectedAuthInstance: null,
instances: [], instances: [],
custominstances: [], customInstances: [],
showmodal: false, showmodal: false,
sponsorBlock: true, sponsorBlock: true,
skipSponsor: true, skipSponsor: true,
@ -483,12 +483,12 @@ export default {
}, },
async mounted() { async mounted() {
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} }); if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
this.custominstances = JSON.parse(localStorage.getItem("custominstance")); this.customInstances = JSON.parse(localStorage.getItem("custominstance"));
this.fetchJson("https://piped-instances.kavin.rocks/") this.fetchJson("https://piped-instances.kavin.rocks/")
.then(resp => { .then(resp => {
this.instances = resp; this.instances = resp;
if (this.custominstances != null) if (this.customInstances != null)
this.custominstances.forEach(cusinstance => { this.customInstances.forEach(cusinstance => {
this.instances.push(cusinstance); this.instances.push(cusinstance);
}); });
if (this.instances.filter(instance => instance.api_url == this.apiUrl()).length == 0) if (this.instances.filter(instance => instance.api_url == this.apiUrl()).length == 0)
@ -500,8 +500,8 @@ export default {
}); });
}) })
.catch(() => { .catch(() => {
if (this.custominstances != null) if (this.customInstances != null)
this.custominstances.forEach(cusinstance => { this.customInstances.forEach(cusinstance => {
this.instances.push(cusinstance); this.instances.push(cusinstance);
}); });
}); });

View file

@ -2,7 +2,7 @@
<div <div
ref="container" ref="container"
data-shaka-player-container data-shaka-player-container
class="w-full max-h-screen flex justify-center" class="w-full !max-h-full flex justify-center"
:class="{ 'player-container': !isEmbed }" :class="{ 'player-container': !isEmbed }"
> >
<video ref="videoEl" class="w-full" data-shaka-player :autoplay="shouldAutoPlay" :loop="selectedAutoLoop" /> <video ref="videoEl" class="w-full" data-shaka-player :autoplay="shouldAutoPlay" :loop="selectedAutoLoop" />

View file

@ -16,7 +16,12 @@
<ErrorHandler v-if="video && video.error" :message="video.message" :error="video.error" /> <ErrorHandler v-if="video && video.error" :message="video.message" :error="video.error" />
<div v-show="!video.error"> <div v-show="!video.error">
<div :class="isMobile ? 'flex-col' : 'flex'"> <div
:class="[
isMobile ? 'flex-col' : 'flex',
showThea ? 'w-screen relative right-[10vw] max-h-[90vh]' : 'max-h-[75vh]',
]"
>
<VideoPlayer <VideoPlayer
ref="videoPlayer" ref="videoPlayer"
:video="video" :video="video"
@ -32,6 +37,7 @@
v-if="video?.chapters?.length > 0 && showChapters" v-if="video?.chapters?.length > 0 && showChapters"
:chapters="video.chapters" :chapters="video.chapters"
:player-position="currentTime" :player-position="currentTime"
:theater="showThea"
@seek="navigate" @seek="navigate"
/> />
</div> </div>
@ -136,9 +142,11 @@
<hr /> <hr />
<div efy_select> <div efy_select>
<input id="showDesc" type="checkbox" v-model="showDesc" /> <input v-if="!isMobile" id="showThea" type="checkbox" v-model="showThea" @change="onChange($event)" />
<label v-if="!isMobile" for="showThea" v-t="'Theater'" />
<input id="showDesc" type="checkbox" v-model="showDesc" @change="onChange($event)" />
<label for="showDesc" v-t="'actions.show_description'" /> <label for="showDesc" v-t="'actions.show_description'" />
<input id="showRecs" type="checkbox" v-model="showRecs" /> <input id="showRecs" type="checkbox" v-model="showRecs" @change="onChange($event)" />
<label for="showRecs" v-t="'actions.show_recommendations'" /> <label for="showRecs" v-t="'actions.show_recommendations'" />
<input id="chkAutoLoop" v-model="selectedAutoLoop" type="checkbox" @change="onChange($event)" /> <input id="chkAutoLoop" v-model="selectedAutoLoop" type="checkbox" @change="onChange($event)" />
<label for="chkAutoLoop" v-text="`${$t('actions.loop_this_video')}`" /> <label for="chkAutoLoop" v-text="`${$t('actions.loop_this_video')}`" />
@ -150,7 +158,6 @@
</span> </span>
</div> </div>
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-show="showDesc" class="break-words mb-2" v-html="purifyHTML(video.description)" /> <div v-show="showDesc" class="break-words mb-2" v-html="purifyHTML(video.description)" />
<div <div
v-if="showDesc && sponsors && sponsors.segments" v-if="showDesc && sponsors && sponsors.segments"
@ -235,6 +242,7 @@ export default {
selectedAutoLoop: false, selectedAutoLoop: false,
selectedAutoPlay: null, selectedAutoPlay: null,
showDesc: true, showDesc: true,
showThea: false,
showRecs: true, showRecs: true,
showChapters: true, showChapters: true,
comments: null, comments: null,
@ -273,7 +281,6 @@ export default {
}, },
}, },
mounted() { mounted() {
console.log("ASD");
// check screen size // check screen size
if (window.innerWidth >= 1024) { if (window.innerWidth >= 1024) {
this.isMobile = false; this.isMobile = false;
@ -325,9 +332,10 @@ export default {
}); });
}, },
activated() { activated() {
console.log("ASD");
this.active = true; this.active = true;
this.selectedAutoPlay = this.getPreferenceBoolean("autoplay", false); this.selectedAutoPlay = this.getPreferenceBoolean("autoplay", false);
this.selectedAutoLoop = this.getPreferenceBoolean("loop", false);
this.showThea = this.getPreferenceBoolean("theater", false);
this.showDesc = !this.getPreferenceBoolean("minimizeDescription", false); this.showDesc = !this.getPreferenceBoolean("minimizeDescription", false);
this.showRecs = !this.getPreferenceBoolean("minimizeRecommendations", false); this.showRecs = !this.getPreferenceBoolean("minimizeRecommendations", false);
if (this.video.duration) { if (this.video.duration) {
@ -361,8 +369,30 @@ export default {
fetchComments() { fetchComments() {
return this.fetchJson(this.apiUrl() + "/comments/" + this.getVideoId()); return this.fetchJson(this.apiUrl() + "/comments/" + this.getVideoId());
}, },
onChange() { onChange(event) {
this.setPreference("autoplay", this.selectedAutoPlay); if (this.testLocalStorage) {
switch (event.target.id) {
case "showThea":
this.setPreference("theater", this.showThea);
scroll(0, 0);
break;
case "showDesc":
this.setPreference("minimizeDescription", this.showDesc);
break;
case "showRecs":
this.setPreference("minimizeRecommendations", this.showRecs);
break;
case "chkAutoplay":
this.setPreference("autoplay", this.selectedAutoPlay);
break;
case "chkLoop":
this.setPreference("loop", this.selectedAutoLoop);
break;
default:
break;
}
}
}, },
async getVideoData() { async getVideoData() {
await this.fetchVideo() await this.fetchVideo()

View file

@ -2,7 +2,7 @@
/*End of EFY Template - Documentation on how to use it coming soon at https://efy.ooo/ui . Your own css starts bellow*/ /*End of EFY Template - Documentation on how to use it coming soon at https://efy.ooo/ui . Your own css starts bellow*/
/*Base*/ .pp-base {margin: 0 auto; width: 80%;} /*Base*/ .pp-base {margin: 0 auto; width: 80vw;}
/*BG: Transparent*/ .video-grid div div, .pp-show-recs div div {background: transparent} /*BG: Transparent*/ .video-grid div div, .pp-show-recs div div {background: transparent}
/*BG 1*/ .comment, .video-grid div, .pp-show-recs div, .pp-mobile-nav a, .pp-mobile-nav p, .suggestion-selected, .pp-chapters .chapter:not(.pp-chapter-active, .chapter:hover), .pp-chapters [title=chapters] {background: var(--efy_bg1)} /*BG 1*/ .comment, .video-grid div, .pp-show-recs div, .pp-mobile-nav a, .pp-mobile-nav p, .suggestion-selected, .pp-chapters .chapter:not(.pp-chapter-active, .chapter:hover), .pp-chapters [title=chapters] {background: var(--efy_bg1)}
/*Bold*/ .btn {font-weight: bold} /*Bold*/ .btn {font-weight: bold}
@ -89,7 +89,7 @@ tbody:nth-child(odd) {background: var(--efy_bg1)!important; box-shadow: inset 0
table {margin-top: 0} table {margin-top: 0}
/*Chapters*/ .pp-chapters {margin-left: 15rem; max-width: 400rem; gap: 10rem; border-radius: var(--efy_radius)} /*Chapters*/ .pp-chapters {margin-left: 15rem; max-width: 400rem; gap: 10rem; border-radius: var(--efy_radius)}
.pp-chapters .chapter {padding: 10rem; border-radius: var(--efy_radius); border: 1.5rem solid var(--efy_color_border)} .pp-chapters .chapter {width: 100%; padding: 10rem; border-radius: var(--efy_radius); border: 1.5rem solid var(--efy_color_border)}
.pp-chapters [title=chapters] {padding: 5rem 10rem; border-radius: var(--efy_radius); border: 1.5rem solid var(--efy_color_border)} .pp-chapters [title=chapters] {padding: 5rem 10rem; border-radius: var(--efy_radius); border: 1.5rem solid var(--efy_color_border)}
.pp-chapters .chapter .flex {gap: 0 15rem} .pp-chapters .chapter .flex {gap: 0 15rem}