From fc5ae79bf0e0fc2c43b9b748c4d00037077f21a6 Mon Sep 17 00:00:00 2001 From: Wugy Date: Sat, 19 Dec 2009 19:27:42 +0100 Subject: webinterface - activ Downloads List - Code completed --- module/web/templates/default/base.html | 30 +++++++++++++++++++++++++++--- pyLoadCore.py | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/module/web/templates/default/base.html b/module/web/templates/default/base.html index f9ea8c3a2..73846b0d6 100644 --- a/module/web/templates/default/base.html +++ b/module/web/templates/default/base.html @@ -132,8 +132,25 @@ sprintfWrapper = { } } } - sprintf = sprintfWrapper.init; + +//var SetInver = new Array(); + +function HumanFileSize(size) +{ + var filesizename = new Array("KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"); + var loga = Math.log(size)/Math.log(1024); + var i = Math.floor(loga); + var a = Math.pow(1024, i); + return Math.round( size / a , 2) + " " + filesizename[i]; +} + +/*function UpdateLinks( SetInver, index ) +{ + $("#aktiv_percent").text(parseInt($("#aktiv_percent").text)+1) + setTimeout( UpdateLinks( SetInver, index+1 ), SetInver[index]*1000); +}*/ + function LoadJsonToContent(data) { JSONDATA = data; @@ -161,8 +178,15 @@ function LinksToContent(data) $("#LinksAktiv").text(''); $.each(data, function(i,item) { - $("#LinksAktiv").append(''+item.name+''+item.status+''+Math.round(item.speed*100)/100+'@'+SecToRightTime(item.eta)+''+item.size+' MB'+item.percent+'% / '+item.kbleft+' MB'); + $("#LinksAktiv").append(''+item.name+''+item.status+''+Math.round(item.speed*100)/100+'@'+SecToRightTime(item.eta)+''+HumanFileSize(item.size)+''+item.percent+'% / '+HumanFileSize(item.size-item.kbleft)+''); + //SetInver[i] = (item.size / 100 ) / item.speed ; + //window.setInterval( $("#aktiv_percent").text(parseInt($("#aktiv_percent").text)+1), ((item.size / 100 ) / item.speed)*100); }); + //UpdateLinks(SetInver, 0); + setTimeout(function() + { + $.getJSON('/json/links', LinksToContent ); + }, 4000); } function SecToRightTime(sek) @@ -248,7 +272,7 @@ $(document).ready(function(){ {% if perms.pyload.can_see_dl %}
{% endif %} diff --git a/pyLoadCore.py b/pyLoadCore.py index 3e6662d17..1951d6db1 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -351,7 +351,7 @@ class ServerMethods(): download['speed'] = pyfile.status.get_speed() download['eta'] = pyfile.status.get_ETA() download['kbleft'] = pyfile.status.kB_left() - download['size'] = pyfile.status.size() / 1000 + download['size'] = pyfile.status.size() download['percent'] = pyfile.status.percent() download['status'] = pyfile.status.type download['wait_until'] = pyfile.status.waituntil -- cgit v1.2.3