Commit 7791a7c4 by Lyla Fischer Committed by Calen Pennington

slight refactoring of the javascript

parent d35ff48e
......@@ -233,32 +233,35 @@ function showFileSelectionMenu(e) {
function startUpload(e) {
$('.upload-modal h1').html('Uploading…');
$('.upload-modal .file-name').html($('.file-input').val());
var bar = $('.upload-modal .progress-fill');
$('.upload-modal .file-chooser').ajaxSubmit({
beforeSend: function() {
var percentVal = '0%';
bar.width(percentVal)
bar.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
bar.html(percentVal);
},
complete: function(xhr) {
if(xhr.status = 200){
markAsLoaded();
}
bar.html(xhr.responseText);
$('.upload-modal .choose-file-button').html('Load Another File').show();
}
beforeSend: resetUploadBar,
uploadProgress: showUploadFeedback,
complete: displayFinishedUpload
});
$('.upload-modal .choose-file-button').hide();
$('.upload-modal .progress-bar').removeClass('loaded').show();
}
function resetUploadBar(){
var percentVal = '0%';
$('.upload-modal .progress-fill').width(percentVal)
$('.upload-modal .progress-fill').html(percentVal);
}
function showUploadFeedback(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
$('.upload-modal .progress-fill').width(percentVal);
$('.upload-modal .progress-fill').html(percentVal);
}
function displayFinishedUpload(xhr) {
if(xhr.status = 200){
markAsLoaded();
}
$('.upload-modal .progress-fill').html(xhr.responseText);
$('.upload-modal .choose-file-button').html('Load Another File').show();
}
function markAsLoaded() {
$('.upload-modal .copy-button').css('display', 'inline-block');
$('.upload-modal .progress-bar').addClass('loaded');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment