2022-08-28 14:29:11 +00:00
|
|
|
<template>
|
2022-08-28 17:40:35 +00:00
|
|
|
<ModalComponent>
|
2022-09-08 20:56:24 +00:00
|
|
|
<h2 v-t="'actions.share'" />
|
2022-08-28 17:40:35 +00:00
|
|
|
<div class="flex justify-between">
|
|
|
|
<label v-t="'actions.piped_link'" />
|
2023-07-27 11:46:05 +00:00
|
|
|
<input v-model="pipedLink" type="checkbox" @change="onChange" />
|
2022-08-28 17:40:35 +00:00
|
|
|
</div>
|
2023-07-27 11:46:05 +00:00
|
|
|
<div v-if="hasPlaylist" class="flex justify-between">
|
2022-12-04 23:19:24 +00:00
|
|
|
<label v-t="'actions.with_playlist'" />
|
2023-07-27 11:46:05 +00:00
|
|
|
<input v-model="withPlaylist" type="checkbox" @change="onChange" />
|
2022-12-04 23:19:24 +00:00
|
|
|
</div>
|
2022-12-15 23:26:42 +00:00
|
|
|
<div class="flex justify-between">
|
|
|
|
<label v-t="'actions.with_timecode'" for="withTimeCode" />
|
2023-07-27 11:46:05 +00:00
|
|
|
<input id="withTimeCode" v-model="withTimeCode" type="checkbox" @change="onChange" />
|
2022-12-15 23:26:42 +00:00
|
|
|
</div>
|
2023-08-04 14:19:25 +00:00
|
|
|
<div v-if="withTimeCode" class="flex justify-between mt-2 items-center">
|
2022-08-28 17:40:35 +00:00
|
|
|
<label v-t="'actions.time_code'" />
|
2023-08-04 10:08:08 +00:00
|
|
|
<input v-model="timeStamp" class="input w-12" type="text" @change="onChange" />
|
2022-08-28 17:40:35 +00:00
|
|
|
</div>
|
2022-12-04 23:19:24 +00:00
|
|
|
<a :href="generatedLink" target="_blank">
|
|
|
|
<h3 class="mt-4" v-text="generatedLink" />
|
|
|
|
</a>
|
2023-08-04 14:19:25 +00:00
|
|
|
<QrCode v-if="showQrCode" :text="generatedLink" />
|
2022-08-28 17:40:35 +00:00
|
|
|
<div class="flex justify-end mt-4">
|
2023-08-04 14:19:25 +00:00
|
|
|
<button v-t="'actions.generate_qrcode'" class="btn" @click="showQrCode = !showQrCode" />
|
|
|
|
<button v-t="'actions.follow_link'" class="btn ml-3" @click="followLink()" />
|
2023-07-27 11:46:05 +00:00
|
|
|
<button v-t="'actions.copy_link'" class="btn ml-3" @click="copyLink()" />
|
2022-08-28 17:40:35 +00:00
|
|
|
</div>
|
|
|
|
</ModalComponent>
|
2022-08-28 14:29:11 +00:00
|
|
|
</template>
|
|
|
|
|
2023-08-04 14:19:25 +00:00
|
|
|
<script setup>
|
|
|
|
import { defineAsyncComponent } from "vue";
|
|
|
|
|
|
|
|
const QrCode = defineAsyncComponent(() => import("./QrCode.vue"));
|
|
|
|
</script>
|
|
|
|
|
2022-08-28 14:29:11 +00:00
|
|
|
<script>
|
2022-08-28 17:40:35 +00:00
|
|
|
import ModalComponent from "./ModalComponent.vue";
|
|
|
|
|
2022-08-28 14:29:11 +00:00
|
|
|
export default {
|
2023-07-27 11:46:05 +00:00
|
|
|
components: {
|
|
|
|
ModalComponent,
|
|
|
|
},
|
2022-08-28 14:29:11 +00:00
|
|
|
props: {
|
|
|
|
videoId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
currentTime: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-12-04 23:19:24 +00:00
|
|
|
playlistId: {
|
|
|
|
type: String,
|
2023-07-27 11:46:05 +00:00
|
|
|
default: undefined,
|
2022-12-04 23:19:24 +00:00
|
|
|
},
|
|
|
|
playlistIndex: {
|
|
|
|
type: Number,
|
2023-07-27 11:46:05 +00:00
|
|
|
default: undefined,
|
2022-12-04 23:19:24 +00:00
|
|
|
},
|
2022-08-28 14:29:11 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
withTimeCode: true,
|
|
|
|
pipedLink: true,
|
2022-12-04 23:19:24 +00:00
|
|
|
withPlaylist: true,
|
2022-08-28 14:58:56 +00:00
|
|
|
timeStamp: null,
|
2022-12-04 23:19:24 +00:00
|
|
|
hasPlaylist: false,
|
2023-08-04 10:08:08 +00:00
|
|
|
showQrCode: false,
|
2022-08-28 14:29:11 +00:00
|
|
|
};
|
|
|
|
},
|
2023-07-27 11:46:05 +00:00
|
|
|
computed: {
|
|
|
|
generatedLink() {
|
|
|
|
var baseUrl = this.pipedLink
|
|
|
|
? window.location.origin + "/watch?v=" + this.videoId
|
|
|
|
: "https://youtu.be/" + this.videoId;
|
|
|
|
var url = new URL(baseUrl);
|
|
|
|
if (this.withTimeCode && this.timeStamp > 0) url.searchParams.append("t", this.timeStamp);
|
|
|
|
if (this.hasPlaylist && this.withPlaylist) {
|
|
|
|
url.searchParams.append("list", this.playlistId);
|
|
|
|
url.searchParams.append("index", this.playlistIndex);
|
|
|
|
}
|
|
|
|
return url.href;
|
|
|
|
},
|
|
|
|
},
|
2022-08-28 14:29:11 +00:00
|
|
|
mounted() {
|
2022-08-28 14:58:56 +00:00
|
|
|
this.timeStamp = parseInt(this.currentTime);
|
2022-11-02 12:06:13 +00:00
|
|
|
this.withTimeCode = this.getPreferenceBoolean("shareWithTimeCode", true);
|
|
|
|
this.pipedLink = this.getPreferenceBoolean("shareAsPipedLink", true);
|
2022-12-04 23:19:24 +00:00
|
|
|
this.withPlaylist = this.getPreferenceBoolean("shareWithPlaylist", true);
|
|
|
|
this.hasPlaylist = this.playlistId != undefined && !isNaN(this.playlistIndex);
|
2022-08-28 14:29:11 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
followLink() {
|
2022-08-28 14:35:40 +00:00
|
|
|
window.open(this.generatedLink, "_blank").focus();
|
2022-08-28 14:29:11 +00:00
|
|
|
},
|
2022-08-28 14:35:40 +00:00
|
|
|
async copyLink() {
|
|
|
|
await this.copyURL(this.generatedLink);
|
|
|
|
},
|
|
|
|
async copyURL(mytext) {
|
|
|
|
try {
|
|
|
|
await navigator.clipboard.writeText(mytext);
|
|
|
|
alert(this.$t("info.copied"));
|
|
|
|
} catch ($e) {
|
|
|
|
alert(this.$t("info.cannot_copy"));
|
|
|
|
}
|
2022-08-28 14:29:11 +00:00
|
|
|
},
|
2022-11-02 12:06:13 +00:00
|
|
|
onChange() {
|
2022-11-16 18:51:56 +00:00
|
|
|
this.setPreference("shareWithTimeCode", this.withTimeCode, true);
|
|
|
|
this.setPreference("shareAsPipedLink", this.pipedLink, true);
|
2022-12-04 23:19:24 +00:00
|
|
|
this.setPreference("shareWithPlaylist", this.withPlaylist, true);
|
2022-11-02 12:06:13 +00:00
|
|
|
},
|
2022-08-28 14:29:11 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|