1 2// dropzoneWordpressForm is the configuration for the element that has an id attribute 3// with the value dropzone-wordpress-form (or dropzoneWordpressForm) 4jQuery(document).ready(function($){ 5 function custom_sanitize_attr(s) { 6 return s.replace(/&/g, '_').replace(/</g, '_').replace(/>/g, '_').replace(/"/g, '_').replace(/'/g, '_').replace(/\//g, '_').replace(/\./g, '_'); 7 } 8 // Disable auto discover for all elements: 9 Dropzone.autoDiscover = false; 10 $(".dropzone-custom").each(function(){ 11 var $self = $(this); 12 var actionUrl = $self.data('url') || $self.closest('form').attr('action'); 13 var uploadsFolder = $self.data('type') || ''; 14 var filesField = $self.data('field') || 'uploads'; 15 var maxAllowed = $self.data('max') || 2; 16 var maxSizeAllowed = $self.data('max-filesize') || 5; 17 var acceptedTypes = $self.data('filetypes') || '.jpg,.jpeg,.png'; 18 $self.dropzone({ 19 url: actionUrl + "?action=handleUploads&type=" + uploadsFolder , 20 addRemoveLinks: true, 21 maxFiles: parseInt(maxAllowed), 22 acceptedFiles: acceptedTypes, 23 maxFilesize: parseInt(maxSizeAllowed), // MB 24 clickable: true, 25 autoDiscover:false, 26 uploadMultiple: false, 27 init: function(){ 28 this.on("removedfile", function(file){ 29 if(file.new_name){ 30 $.ajax({ 31 type: 'POST', 32 url: actionUrl + "?action=handleDeleteUploads&type=" + uploadsFolder, 33 data: {name: file.new_name}, 34 success: function(data){ 35 var input_attr = custom_sanitize_attr(filesField+'_'+file.new_name); 36 $self.find('#'+input_attr).remove(); 37 } 38 }); 39 } 40 }); 41 this.on("success", function(file, response){ 42 if(response.success){ 43 file.new_name = response.file; //store new file name for delete action 44 var input_attr = custom_sanitize_attr(filesField+'_'+response.file); 45 $self.append('<input type="hidden" name="'+filesField+'[]" value="'+response.file_url+'" id="'+input_attr+'" />'); 46 } 47 }); 48 this.on("error", function(file, message2){ 49// console.log('error',message2); 50 }); 51 } 52 }) 53 }); 54});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.