Add ability to paste YouTube links into the search bar to go directly to them
This commit is contained in:
parent
138f4b90f4
commit
2b476f4dc6
|
@ -59,6 +59,14 @@ export default Vue.extend({
|
||||||
searchContainer.style.display = 'none'
|
searchContainer.style.display = 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$store.dispatch('getVideoIdFromUrl', query).then((result) => {
|
||||||
|
if (result) {
|
||||||
|
this.$router.push(
|
||||||
|
{
|
||||||
|
path: `/watch/${result}`,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
router.push(
|
router.push(
|
||||||
{
|
{
|
||||||
path: `/search/${query}`,
|
path: `/search/${query}`,
|
||||||
|
@ -70,6 +78,8 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.showFilters = false
|
this.showFilters = false
|
||||||
},
|
},
|
||||||
|
|
|
@ -220,9 +220,6 @@ export default Vue.extend({
|
||||||
|
|
||||||
onScroll: function (event) {
|
onScroll: function (event) {
|
||||||
const liveChatComments = $('.liveChatComments').get(0)
|
const liveChatComments = $('.liveChatComments').get(0)
|
||||||
const scrollTop = liveChatComments.scrollTop
|
|
||||||
const scrollHeight = liveChatComments.scrollHeight
|
|
||||||
const clientHeight = liveChatComments.clientHeight
|
|
||||||
if (event.wheelDelta >= 0 && this.stayAtBottom) {
|
if (event.wheelDelta >= 0 && this.stayAtBottom) {
|
||||||
$('.liveChatComments').data('animating', 0)
|
$('.liveChatComments').data('animating', 0)
|
||||||
this.stayAtBottom = false
|
this.stayAtBottom = false
|
||||||
|
|
|
@ -51,6 +51,20 @@ const actions = {
|
||||||
getRandomColorClass () {
|
getRandomColorClass () {
|
||||||
const randomInt = Math.floor(Math.random() * state.colorClasses.length)
|
const randomInt = Math.floor(Math.random() * state.colorClasses.length)
|
||||||
return state.colorClasses[randomInt]
|
return state.colorClasses[randomInt]
|
||||||
|
},
|
||||||
|
|
||||||
|
getVideoIdFromUrl ({ state }, url) {
|
||||||
|
console.log('checking for id')
|
||||||
|
console.log(url)
|
||||||
|
const rx = /^.*(?:(?:(you|hook)tu\.?be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/
|
||||||
|
|
||||||
|
const match = url.match(rx)
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
return match[2]
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue