mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Make timestamps in comments seek instead of reload
This commit is contained in:
parent
86e9bd069e
commit
95a0e4cbc8
2 changed files with 17 additions and 0 deletions
|
@ -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) {
|
||||||
|
|
|
@ -186,6 +186,7 @@
|
||||||
:comment="comment"
|
:comment="comment"
|
||||||
:uploader="video.uploader"
|
:uploader="video.uploader"
|
||||||
:video-id="getVideoId()"
|
:video-id="getVideoId()"
|
||||||
|
@seek="navigate"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue