});
document.getElementById('save-btn').style.display = 'inline';
+ }
- $('#save-btn').on('click', function(e){
- e.stopPropagation();
- $('#forms_container .inline-form').each(function(i,el){
- console.log("inline form " + i + "el: " + el);
- var name, tags, fpurl, course;
- name = $(el).find('.intext').val();
- fp_file = $(el).find('.fpurl').val();
- tags = $(el).find('.taggit-tags').val();
- course = $(el).find('.course_id').val();
- csrf = $(el).find('.csrf').val();
- mimetype = $(el).find('.mimetype').val();
+ $('#save-btn').on('click', function(e){
+ e.stopPropagation();
+ $('#forms_container .inline-form').each(function(i,el){
+ console.log("inline form " + i + "el: " + el);
+ var name, tags, fpurl, course;
+ name = $(el).find('.intext').val();
+ fp_file = $(el).find('.fpurl').val();
+ tags = $(el).find('.taggit-tags').val();
+ course = $(el).find('.course_id').val();
+ csrf = $(el).find('.csrf').val();
+ mimetype = $(el).find('.mimetype').val();
- $.post('{% url 'upload_post' %}', {
- 'name': name,
- 'fp_file': fp_file,
- 'tags': tags,
- 'course': course,
- 'csrfmiddlewaretoken': csrf,
- 'mimetype': mimetype
- }, function(data){
- if (data === 'success') {
- // For multiple uploads, we may end up clearing and re-
- // writing this multiple times, but show the same list
- // each time.
- $('#uploaded_files').empty();
- for (var i=0; i < uploaded_files.length; i++) {
- $('#uploaded_files').append($('<li>', {text: uploaded_files[i]}));
- }
- $('#success').show();
- document.getElementById('save-btn').style.display = 'none';
- $('#forms_container .inline-form').remove();
- _gat._getTracker()._trackEvent('upload', 'upload form submitted');
- setTimeout(function(){
- location.reload(true);
- }, 15000);
+ $.post('{% url 'upload_post' %}', {
+ 'name': name,
+ 'fp_file': fp_file,
+ 'tags': tags,
+ 'course': course,
+ 'csrfmiddlewaretoken': csrf,
+ 'mimetype': mimetype
+ }, function(data){
+ if (data === 'success') {
+ // For multiple uploads, we may end up clearing and re-
+ // writing this multiple times, but show the same list
+ // each time.
+ $('#uploaded_files').empty();
+ for (var i=0; i < uploaded_files.length; i++) {
+ $('#uploaded_files').append($('<li>', {text: uploaded_files[i]}));
}
- });
- // Add the name we've just uploaded to the list
- uploaded_files.push(name);
- });
+ $('#success').show();
+ document.getElementById('save-btn').style.display = 'none';
+ $('#forms_container .inline-form').remove();
+ _gat._getTracker()._trackEvent('upload', 'upload form submitted');
+ setTimeout(function(){
+ location.reload(true);
+ }, 15000);
+ }
+ });
+ // Add the name we've just uploaded to the list
+ uploaded_files.push(name);
});
-
- };
+ });
var fileup = document.getElementById('filepicker-file-upload');
fileup.onchange = function(event){