KawAnime/pages/downloader.vue

160 lines
4.3 KiB
Vue
Raw Normal View History

<template lang="pug">
v-container#downloader.container(fluid, fill-height)
.cute-char.left-pic
.cute-char.right-pic
v-layout(row, wrap, justify-center, align-center)
v-flex.form-container(xs8)
v-layout(row, wrap, justify-center)
v-flex(xs9)
v-flex(xs3)
v-switch#magnets-switch(
label='Get Magnets',
color='primary',
2017-09-17 18:55:24 +00:00
v-model='$store.state.config.config.magnets',
dark
)
v-flex.pt-3.pl-5.pr-5(xs7, @keydown.enter='next(1)')
v-text-field#name-input(
name='name-input',
type='text', ref='name',
label='Name of the anime',
v-model='formValues.name',
autofocus,
required,
:rules='nameRules',
dark
)
v-flex.pt-3.pl-5.pr-5(xs7, @keydown.enter='next(2)', @keydown.delete='previous(2)')
v-text-field(
name='from-ep-input',
type='number',
min='0',
label='From episode...',
v-model='formValues.fromEp',
dark
)
v-flex.pt-3.pl-5.pr-5(xs7, @keydown.enter='next(3)', @keydown.delete='previous(3)')
v-text-field(
name='until-ep-input',
type='number',
label='Until episode..',
v-model='formValues.untilEp',
dark
)
v-flex.pt-4(xs12)
v-radio-group(:isMandatory="true", row, v-model="quality")
v-radio.radio.primary--text(label='480p', value='480p')
v-radio.radio.primary--text(label='720p', value='720p')
v-radio.radio.primary--text(label='1080p', value='1080p')
v-flex.pt-4(xs12)
v-layout(justify-center, align-center)
v-flex(xs3)
v-btn#download-btn(
dark, block,
color='secondary',
@click='isDownloadable()',
v-if='!$store.state.downloader.form.loading'
) Download!
2017-10-10 01:51:34 +00:00
v-btn(dark, block, color='secondary', loading, v-else)
2017-04-15 14:16:14 +00:00
</template>
<script>
export default {
2017-05-13 14:38:17 +00:00
data () {
2017-04-15 14:16:14 +00:00
return {
modalText: '',
quality: this.$store.state.config.config.quality,
nameRules: [
() => this.formValues.name.length > 2 || 'Please enter at least 3 characters.'
]
2017-04-15 14:16:14 +00:00
}
},
computed: {
formValues () {
return this.$store.state.downloader.form
2017-04-15 14:16:14 +00:00
}
},
methods: {
isDownloadable () {
this.formValues.name.length > 2
? this.download()
: this.$refs.name.focus()
2017-04-15 14:16:14 +00:00
},
2017-05-13 14:38:17 +00:00
download () {
2017-04-15 14:16:14 +00:00
const quality = this.quality
this.$store.dispatch('downloader/download')
2017-09-20 13:04:27 +00:00
.then(() => {
this.$store.commit('downloader/setQuality', quality)
})
2017-04-15 14:16:14 +00:00
},
2017-05-13 14:38:17 +00:00
next (number) {
switch (number) {
2017-04-15 14:16:14 +00:00
case 1:
document.getElementsByName('from-ep-input')[0].focus()
2017-04-15 14:16:14 +00:00
break
case 2:
document.getElementsByName('until-ep-input')[0].focus()
2017-04-15 14:16:14 +00:00
break
case 3:
2017-05-13 14:38:17 +00:00
document.getElementById('download-btn').click()
document.getElementsByName('name-input')[0].focus()
2017-04-15 14:16:14 +00:00
break
default:
break
}
},
2017-05-13 14:38:17 +00:00
previous (number) {
switch (number) {
2017-04-15 14:16:14 +00:00
case 2:
if (!this.formValues.fromEp) document.getElementsByName('name-input')[0].focus()
2017-04-15 14:16:14 +00:00
break
case 3:
if (!this.formValues.untilEp) document.getElementsByName('from-ep-input')[0].focus()
2017-04-15 14:16:14 +00:00
break
default:
break
}
2017-05-03 18:22:07 +00:00
}
2017-04-15 14:16:14 +00:00
}
}
</script>
2017-10-15 23:58:56 +00:00
<style lang="stylus" scoped>
.container
2017-10-15 23:58:56 +00:00
position relative
height 100%
width 100%
background-image url(~static/images/downloader-back.jpg)
background-size cover
background-repeat no-repeat
2017-07-11 07:44:55 +00:00
2017-05-13 14:38:17 +00:00
.cute-char
2017-10-15 23:58:56 +00:00
position absolute
bottom 0
height 45%
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.right-pic
2017-10-15 23:58:56 +00:00
content url(~static/images/downloader-char-right.png)
right 2%
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.left-pic
2017-10-15 23:58:56 +00:00
content url(~static/images/downloader-char-left.png)
left 2%
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.form-container
2017-10-15 23:58:56 +00:00
background-color rgba(0, 0, 0, 0.4)
width 65%
margin-top 4%
padding-bottom 4%
padding-top 3%
2017-04-15 14:16:14 +00:00
2017-05-13 14:38:17 +00:00
.radio
2017-10-15 23:58:56 +00:00
margin-left 10%
2017-05-13 14:38:17 +00:00
</style>