function showUpload() { $.get( site_url +"home/progresso/"+ idservidor +"/"+ progress_key, function(data) { if (!data) { return; } var response; eval ("response = " + data); if (!response) { return; } percentage = Math.floor(100 * parseInt(response['bytes_uploaded']) / parseInt(response['bytes_total'])); $("#progressbar").progressbar( 'value' , percentage ); if ( response['est_sec'] > 120 ) { tempo = Math.floor( response['est_sec'] / 60 ); $( '#tempo_restante' ).html( tempo +' minutos' ); } else { tempo = Math.floor( response['est_sec'] ); $( '#tempo_restante' ).html( tempo +' segundos' ); } $( '#velocidade' ).html( Math.floor( response['speed_last'] / 1024 ) +' kb/s' ); bytes_uploaded = Math.round( response['bytes_uploaded'] / 1024 / 1024 * 100) / 100; bytes_total = Math.round( response['bytes_total'] / 1024 / 1024 * 100) / 100; if ( response['bytes_total'] > total_permitido ) { alert( 'O arquivo selecionado é muito grande.' ); cancelUpload(); } $( '#tamanho').html( bytes_uploaded +'MB de '+ bytes_total +'MB ( '+ percentage +'% )' ); }); if ( percentage < 99 ) { setTimeout( 'showUpload()' , 1000 ); } } function erroUpload() { alert( 'Houve um erro no upload. Por favor, tente novamente.' ); window.location = site_url; } function cancelUpload() { $( '#cancelar' ).css( 'display' , 'block' ); $( '#conteudo' ).css( 'display' , 'none' ); window.location = site_url; } function homeEnviar() { setTimeout( 'showUpload()', 2000 ); $( '#conteudo' ).css( 'display' , 'block' ); $( '#formulario' ).css( 'display' , 'none' ); return true; }