var s3_queueChangeHandler = function(s3_swf, queue) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); var list = obj.find('.file_todo_list'); var queueBytesTotal = 0; var queueFiles = obj.data('queueFiles') || 0; // Go through the queue, find anything that doesn't exist in the list, and add it to list // Also add up the queueBytesTotal for(x = 0; x < queue.files.length; x++) { queueBytesTotal = queueBytesTotal + queue.files[x].size; var one_file = list.find("li[data-name='" + queue.files[x].name + "']"); if(one_file.length == 0) { s3_addFileToTodoList(s3_swf, queue.files[x].name, queue.files[x].size, x); } } //Go through the list, find anything that doesn't exist in the queue, and remove it $('li.file_to_upload', list).each(function(i, el) { var name_to_find = $(el).data('name'); var found_it = false; for(x = 0; x < queue.files.length; x++) { if(queue.files[x].name == name_to_find) { found_it = true; break; } } if(found_it == false) $(el).remove(); }); obj.find('.file_done_list').find('li').show(); if(queue.files.length > queueFiles) obj.data('queueBytesTotal', queueBytesTotal); obj.data('queueFiles', queue.files.length); }; var s3_uploadingStartHandler = function(s3_swf) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); obj.data('queueBytesFinished', 0); var queueBytesTotal = obj.data('queueBytesTotal'); obj.find('.queue_size').find('.numerator').text("0 bytes / "); obj.find('.queue_size').find('.denominator').text(s3_readableBytes(queueBytesTotal)); }; var s3_uploadingFinishHandler = function(s3_swf) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); obj.find('.overall').find('.progress').css('width', '100%'); obj.find('.overall').find('.amount').text('100%'); }; var s3_progressHandler = function(s3_swf, progress_event) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); var current_percentage = Math.floor((parseInt(progress_event.bytesLoaded)/parseInt(progress_event.bytesTotal))*100)+'%'; var first_file = obj.find('.file_todo_list').find('li.file_to_upload').first(); first_file.find('.delete').hide(); first_file.find('.progress').css('display','block').css('width', current_percentage); first_file.find('.progress').find('.amount').text(current_percentage); var queueBytesFinished = parseInt(obj.data('queueBytesFinished')); var queueBytesTotal = parseInt(obj.data('queueBytesTotal')); var overall_percentage = Math.floor(((queueBytesFinished+parseInt(progress_event.bytesLoaded))/queueBytesTotal)*100)+'%'; // Overall obj.find('.overall').find('.progress').css('width', overall_percentage).show(); obj.find('.overall').find('.amount').text(overall_percentage); obj.find('.queue_size').find('.numerator').text(s3_readableBytes(queueBytesFinished+parseInt(progress_event.bytesLoaded)) + " / "); }; var s3_queueClearHandler = function(s3_swf, queue) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); var overall = obj.find('div.overall'); overall.find('span.progress').css('width', '0%').hide(); overall.find('span.amount').html('0%'); obj.find('.file_done_list').children().remove(); obj.find('.file_todo_list').children().remove(); obj.find('.queue_size').find('.numerator').text(''); obj.find('.queue_size').find('.denominator').text(''); }; var s3_addFileToDoneList = function(s3_swf, file_name, file_size) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); var queueBytesFinished = parseInt(obj.data('queueBytesFinished')); queueBytesFinished = queueBytesFinished + parseInt(file_size); obj.data('queueBytesFinished', queueBytesFinished); var one_file = $( '
' ); obj.find('.file_done_list').first().append(one_file); }; var s3_addFileToTodoList = function(s3_swf, file_name, file_size, index) { var obj = $("div.asset_box_input[data-swf='" + s3_swf + "']").find('div.asset_box_uploader').first(); var one_file = $( '