window.setInterval(function(){ refreshUpDownTotal(); refreshList(); }, 5000); $("a[data-torrent-id]").click(function() { var hash = $(this).attr("data-torrent-id"); $.ajax({ type: "POST", url: "share", data: { hash: hash } }) .done(function( msg ) { $.notify( "URL : " + msg); }); }); $(document).ready(function() { $.ajaxSetup({ cache: false }); refreshList(); }); function refreshUpDownTotal() { $.getJSON( "api/get_updown_total", function( data ) { $("#up-info").text(bytesToSize(data["up"], true)); $("#down-info").text(bytesToSize(data["down"], true)); }); } function refreshList(){ $.getJSON( "api/get_list", function ( data ) { $.each( data, function( key, val ) { percent = (val['completed_bytes'] / val['size_bytes']) * 100; if(percent == 100) { space = bytesToSize(val['size_bytes'], false); } else { space = bytesToSize(val['completed_bytes'], false) + ' | ' + bytesToSize(val['size_bytes'], false); } html = '