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,17 +59,27 @@ export default Vue.extend({
|
||||||
searchContainer.style.display = 'none'
|
searchContainer.style.display = 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
router.push(
|
this.$store.dispatch('getVideoIdFromUrl', query).then((result) => {
|
||||||
{
|
if (result) {
|
||||||
path: `/search/${query}`,
|
this.$router.push(
|
||||||
query: {
|
{
|
||||||
sortBy: this.searchSettings.sortBy,
|
path: `/watch/${result}`,
|
||||||
time: this.searchSettings.time,
|
}
|
||||||
type: this.searchSettings.type,
|
)
|
||||||
duration: this.searchSettings.duration
|
} else {
|
||||||
}
|
router.push(
|
||||||
|
{
|
||||||
|
path: `/search/${query}`,
|
||||||
|
query: {
|
||||||
|
sortBy: this.searchSettings.sortBy,
|
||||||
|
time: this.searchSettings.time,
|
||||||
|
type: this.searchSettings.type,
|
||||||
|
duration: this.searchSettings.duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
|
|
||||||
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