2018-06-21 22:01:08 +02:00
|
|
|
/*
|
|
|
|
This file is part of FreeTube.
|
|
|
|
|
|
|
|
FreeTube is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
FreeTube is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with FreeTube. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Vue from './js/vue.js';
|
|
|
|
|
|
|
|
const mainHeaderTemplate = require('./templates/mainHeader.html');
|
|
|
|
const aboutTemplate = require('./templates/about.html');
|
2018-06-25 22:04:11 +02:00
|
|
|
const settingsTemplate = require('./templates/settings.html');
|
2018-06-21 22:01:08 +02:00
|
|
|
const videoListTemplate = require('./templates/videoTemplate.html');
|
2018-06-25 22:04:11 +02:00
|
|
|
const playerTemplate = require('./templates/player.html');
|
|
|
|
const channelTemplate = require('./templates/channelView.html');
|
|
|
|
const progressViewTemplate = require('./templates/progressView.html');
|
2018-09-25 20:26:10 +02:00
|
|
|
const playlistViewTemplate = require('./templates/playlistView.html');
|
2018-06-25 22:04:11 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Progress view
|
|
|
|
*
|
|
|
|
* Shows progress bar on bottom of application.
|
|
|
|
*
|
|
|
|
* seen: Toggles visibility of view
|
|
|
|
* progressWidth: sets width of the progress bar
|
|
|
|
*/
|
|
|
|
let progressView = new Vue({
|
|
|
|
el: '#progressView',
|
|
|
|
data: {
|
|
|
|
seen: true,
|
|
|
|
progressWidth: 0
|
|
|
|
},
|
|
|
|
template: progressViewTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let loadingView = new Vue({
|
|
|
|
el: '#loading',
|
|
|
|
data: {
|
|
|
|
seen: false
|
|
|
|
}
|
|
|
|
});
|
2018-06-21 22:01:08 +02:00
|
|
|
|
2018-07-25 05:38:12 +02:00
|
|
|
let noSubscriptions = new Vue({
|
|
|
|
el: '#noSubscriptions',
|
|
|
|
data: {
|
|
|
|
seen: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-21 22:01:08 +02:00
|
|
|
let sideNavBar = new Vue({
|
|
|
|
el: '#sideNav',
|
|
|
|
methods: {
|
|
|
|
subscriptions: (event) => {
|
|
|
|
hideViews();
|
2018-06-25 22:04:11 +02:00
|
|
|
if(subscriptionView.videoList.length === 0){
|
|
|
|
loadingView.seen = true;
|
|
|
|
}
|
2018-06-21 22:01:08 +02:00
|
|
|
headerView.seen = true;
|
|
|
|
headerView.title = 'Latest Subscriptions';
|
|
|
|
subscriptionView.seen = true;
|
|
|
|
loadSubscriptions();
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
popular: (event) => {
|
|
|
|
hideViews();
|
2018-07-25 04:44:09 +02:00
|
|
|
if (loadingView.seen !== false){
|
2018-08-04 03:59:26 +02:00
|
|
|
loadingView.seen = false;
|
2018-07-25 04:44:09 +02:00
|
|
|
}
|
2018-06-25 22:04:11 +02:00
|
|
|
if(popularView.videoList.length === 0){
|
|
|
|
loadingView.seen = true;
|
|
|
|
}
|
|
|
|
headerView.seen = true;
|
|
|
|
headerView.title = 'Most Popular';
|
|
|
|
popularView.seen = true;
|
|
|
|
showMostPopular();
|
|
|
|
},
|
2018-09-21 16:49:23 +02:00
|
|
|
trending: (event) => {
|
|
|
|
hideViews();
|
|
|
|
if (loadingView.seen !== false){
|
|
|
|
loadingView.seen = false;
|
|
|
|
}
|
|
|
|
if(trendingView.videoList.length === 0){
|
|
|
|
loadingView.seen = true;
|
|
|
|
}
|
|
|
|
headerView.seen = true;
|
|
|
|
headerView.title = 'Trending';
|
|
|
|
trendingView.seen = true;
|
|
|
|
showTrending();
|
|
|
|
},
|
2018-06-25 22:04:11 +02:00
|
|
|
saved: (event) => {
|
|
|
|
hideViews();
|
2018-07-25 04:44:09 +02:00
|
|
|
if (loadingView.seen !== false){
|
2018-08-04 03:59:26 +02:00
|
|
|
loadingView.seen = false;
|
2018-07-25 04:44:09 +02:00
|
|
|
}
|
2018-11-09 16:11:25 +01:00
|
|
|
else{
|
2018-06-25 22:04:11 +02:00
|
|
|
loadingView.seen = true;
|
|
|
|
}
|
|
|
|
headerView.seen = true;
|
2018-08-04 03:59:26 +02:00
|
|
|
headerView.title = 'Favorited Videos';
|
2018-06-25 22:04:11 +02:00
|
|
|
savedView.seen = true;
|
|
|
|
showSavedVideos();
|
|
|
|
},
|
|
|
|
history: (event) => {
|
|
|
|
hideViews();
|
2018-07-25 04:44:09 +02:00
|
|
|
if (loadingView.seen !== false){
|
2018-08-04 03:59:26 +02:00
|
|
|
loadingView.seen = false;
|
2018-07-25 04:44:09 +02:00
|
|
|
}
|
2018-11-09 16:11:25 +01:00
|
|
|
else{
|
2018-06-25 22:04:11 +02:00
|
|
|
loadingView.seen = true;
|
|
|
|
}
|
|
|
|
headerView.seen = true;
|
|
|
|
headerView.title = 'Video History';
|
|
|
|
historyView.seen = true;
|
|
|
|
showHistory();
|
|
|
|
},
|
|
|
|
settings: (event) => {
|
|
|
|
hideViews();
|
2018-07-25 04:44:09 +02:00
|
|
|
if (loadingView.seen !== false){
|
2018-08-04 03:59:26 +02:00
|
|
|
loadingView.seen = false;
|
2018-07-25 04:44:09 +02:00
|
|
|
}
|
2018-06-25 22:04:11 +02:00
|
|
|
settingsView.seen = true;
|
|
|
|
updateSettingsView();
|
|
|
|
},
|
|
|
|
about: (event) => {
|
|
|
|
hideViews();
|
2018-07-25 04:44:09 +02:00
|
|
|
if (loadingView.seen !== false){
|
2018-08-04 03:59:26 +02:00
|
|
|
loadingView.seen = false;
|
2018-07-25 04:44:09 +02:00
|
|
|
}
|
2018-06-25 22:04:11 +02:00
|
|
|
aboutView.seen = true;
|
2018-06-21 22:01:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
let headerView = new Vue({
|
|
|
|
el: '#mainHeaderView',
|
|
|
|
data: {
|
|
|
|
seen: true,
|
|
|
|
title: 'Latest Subscriptions'
|
|
|
|
},
|
|
|
|
template: mainHeaderTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let subscriptionView = new Vue({
|
|
|
|
el: '#subscriptionView',
|
|
|
|
data: {
|
|
|
|
seen: true,
|
|
|
|
isSearch: false,
|
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
2018-06-25 22:04:11 +02:00
|
|
|
loadingView.seen = true;
|
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
2019-02-25 16:31:04 +01:00
|
|
|
addSavedVideo(videoId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
2018-11-09 16:11:25 +01:00
|
|
|
},
|
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
2018-06-25 22:04:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let popularView = new Vue({
|
|
|
|
el: '#popularView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
isSearch: false,
|
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
|
|
|
loadingView.seen = true;
|
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
|
|
|
addSavedVideo(videoId);
|
2018-08-03 04:18:08 +02:00
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
2018-11-09 16:11:25 +01:00
|
|
|
},
|
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
2018-06-25 22:04:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
2018-09-21 16:49:23 +02:00
|
|
|
let trendingView = new Vue({
|
|
|
|
el: '#trendingView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
isSearch: false,
|
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
|
|
|
loadingView.seen = true;
|
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
|
|
|
addSavedVideo(videoId);
|
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
2018-11-09 16:11:25 +01:00
|
|
|
},
|
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
2018-09-21 16:49:23 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
2018-06-25 22:04:11 +02:00
|
|
|
let savedView = new Vue({
|
|
|
|
el: '#savedView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
isSearch: false,
|
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
|
|
|
loadingView.seen = true;
|
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
2019-02-25 16:31:04 +01:00
|
|
|
toggleSavedVideo(videoId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
2018-11-09 16:11:25 +01:00
|
|
|
},
|
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
2018-06-25 22:04:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let historyView = new Vue({
|
|
|
|
el: '#historyView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
isSearch: false,
|
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
|
|
|
loadingView.seen = true;
|
2018-06-21 22:01:08 +02:00
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
2018-06-25 22:04:11 +02:00
|
|
|
goToChannel(channelId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
|
|
|
addSavedVideo(videoId);
|
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
2018-11-09 16:11:25 +01:00
|
|
|
},
|
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
2018-06-21 22:01:08 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
2018-09-25 20:26:10 +02:00
|
|
|
let playlistView = new Vue({
|
|
|
|
el: '#playlistView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
2018-09-28 21:48:42 +02:00
|
|
|
playlistId: '',
|
2018-09-25 20:26:10 +02:00
|
|
|
channelName: '',
|
|
|
|
channelId: '',
|
|
|
|
thumbnail: '',
|
|
|
|
title: '',
|
|
|
|
videoCount: '',
|
|
|
|
viewCount: '',
|
|
|
|
description: '',
|
|
|
|
lastUpdated: '',
|
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
|
|
|
loadingView.seen = true;
|
2018-09-28 21:48:42 +02:00
|
|
|
playVideo(videoId, playlistView.playlistId);
|
2018-09-25 20:26:10 +02:00
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
|
|
|
addSavedVideo(videoId);
|
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
2018-11-09 16:11:25 +01:00
|
|
|
},
|
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
2018-09-25 20:26:10 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
template: playlistViewTemplate
|
|
|
|
});
|
|
|
|
|
2018-06-25 22:04:11 +02:00
|
|
|
let aboutView = new Vue({
|
|
|
|
el: '#aboutView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
versionNumber: electron.remote.app.getVersion()
|
|
|
|
},
|
|
|
|
template: aboutTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let settingsView = new Vue({
|
|
|
|
el: '#settingsView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
useTheme: false,
|
|
|
|
useTor: false,
|
2018-09-19 20:34:23 +02:00
|
|
|
apiKey: '',
|
|
|
|
history: true,
|
2018-09-21 16:49:23 +02:00
|
|
|
autoplay: true,
|
|
|
|
subtitles: false,
|
|
|
|
updates: true,
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
template: settingsTemplate
|
|
|
|
});
|
|
|
|
|
2018-06-21 22:01:08 +02:00
|
|
|
let searchView = new Vue({
|
|
|
|
el: '#searchView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
|
|
|
isSearch: true,
|
2018-09-19 17:01:21 +02:00
|
|
|
page: 1,
|
2018-06-21 22:01:08 +02:00
|
|
|
videoList: []
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
play: (videoId) => {
|
2018-06-25 22:04:11 +02:00
|
|
|
loadingView.seen = true;
|
2018-06-21 22:01:08 +02:00
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
2018-06-25 22:04:11 +02:00
|
|
|
goToChannel(channelId);
|
2018-06-21 22:01:08 +02:00
|
|
|
},
|
2018-07-25 04:44:09 +02:00
|
|
|
toggleSave: (videoId) => {
|
|
|
|
addSavedVideo(videoId);
|
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
|
|
|
},
|
2018-09-21 16:49:23 +02:00
|
|
|
nextPage: () => {
|
2018-09-19 17:01:21 +02:00
|
|
|
console.log(searchView.page);
|
|
|
|
search(searchView.page);
|
2018-09-25 20:26:10 +02:00
|
|
|
},
|
|
|
|
playlist: (playlistId) => {
|
|
|
|
showPlaylist(playlistId);
|
|
|
|
},
|
2018-06-21 22:01:08 +02:00
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
2018-06-25 22:04:11 +02:00
|
|
|
let channelView = new Vue({
|
|
|
|
el: '#channelView',
|
2018-06-21 22:01:08 +02:00
|
|
|
data: {
|
|
|
|
seen: false,
|
2018-06-25 22:04:11 +02:00
|
|
|
id: '',
|
|
|
|
name: '',
|
|
|
|
icon: '',
|
|
|
|
baner: '',
|
|
|
|
subCount: '',
|
|
|
|
subButtonText: '',
|
|
|
|
description: ''
|
2018-06-21 22:01:08 +02:00
|
|
|
},
|
2018-06-25 22:04:11 +02:00
|
|
|
methods: {
|
|
|
|
subscription: (channelId) => {
|
|
|
|
toggleSubscription(channelId);
|
2018-07-24 02:15:20 +02:00
|
|
|
},
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
template: channelTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let channelVideosView = new Vue({
|
|
|
|
el: '#channelVideosView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
2018-09-21 16:49:23 +02:00
|
|
|
channelId: '',
|
|
|
|
isSearch: true,
|
|
|
|
page: 2,
|
2018-06-25 22:04:11 +02:00
|
|
|
videoList: []
|
|
|
|
},
|
2018-07-24 02:15:20 +02:00
|
|
|
methods: {
|
2018-06-25 22:04:11 +02:00
|
|
|
play: (videoId) => {
|
|
|
|
loadingView.seen = true;
|
|
|
|
playVideo(videoId);
|
|
|
|
},
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
2018-07-25 04:44:09 +02:00
|
|
|
},
|
|
|
|
toggleSave: (videoId) => {
|
|
|
|
addSavedVideo(videoId);
|
|
|
|
},
|
2018-09-21 16:49:23 +02:00
|
|
|
nextPage: () => {
|
|
|
|
channelNextPage();
|
|
|
|
},
|
2018-07-25 04:44:09 +02:00
|
|
|
copy: (site, videoId) => {
|
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
|
|
|
},
|
2018-11-09 16:11:25 +01:00
|
|
|
history: (videoId) => {
|
|
|
|
removeFromHistory(videoId);
|
|
|
|
}
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
template: videoListTemplate
|
|
|
|
});
|
|
|
|
|
|
|
|
let playerView = new Vue({
|
|
|
|
el: '#playerView',
|
|
|
|
data: {
|
|
|
|
seen: false,
|
2018-09-28 21:48:42 +02:00
|
|
|
playlistSeen: false,
|
2018-09-24 20:19:43 +02:00
|
|
|
firstLoad: true,
|
2018-06-25 22:04:11 +02:00
|
|
|
publishedDate: '',
|
|
|
|
videoUrl: '',
|
|
|
|
videoId: '',
|
|
|
|
channelId: '',
|
|
|
|
channelIcon: '',
|
|
|
|
channelName: '',
|
|
|
|
subscribedText: '',
|
|
|
|
savedText: '',
|
|
|
|
savedIconType: 'far',
|
|
|
|
description: '',
|
|
|
|
videoThumbnail: '',
|
|
|
|
subtitleHtml: '',
|
|
|
|
currentQuality: '',
|
2018-09-24 20:19:43 +02:00
|
|
|
videoAudio: '',
|
|
|
|
validAudio: false,
|
2018-06-25 22:04:11 +02:00
|
|
|
video480p: '',
|
2018-09-21 21:56:59 +02:00
|
|
|
valid480p: false,
|
2018-06-25 22:04:11 +02:00
|
|
|
video720p: '',
|
2018-09-21 21:56:59 +02:00
|
|
|
valid720p: false,
|
2018-06-25 22:04:11 +02:00
|
|
|
embededHtml: '',
|
|
|
|
currentSpeed: 1,
|
|
|
|
videoTitle: '',
|
|
|
|
videoViews: '',
|
|
|
|
likePercentage: 0,
|
|
|
|
videoLikes: 0,
|
|
|
|
videoDislikes: 0,
|
2018-07-24 02:15:20 +02:00
|
|
|
playerSeen: true,
|
2018-09-28 21:48:42 +02:00
|
|
|
playlistTitle: '',
|
|
|
|
playlistChannelName: '',
|
|
|
|
playlistIndex: 1,
|
|
|
|
playlistTotal: 1,
|
|
|
|
playlistLoop: false,
|
|
|
|
playlistShuffle: false,
|
|
|
|
playlistShowList: true,
|
2018-09-25 20:26:10 +02:00
|
|
|
recommendedVideoList: [],
|
|
|
|
playlistVideoList: [],
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
channel: (channelId) => {
|
|
|
|
goToChannel(channelId);
|
|
|
|
},
|
|
|
|
subscription: (videoId) => {
|
|
|
|
toggleSubscription(videoId);
|
|
|
|
},
|
|
|
|
quality: (url, qualityText) => {
|
|
|
|
console.log(url);
|
|
|
|
console.log(qualityText);
|
2018-07-24 02:15:20 +02:00
|
|
|
if(playerView.playerSeen === true){
|
|
|
|
// Update time to new url
|
|
|
|
const currentPlayBackTime = $('.videoPlayer').get(0).currentTime;
|
|
|
|
console.log(currentPlayBackTime);
|
|
|
|
playerView.videoUrl = url;
|
|
|
|
playerView.currentQuality = qualityText;
|
|
|
|
setTimeout(() => {$('.videoPlayer').get(0).currentTime = currentPlayBackTime;}, 100);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
playerView.playerSeen = true;
|
|
|
|
playerView.videoUrl = url;
|
|
|
|
playerView.currentQuality = qualityText;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
embededPlayer: () => {
|
|
|
|
playerView.playerSeen = false;
|
|
|
|
playerView.currentQuality = 'EMBED';
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
copy: (site, videoId) => {
|
2018-07-25 04:44:09 +02:00
|
|
|
const url = 'https://' + site + '/watch?v=' + videoId;
|
2018-06-25 22:04:11 +02:00
|
|
|
clipboard.writeText(url);
|
|
|
|
showToast('URL has been copied to the clipboard');
|
|
|
|
},
|
|
|
|
save: (videoId) => {
|
2019-02-25 16:31:04 +01:00
|
|
|
addSavedVideo(videoId);
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
2018-09-28 21:48:42 +02:00
|
|
|
play: (videoId, playlistId = '') => {
|
2018-06-25 22:04:11 +02:00
|
|
|
loadingView.seen = true;
|
2018-09-28 21:48:42 +02:00
|
|
|
playVideo(videoId, playlistId);
|
2018-09-21 16:49:23 +02:00
|
|
|
},
|
|
|
|
loop: () => {
|
|
|
|
let player = document.getElementById('videoPlayer');
|
|
|
|
|
|
|
|
if (player.loop === false) {
|
|
|
|
player.loop = true;
|
|
|
|
showToast('Video loop has been turned on.');
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
player.loop = false;
|
|
|
|
showToast('Video loop has been turned off.')
|
|
|
|
}
|
2018-09-25 20:26:10 +02:00
|
|
|
},
|
|
|
|
playlist: (playlistId) => {
|
|
|
|
showPlaylist(playlistId);
|
|
|
|
},
|
2018-09-28 21:48:42 +02:00
|
|
|
playlistLoopToggle: () => {
|
|
|
|
if (playerView.playlistLoop !== false) {
|
|
|
|
showToast('Playlist will no longer loop');
|
|
|
|
playerView.playlistLoop = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
showToast('Playlist will now loop');
|
|
|
|
playerView.playlistLoop = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
playlistShuffleToggle: () => {
|
|
|
|
if (playerView.playlistShuffle !== false) {
|
|
|
|
showToast('Playlist will no longer shuffle');
|
|
|
|
playerView.playlistShuffle = false;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
showToast('Playlist will now shuffle');
|
|
|
|
playerView.playlistShuffle = true;
|
|
|
|
}
|
|
|
|
},
|
2018-06-25 22:04:11 +02:00
|
|
|
},
|
|
|
|
template: playerTemplate
|
2018-06-21 22:01:08 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
function hideViews(){
|
|
|
|
subscriptionView.seen = false;
|
2018-07-25 05:38:12 +02:00
|
|
|
noSubscriptions.seen = false;
|
2018-06-21 22:01:08 +02:00
|
|
|
aboutView.seen = false;
|
|
|
|
headerView.seen = false;
|
|
|
|
searchView.seen = false;
|
2018-06-25 22:04:11 +02:00
|
|
|
settingsView.seen = false;
|
|
|
|
popularView.seen = false;
|
2018-09-21 16:49:23 +02:00
|
|
|
trendingView.seen = false;
|
2018-06-25 22:04:11 +02:00
|
|
|
savedView.seen = false;
|
|
|
|
historyView.seen = false;
|
2018-09-25 20:26:10 +02:00
|
|
|
playlistView.seen = false;
|
2018-06-25 22:04:11 +02:00
|
|
|
playerView.seen = false;
|
|
|
|
channelView.seen = false;
|
|
|
|
channelVideosView.seen = false;
|
2018-06-21 22:01:08 +02:00
|
|
|
}
|