mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-12-23 14:03:35 +00:00
Make timestamps in comments seek instead of reload
This commit is contained in:
parent
86e9bd069e
commit
95a0e4cbc8
@ -71,6 +71,7 @@ export default {
|
||||
uploader: { type: String, default: null },
|
||||
videoId: { type: String, default: null },
|
||||
},
|
||||
emits: ["seek"],
|
||||
data() {
|
||||
return {
|
||||
loadingReplies: false,
|
||||
@ -79,6 +80,21 @@ export default {
|
||||
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: {
|
||||
async loadReplies() {
|
||||
if (!this.showingReplies && this.loadingReplies) {
|
||||
|
@ -186,6 +186,7 @@
|
||||
:comment="comment"
|
||||
:uploader="video.uploader"
|
||||
:video-id="getVideoId()"
|
||||
@seek="navigate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user