mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-23 05:57:21 +00:00
Add only one listener on the window
This commit is contained in:
parent
95a0e4cbc8
commit
8311888501
@ -71,7 +71,6 @@ export default {
|
|||||||
uploader: { type: String, default: null },
|
uploader: { type: String, default: null },
|
||||||
videoId: { type: String, default: null },
|
videoId: { type: String, default: null },
|
||||||
},
|
},
|
||||||
emits: ["seek"],
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loadingReplies: false,
|
loadingReplies: false,
|
||||||
@ -80,21 +79,6 @@ export default {
|
|||||||
nextpage: null,
|
nextpage: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
const thisComment = this;
|
|
||||||
this.$el.querySelectorAll("a").forEach(elem => {
|
|
||||||
if (elem.innerText.match(/(?:[\d]{1,2}:)?(?:[\d]{1,2}):(?:[\d]{1,2})/)) {
|
|
||||||
elem.addEventListener("click", function (event) {
|
|
||||||
if (!event || !event.target) return;
|
|
||||||
if (!event.target.getAttribute("href").match(/(?<=t=)\d{1,}/)) return;
|
|
||||||
|
|
||||||
const time = parseInt(event.target.getAttribute("href").match(/(?<=t=)\d{1,}/)[0]);
|
|
||||||
thisComment.$emit("seek", time);
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
async loadReplies() {
|
async loadReplies() {
|
||||||
if (!this.showingReplies && this.loadingReplies) {
|
if (!this.showingReplies && this.loadingReplies) {
|
||||||
|
@ -186,7 +186,6 @@
|
|||||||
:comment="comment"
|
:comment="comment"
|
||||||
:uploader="video.uploader"
|
:uploader="video.uploader"
|
||||||
:video-id="getVideoId()"
|
:video-id="getVideoId()"
|
||||||
@seek="navigate"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -337,6 +336,19 @@ export default {
|
|||||||
this.getPlaylistData();
|
this.getPlaylistData();
|
||||||
this.getSponsors();
|
this.getSponsors();
|
||||||
if (!this.isEmbed && this.showComments) this.getComments();
|
if (!this.isEmbed && this.showComments) this.getComments();
|
||||||
|
window.addEventListener("click", event => {
|
||||||
|
if (!event || !event.target) return;
|
||||||
|
var target = event.target;
|
||||||
|
if (
|
||||||
|
!target.nodeName == "A" ||
|
||||||
|
!target.getAttribute("href") ||
|
||||||
|
!target.innerText.match(/(?:[\d]{1,2}:)?(?:[\d]{1,2}):(?:[\d]{1,2})/)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
const time = parseInt(event.target.getAttribute("href").match(/(?<=t=)\d+/)[0]);
|
||||||
|
this.navigate(time);
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener("resize", () => {
|
||||||
this.smallView = this.smallViewQuery.matches;
|
this.smallView = this.smallViewQuery.matches;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user