2022-08-28 14:29:11 +00:00
|
|
|
<template>
|
|
|
|
<div class="modal">
|
|
|
|
<div>
|
|
|
|
<div class="modal-container">
|
|
|
|
<h2 v-t="'actions.share'" />
|
|
|
|
<div class="flex justify-between mt-4">
|
|
|
|
<label v-t="'actions.with_timecode'" for="withTimeCode" />
|
|
|
|
<input id="withTimeCode" type="checkbox" v-model="withTimeCode" />
|
|
|
|
</div>
|
|
|
|
<div class="flex justify-between">
|
|
|
|
<label v-t="'actions.piped_link'" />
|
|
|
|
<input type="checkbox" v-model="pipedLink" />
|
|
|
|
</div>
|
2022-08-28 14:58:56 +00:00
|
|
|
<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-08-28 14:29:11 +00:00
|
|
|
<h3 class="mt-4" v-text="generatedLink" />
|
|
|
|
<div class="flex justify-end mt-4">
|
|
|
|
<button class="btn" v-t="'actions.follow_link'" @click="followLink()" />
|
2022-08-28 14:35:40 +00:00
|
|
|
<button class="btn ml-3" v-t="'actions.copy_link'" @click="copyLink()" />
|
2022-08-28 14:29:11 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
videoId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
currentTime: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
withTimeCode: true,
|
|
|
|
pipedLink: true,
|
2022-08-28 14:58:56 +00:00
|
|
|
timeStamp: null,
|
2022-08-28 14:29:11 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
window.addEventListener("keydown", this.handleKeyDown);
|
2022-08-28 14:58:56 +00:00
|
|
|
this.timeStamp = parseInt(this.currentTime);
|
2022-08-28 14:29:11 +00:00
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
window.removeEventListener("keydown", this.handleKeyDown);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleKeyDown(event) {
|
|
|
|
if (event.code === "Escape") {
|
|
|
|
this.$emit("close");
|
|
|
|
} else return;
|
|
|
|
event.preventDefault();
|
|
|
|
},
|
|
|
|
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
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
generatedLink() {
|
|
|
|
var href = this.pipedLink
|
|
|
|
? window.location.origin + "/watch?v=" + this.videoId
|
|
|
|
: "https://youtu.be/" + this.videoId;
|
2022-08-28 14:58:56 +00:00
|
|
|
if (this.withTimeCode && this.timeStamp) href += "?t=" + this.timeStamp;
|
2022-08-28 14:29:11 +00:00
|
|
|
return href;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
2022-08-28 14:42:55 +00:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.modal {
|
|
|
|
@apply fixed z-50 top-0 left-0 w-full h-full bg-dark-900 bg-opacity-80 transition-opacity table;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal > div {
|
|
|
|
@apply table-cell align-middle;
|
|
|
|
}
|
|
|
|
|
|
|
|
.modal-container {
|
|
|
|
@apply w-100 m-auto px-8 bg-dark-700 p-5 flex flex-col rounded-xl;
|
|
|
|
}
|
|
|
|
</style>
|