|
@@ -3,8 +3,6 @@ window.setInterval(function(){
|
|
|
refreshList();
|
|
|
}, 5000);
|
|
|
|
|
|
-$(document).ready(function() {
|
|
|
- $.ajaxSetup({ cache: false });
|
|
|
$("a[data-torrent-id]").click(function() {
|
|
|
var hash = $(this).attr("data-torrent-id");
|
|
|
$.ajax({
|
|
@@ -17,16 +15,15 @@ $(document).ready(function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- $("td[data-torrent-percent]").css({
|
|
|
- "background": "linear-gradient(to right, #43ac6a 100%, #f9f9f9 100%, #f9f9f9)"
|
|
|
- });
|
|
|
-
|
|
|
+$(document).ready(function() {
|
|
|
+ $.ajaxSetup({ cache: false });
|
|
|
+ refreshList();
|
|
|
});
|
|
|
|
|
|
function refreshUpDownTotal() {
|
|
|
$.getJSON( "api/get_updown_total", function( data ) {
|
|
|
- $("#up-info").text( data["up"] + " ko/s" );
|
|
|
- $("#down-info").text( data["down"] + " ko/s" );
|
|
|
+ $("#up-info").text(bytesToSize(data["up"], true));
|
|
|
+ $("#down-info").text(bytesToSize(data["down"], true));
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -35,19 +32,33 @@ function refreshList(){
|
|
|
$.getJSON( "api/get_list", function ( data ) {
|
|
|
$.each( data, function( key, val ) {
|
|
|
percent = (val['completed_bytes'] / val['size_bytes']) * 100;
|
|
|
- html = '<td style="background: linear-gradient(to right, #43ac6a ' + percent + '%, #f9f9f9 ' + percent + '%, #f9f9f9)"><h5>' + val['name'] + '</h5></td>';
|
|
|
- html += '<td class="text-center">' + (val['ratio'] / 100) + '</td>';
|
|
|
- html += '<td class="text-center">' + bytesToSize(val['up']) + '</td>';
|
|
|
- html += '<td class="text-center">' + bytesToSize(val['down']) + '</td>';
|
|
|
+ if(percent == 100) {
|
|
|
+ space = bytesToSize(val['size_bytes'], false);
|
|
|
+ } else {
|
|
|
+ space = bytesToSize(val['completed_bytes'], false) + ' | ' + bytesToSize(val['size_bytes'], false);
|
|
|
+ }
|
|
|
+ html = '<td style="background: linear-gradient(to right, #43ac6a ' + percent + '%, #f9f9f9 ' + percent + '%, #f9f9f9)">'
|
|
|
+ html += val['name'];
|
|
|
+ html += '<span class="secondary round label right">' + space + '<span>';
|
|
|
+ html += '</td>';
|
|
|
+ html += '<td class="text-center">' + (val['ratio'] / 1000) + '</td>';
|
|
|
+ html += '<td class="text-center">' + bytesToSize(val['up'], true) + '</td>';
|
|
|
+ html += '<td class="text-center">' + bytesToSize(val['down'], true) + '</td>';
|
|
|
html += '<td class="text-center"><a href="#" data-torrent-id="' + val['hash'].substr(0,10) + '">SHARE</a></td>';
|
|
|
$("tr[data-torrent-id='" + val['hash'] + "']").html(html);
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-function bytesToSize(bytes) {
|
|
|
- var sizes = ['o/s', 'ko/s', 'mo/s', 'go/s', 'to/s'];
|
|
|
- if (bytes == 0) return '0 o/s';
|
|
|
- var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
|
- return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
|
|
|
+function bytesToSize(bytes, speed) {
|
|
|
+ var sizes = ['o', 'Ko', 'Mo', 'Go', 'To'];
|
|
|
+ var speeds = ['o/s', 'Ko/s', 'Mo/s'];
|
|
|
+ if (bytes == 0) return '-';
|
|
|
+ var i = parseFloat(Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
|
+ if(speed) {
|
|
|
+ return Math.round(bytes / Math.pow(1024, i) * 10) / 10 + ' ' + speeds[i];
|
|
|
+ } else {
|
|
|
+ return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
|
|
|
+ }
|
|
|
};
|