diff --git a/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.css b/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.css new file mode 100644 index 00000000..e69de29b diff --git a/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.js b/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.js new file mode 100644 index 00000000..b66b234e --- /dev/null +++ b/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.js @@ -0,0 +1,26 @@ +import Vue from 'vue' + +export default Vue.extend({ + name: 'FtTimestampCatcher', + props: { + inputHTML: { + type: String, + default: '' + } + }, + methods: { + catchTimestampClick: function(event) { + const match = event.detail.match(/(\d+):(\d+):?(\d+)?/) + if (match[3] !== undefined) { // HH:MM:SS + const seconds = 3600 * Number(match[1]) + 60 * Number(match[2]) + Number(match[3]) + this.$emit('timestampEvent', seconds) + } else { // MM:SS + const seconds = 60 * Number(match[1]) + Number(match[2]) + this.$emit('timestampEvent', seconds) + } + }, + detectTimestamps: function (input) { + return input.replaceAll(/(\d+(:\d+)+)/g, '$1') + } + } +}) diff --git a/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.vue b/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.vue new file mode 100644 index 00000000..034da7c8 --- /dev/null +++ b/src/renderer/components/ft-timestamp-catcher/ft-timestamp-catcher.vue @@ -0,0 +1,9 @@ + + + + + + diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.js b/src/renderer/components/watch-video-comments/watch-video-comments.js index 29c4659f..01c05386 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.js +++ b/src/renderer/components/watch-video-comments/watch-video-comments.js @@ -3,12 +3,14 @@ import { mapActions } from 'vuex' import FtCard from '../ft-card/ft-card.vue' import FtLoader from '../../components/ft-loader/ft-loader.vue' import CommentScraper from 'yt-comment-scraper' +import FtTimestampCatcher from '../../components/ft-timestamp-catcher/ft-timestamp-catcher.vue' export default Vue.extend({ name: 'WatchVideoComments', components: { 'ft-card': FtCard, - 'ft-loader': FtLoader + 'ft-loader': FtLoader, + 'ft-timestamp-catcher': FtTimestampCatcher }, props: { id: { @@ -39,6 +41,10 @@ export default Vue.extend({ } }, methods: { + onTimestamp: function(timestamp) { + this.$emit('timestampEvent', timestamp) + }, + getCommentData: function () { this.isLoading = true switch (this.backendPreference) { diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.vue b/src/renderer/components/watch-video-comments/watch-video-comments.vue index 5a573f2a..e7881256 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.vue +++ b/src/renderer/components/watch-video-comments/watch-video-comments.vue @@ -46,9 +46,11 @@ {{ comment.time }}
-- {{ comment.text }} -
+