Fixed some issues and added some stuff

This commit is contained in:
RemixDev 2020-04-13 19:22:34 +02:00
parent 68a2bae6bf
commit cc3981bbee
2 changed files with 25 additions and 14 deletions

View File

@ -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){
<i onclick="downloadAction(event)" class="material-icons queue_icon" data-uuid="${queueItem.uuid}">remove</i>
</div>
</div>`)
}
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(`<span class="secondary-text"><span class="download_slim_separator">(</span><span class="queue_failed">1</span> Failed<span class="download_slim_separator">)</span></span>`)
$("#download_"+update.uuid+" .download_info_status").append(`<span class="secondary-text"><span class="download_slim_separator">(</span><span class="queue_failed">1</span> <i class="material-icons">error_outline</i><span class="download_slim_separator">)</span></span>`)
}else{
$("#download_"+update.uuid+" .queue_failed").text(queueList[update.uuid].failed)
}

View File

@ -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"))