From cc3981bbeeebebe17e8f3d085869daf5bb609581 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Mon, 13 Apr 2020 19:22:34 +0200 Subject: [PATCH] Fixed some issues and added some stuff --- public/js/downloadList.js | 27 +++++++++++++++++++++++++-- public/js/init.js | 12 ------------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/public/js/downloadList.js b/public/js/downloadList.js index 4f63a2d..5d52b73 100644 --- a/public/js/downloadList.js +++ b/public/js/downloadList.js @@ -1,7 +1,13 @@ var queueList = {} var queue = [] -socket.on("addedToQueue", function(queueItem){ +socket.on("init_downloadQueue", function(data){ + data['queue'].forEach(item=>{ + addToQueue(data['queueList'][item]) + }) +}) + +function addToQueue(queueItem){ queueList[queueItem.uuid] = queueItem queue.push(queueItem.uuid) $("#download_list").append( @@ -21,6 +27,10 @@ socket.on("addedToQueue", function(queueItem){ remove `) +} + +socket.on("addedToQueue", function(queueItem){ + addToQueue(queueItem) }) function downloadAction(evt){ @@ -51,6 +61,19 @@ socket.on("finishDownload", function(uuid){ console.log(uuid+" finished downloading") toast(`${queueList[uuid].title} finished downloading.`) $('#bar_' + uuid).css('width', '100%') + let result_icon = $('download_'+uuid).find('.queue_icon') + if (queueList[uuid].failed == 0){ + result_icon.text("done") + }else if (queueList[uuid].failed >= queueList[uuid].size){ + result_icon.text("error") + }else{ + result_icon.text("warning") + } + let index = queue.indexOf(uuid) + if (index > -1){ + queue.splice(index, 1) + delete queueList[uuid] + } }) socket.on("removedAllDownloads", function(){ @@ -69,7 +92,7 @@ socket.on("updateQueue", function(update){ if (update.failed){ queueList[update.uuid].failed++ if (queueList[update.uuid].failed == 1){ - $("#download_"+update.uuid+" .download_info_status").append(`(1 Failed)`) + $("#download_"+update.uuid+" .download_info_status").append(`(1 error_outline)`) }else{ $("#download_"+update.uuid+" .queue_failed").text(queueList[update.uuid].failed) } diff --git a/public/js/init.js b/public/js/init.js index 9f0c5aa..03a43c9 100644 --- a/public/js/init.js +++ b/public/js/init.js @@ -6,17 +6,6 @@ search_selected = "" main_selected="" // toasts stuff toastsWithId = {} -// track previews stuff -let preview_track = document.getElementById('preview-track') -let preview_stopped = true -let preview_max_volume; - -preview_track.volume = 0 -preview_max_volume = parseFloat(localStorage.getItem("previewVolume")) -if (preview_max_volume === null){ - preview_max_volume = 0.8 - localStorage.setItem("previewVolume", preview_max_volume) -} function toast(msg, icon=null, dismiss=true, id=null){ if (toastsWithId[id]){ @@ -71,7 +60,6 @@ window.addEventListener('pywebviewready', function() { }) $(function(){ - socket.emit("init"); if (localStorage.getItem("arl")){ socket.emit("login", localStorage.getItem("arl")); $("#login_input_arl").val(localStorage.getItem("arl"))