From 4fafed97a9a1dc32dddbadacda6a3b6def08a4ff Mon Sep 17 00:00:00 2001 From: RemixDev Date: Fri, 10 Apr 2020 23:04:05 +0200 Subject: [PATCH] Added progress bar --- public/css/progressbar.css | 110 +++++++++++++++++++++++++++++++++++++ public/index.html | 3 +- public/js/app.js | 3 +- public/js/downloadList.js | 7 ++- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 public/css/progressbar.css diff --git a/public/css/progressbar.css b/public/css/progressbar.css new file mode 100644 index 0000000..38fb95c --- /dev/null +++ b/public/css/progressbar.css @@ -0,0 +1,110 @@ +.progress { + position: relative; + height: 4px; + display: block; + width: 100%; + background-color: var(--secondary-background); + border-radius: 2px; + margin: 0.5rem 0 1rem 0; + overflow: hidden; +} + +.progress .determinate { + position: absolute; + top: 0; + left: 0; + bottom: 0; + background-color: var(--accent-color); + -webkit-transition: width .3s linear; + transition: width .3s linear; +} + +.progress .indeterminate { + background-color: var(--accent-color); +} + +.progress .indeterminate:before { + content: ''; + position: absolute; + background-color: inherit; + top: 0; + left: 0; + bottom: 0; + will-change: left, right; + -webkit-animation: indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite; + animation: indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite; +} + +.progress .indeterminate:after { + content: ''; + position: absolute; + background-color: inherit; + top: 0; + left: 0; + bottom: 0; + will-change: left, right; + -webkit-animation: indeterminate-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite; + animation: indeterminate-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite; + -webkit-animation-delay: 1.15s; + animation-delay: 1.15s; +} + +@-webkit-keyframes indeterminate { + 0% { + left: -35%; + right: 100%; + } + 60% { + left: 100%; + right: -90%; + } + 100% { + left: 100%; + right: -90%; + } +} + +@keyframes indeterminate { + 0% { + left: -35%; + right: 100%; + } + 60% { + left: 100%; + right: -90%; + } + 100% { + left: 100%; + right: -90%; + } +} + +@-webkit-keyframes indeterminate-short { + 0% { + left: -200%; + right: 100%; + } + 60% { + left: 107%; + right: -8%; + } + 100% { + left: 107%; + right: -8%; + } +} + +@keyframes indeterminate-short { + 0% { + left: -200%; + right: 100%; + } + 60% { + left: 107%; + right: -8%; + } + 100% { + left: 107%; + right: -8%; + } +} diff --git a/public/index.html b/public/index.html index 33dfffd..0698798 100644 --- a/public/index.html +++ b/public/index.html @@ -5,6 +5,7 @@ deemix + @@ -62,7 +63,7 @@

{{ names[section] }}

{{artist.ART_NAME}} {{track.ALB_TITLE}} {{convertDuration(track.DURATION)}} - get_app + get_app diff --git a/public/js/app.js b/public/js/app.js index 5409e83..2234e11 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -114,8 +114,7 @@ var mainSearch = new Vue({ if (section != "TOP_RESULT") clickElement('search_'+section.toLowerCase()+'_tab') }, - addToQueue: function(url){socket.emit("addToQueue", {url: url}) - console.log(url)} + addToQueue: function(url){socket.emit("addToQueue", {url: url})} } }) diff --git a/public/js/downloadList.js b/public/js/downloadList.js index 75ce578..07712f3 100644 --- a/public/js/downloadList.js +++ b/public/js/downloadList.js @@ -16,16 +16,21 @@ socket.on("addedToQueue", function(queueItem){ 0/${queueItem.size} -
+
`) }) +socket.on("startDownload", function(uuid){ + $('#bar_' + uuid).removeClass('indeterminate').addClass('determinate') +}) + socket.on("updateQueue", function(update){ if (update.uuid && queue.indexOf(update.uuid) > -1){ console.log(update) if (update.downloaded){ queueList[update.uuid].downloaded++ $("#download_"+update.uuid+" .queue_downloaded").text(queueList[update.uuid].downloaded) + $('#bar_' + update.uuid).css('width', ((queueList[update.uuid].downloaded + queueList[update.uuid].failed) / queueList[update.uuid].size)*100 + '%') } if (update.failed){ queueList[update.uuid].failed++