1 var dropZone
= document
.getElementById('drop-zone');
2 dropZone
.ondrop = function (e
) {
4 this.className
= 'upload-drop-zone';
5 create(e
.dataTransfer
.files
, true);
8 dropZone
.ondragover = function () {
9 this.className
= 'upload-drop-zone drop';
13 dropZone
.ondragleave = function () {
14 this.className
= 'upload-drop-zone';
19 function create(fs
, dropzone
) {
20 var id
= $('.nav-tabs .active').attr('id');
21 if (dropzone
) id
= 'file_li';
23 var data
= new FormData();
29 var files
= dropzone
? fs
: document
.getElementById('js-upload-files').files
;
30 if (!files
|| !files
.length
) {
31 files
= document
.getElementById('drop-zone').files
;
32 if (!files
|| !files
.length
) {
33 alert("Select a file");
38 var patt1
= /\.([0-9a-z]+)(?:[\?#]|$)/i;
39 console
.log(files
[0].name
.match(patt1
));
40 var extension
= files
[0].name
.substr(files
[0].name
.lastIndexOf('.') + 1);
41 console
.log(extension
);
42 if (!(extension
== 'gz' )) {
43 alert("The file must be .tar.gz");
47 data
.append('file', files
[0]);
50 data
.append('csrfmiddlewaretoken', csrf_token
);
51 data
.append('type', type
);
52 data
.append('text', text
);
53 data
.append('id', '{{descriptor_id}}');
62 success: function (result
) {
65 window
.location
.href
= descr_list_url
68 error: function (result
) {