2022-08-28 19:59:11 +05:30
|
|
|
<template>
|
2022-08-28 23:10:35 +05:30
|
|
|
<ModalComponent>
|
2022-09-09 02:26:24 +05:30
|
|
|
<h2 v-t="'actions.share'" />
|
2022-08-28 23:10:35 +05:30
|
|
|
<div class="flex justify-between mt-4">
|
|
|
|
<label v-t="'actions.with_timecode'" for="withTimeCode" />
|
2022-11-02 17:36:13 +05:30
|
|
|
<input id="withTimeCode" type="checkbox" v-model="withTimeCode" @change="onChange" />
|
2022-08-28 19:59:11 +05:30
|
|
|
</div>
|
2022-08-28 23:10:35 +05:30
|
|
|
<div class="flex justify-between">
|
|
|
|
<label v-t="'actions.piped_link'" />
|
2022-11-02 17:36:13 +05:30
|
|
|
<input type="checkbox" v-model="pipedLink" @change="onChange" />
|
2022-08-28 23:10:35 +05:30
|
|
|
</div>
|
2022-12-05 04:49:24 +05:30
|
|
|
<div v-if="this.hasPlaylist" class="flex justify-between">
|
|
|
|
<label v-t="'actions.with_playlist'" />
|
|
|
|
<input type="checkbox" v-model="withPlaylist" @change="onChange" />
|
|
|
|
</div>
|
2022-08-28 23:10:35 +05:30
|
|
|
<div class="flex justify-between mt-2">
|
|
|
|
<label v-t="'actions.time_code'" />
|
|
|
|
<input class="input w-12" type="text" v-model="timeStamp" />
|
|
|
|
</div>
|
2022-12-05 04:49:24 +05:30
|
|
|
<a :href="generatedLink" target="_blank">
|
|
|
|
<h3 class="mt-4" v-text="generatedLink" />
|
|
|
|
</a>
|
2022-08-28 23:10:35 +05:30
|
|
|
<div class="flex justify-end mt-4">
|
|
|
|
<button class="btn" v-t="'actions.follow_link'" @click="followLink()" />
|
|
|
|
<button class="btn ml-3" v-t="'actions.copy_link'" @click="copyLink()" />
|
|
|
|
</div>
|
|
|
|
</ModalComponent>
|
2022-08-28 19:59:11 +05:30
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-08-28 23:10:35 +05:30
|
|
|
import ModalComponent from "./ModalComponent.vue";
|
|
|
|
|
2022-08-28 19:59:11 +05:30
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
videoId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
currentTime: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-12-05 04:49:24 +05:30
|
|
|
playlistId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
playlistIndex: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-08-28 19:59:11 +05:30
|
|
|
},
|
2022-08-28 23:10:35 +05:30
|
|
|
components: {
|
|
|
|
ModalComponent,
|
|
|
|
},
|
2022-08-28 19:59:11 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
withTimeCode: true,
|
|
|
|
pipedLink: true,
|
2022-12-05 04:49:24 +05:30
|
|
|
withPlaylist: true,
|
2022-08-28 20:28:56 +05:30
|
|
|
timeStamp: null,
|
2022-12-05 04:49:24 +05:30
|
|
|
hasPlaylist: false,
|
2022-08-28 19:59:11 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-08-28 20:28:56 +05:30
|
|
|
this.timeStamp = parseInt(this.currentTime);
|
2022-11-02 17:36:13 +05:30
|
|
|
this.withTimeCode = this.getPreferenceBoolean("shareWithTimeCode", true);
|
|
|
|
this.pipedLink = this.getPreferenceBoolean("shareAsPipedLink", true);
|
2022-12-05 04:49:24 +05:30
|
|
|
this.withPlaylist = this.getPreferenceBoolean("shareWithPlaylist", true);
|
|
|
|
this.hasPlaylist = this.playlistId != undefined && !isNaN(this.playlistIndex);
|
2022-08-28 19:59:11 +05:30
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
followLink() {
|
2022-08-28 20:05:40 +05:30
|
|
|
window.open(this.generatedLink, "_blank").focus();
|
2022-08-28 19:59:11 +05:30
|
|
|
},
|
2022-08-28 20:05:40 +05:30
|
|
|
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 19:59:11 +05:30
|
|
|
},
|
2022-11-02 17:36:13 +05:30
|
|
|
onChange() {
|
2022-11-17 00:21:56 +05:30
|
|
|
this.setPreference("shareWithTimeCode", this.withTimeCode, true);
|
|
|
|
this.setPreference("shareAsPipedLink", this.pipedLink, true);
|
2022-12-05 04:49:24 +05:30
|
|
|
this.setPreference("shareWithPlaylist", this.withPlaylist, true);
|
2022-11-02 17:36:13 +05:30
|
|
|
},
|
2022-08-28 19:59:11 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
generatedLink() {
|
2022-09-02 19:07:14 +05:30
|
|
|
var baseUrl = this.pipedLink
|
2022-08-28 19:59:11 +05:30
|
|
|
? window.location.origin + "/watch?v=" + this.videoId
|
|
|
|
: "https://youtu.be/" + this.videoId;
|
2022-09-02 19:07:14 +05:30
|
|
|
var url = new URL(baseUrl);
|
|
|
|
if (this.withTimeCode && this.timeStamp > 0) url.searchParams.append("t", this.timeStamp);
|
2022-12-05 04:49:24 +05:30
|
|
|
if (this.hasPlaylist && this.withPlaylist) {
|
|
|
|
url.searchParams.append("list", this.playlistId);
|
|
|
|
url.searchParams.append("index", this.playlistIndex);
|
|
|
|
}
|
2022-09-02 19:07:14 +05:30
|
|
|
return url.href;
|
2022-08-28 19:59:11 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|