Skip to content

Commit

Permalink
optimize the organization of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanyingfeiyu committed Nov 14, 2017
1 parent a35b915 commit 8f86b9e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions youtube_dl_webui/static/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var videoDownload = (function (Vue, extendAM){
modalData: {
add: { url: '', ydl_opts: {} },
remove: { removeFile: false },
preference: {youtube_dl: {}, general: {}},
preference: {youtube_dl: {fomart: '', proxy: ''}, general: {download_dir: '', db_path: '', log_size: ''}},
},
currentSelected: null,
taskDetails: {},
Expand All @@ -28,11 +28,8 @@ var videoDownload = (function (Vue, extendAM){
closeBtn: false
};

videoDownload.updateVm = function(res) {
videoDownload.createVm = function(res) {
var that = videoDownload;
if(that.vm){
return false;
}
that.vm = new Vue({
el: '#videoWrapper',
data: that.tasksData,
Expand All @@ -47,6 +44,7 @@ var videoDownload = (function (Vue, extendAM){
},
mounted: function () {
this.resetOptions();
setInterval(videoDownload.timeOut, 3000);
},
methods: {
showAddTaskModal: function(){
Expand Down Expand Up @@ -282,7 +280,6 @@ var videoDownload = (function (Vue, extendAM){
that.tasksData.stateCounter.finished +
that.tasksData.stateCounter.paused +
that.tasksData.stateCounter.invalid;
that.updateVm();
}, function(err){
that.vm.showAlertToast('Network connection lost', 'error');
});
Expand All @@ -291,14 +288,14 @@ var videoDownload = (function (Vue, extendAM){
videoDownload.timeOut = function(){
var that = videoDownload;
that.getTaskList();
that.vm && that.vm.getTaskInfoById();
that.vm.getTaskInfoById();
};

videoDownload.init = function(){
var that = this;
that.tasksData.headPath = window.location.protocol + '//' + window.location.host + '/';
that.createVm();
that.getTaskList();
setInterval(videoDownload.timeOut, 3000);
}

return videoDownload;
Expand Down

0 comments on commit 8f86b9e

Please sign in to comment.