Make timestamps in comments seek instead of reload

This commit is contained in:
Tyrritt 2023-01-18 16:56:21 +01:00
parent 86e9bd069e
commit 95a0e4cbc8
2 changed files with 17 additions and 0 deletions

View File

@ -71,6 +71,7 @@ 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,
@ -79,6 +80,21 @@ 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) {

View File

@ -186,6 +186,7 @@
:comment="comment" :comment="comment"
:uploader="video.uploader" :uploader="video.uploader"
:video-id="getVideoId()" :video-id="getVideoId()"
@seek="navigate"
/> />
</div> </div>