brotherton-erpnext/erpnext/public/js/education/lms/components/Video.vue
2019-02-27 15:32:36 +05:30

77 lines
2.3 KiB
Vue

<template>
<div>
<section class='video-top-section video-section-bg'>
<div>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" :src="'https://www.youtube.com/embed/' + videoID" allowfullscreen></iframe>
</div>
<div class="mt-3 row">
<div class="col-md-8">
<h2>{{ contentData.name }}</h2>
<span class="text-muted">
<i class="octicon octicon-clock" title="Duration"></i> {{ contentData.duration }} Mins
&mdash; Published on {{ contentData.publish_date }}.
</span>
</div>
<div class="col-md-4 text-right">
<slot></slot>
</div>
</div>
<hr>
</div>
</section>
<section class="video-description-section">
<div>
<div class="content" :html="contentData.description">
</div>
<div class="text-right hidden">
<a class='btn btn-outline-secondary' href="/classrooms/module">Previous</a>
<a class='btn btn-primary' href="/classrooms/module">Next</a>
</div>
<div class="mt-3 text-right">
<a class="text-muted" href="/report"><i class="octicon octicon-issue-opened" title="Report"></i> Report a
Mistake</a>
</div>
</div>
</section>
</div>
</template>
<script>
export default {
props: ['content', 'type'],
name: 'Video',
data() {
return {
contentData: '',
videoID: '',
}
},
mounted() {
this.getContent()
.then(data => this.contentData = data)
.then((contentData) => this.videoID = this.getVideoID(this.contentData.url))
},
methods: {
getContent() {
return lms.call('get_content', {
type: this.type,
content: this.content
})
},
getVideoID(link) {
if (!Array.prototype.last){
Array.prototype.last = function(){
return this[this.length - 1];
};
};
if (link.includes('v=')){
return link.split('v=')[1].split('&')[0]
}
else if (link.includes('youtu.be')) {
return link.split('/').last().split('?')[0]
}
}
}
};
</script>