PageSourceSearch

https://3dgrayscale.com/wp-content/plugins/wp-user-frontend/assets/js/upload.js?ver=6.8.3

js 3dgrayscale.com collected 2026-10-03 18:20:00 UTC 8,787 bytes, 255 lines download raw bytes

1;(function($) {
2
3    /**
4     * Upload handler helper
5     *
6     * @param string {browse_button} browse_button ID of the pickfile
7     * @param string {container} container ID of the wrapper
8     * @param int {max} maximum number of file uplaods
9     * @param string {type}
10     */
11    window.WPUF_Uploader = function (browse_button, container, max, type, allowed_type, max_file_size) {
12        this.removed_files = [];
13        this.container = container;
14        this.browse_button = browse_button;
15        this.max = max || 1;
16        this.count = $('#' + container).find('.wpuf-attachment-list > li').length; //count how many items are there
17        this.perFileCount = 0; //file count on each upload
18        this.UploadedFiles = 0; //file count on each upload
19
20        //if no element found on the page, bail out
21        if( !$('#'+browse_button).length ) {
22            return;
23        }
24
25        // enable drag option for ordering
26        $( "ul.wpuf-attachment-list" ).sortable({
27            placeholder: "highlight"
28        });
29        $( "ul.wpuf-attachment-list" ).disableSelection();
30
31        //instantiate the uploader
32        this.uploader = new plupload.Uploader({
33            runtimes: 'html5,html4',
34            browse_button: browse_button,
35            container: container,
36            multipart: true,
37            multipart_params: {
38                action: 'wpuf_upload_file',
39                form_id: $( '#' + browse_button ).data('form_id')
40            },
41            urlstream_upload: true,
42            file_data_name: 'wpuf_file',
43            max_file_size: max_file_size + 'kb',
44            url: wpuf_frontend_upload.plupload.url + '&type=' + type,
45            flash_swf_url: wpuf_frontend_upload.flash_swf_url,
46            filters: [{
47                title: 'Allowed Files',
48                extensions: allowed_type
49            }]
50        });
51
52        //attach event handlers
53        this.uploader.bind('Init', $.proxy(this, 'init'));
54        this.uploader.bind('FilesAdded', $.proxy(this, 'added'));
55        this.uploader.bind('QueueChanged', $.proxy(this, 'upload'));
56        this.uploader.bind('UploadProgress', $.proxy(this, 'progress'));
57        this.uploader.bind('Error', $.proxy(this, 'error'));
58        this.uploader.bind('FileUploaded', $.proxy(this, 'uploaded'));
59
60        this.uploader.init();
61
62        $('#' + container).on('click', 'a.attachment-delete', $.proxy(this.removeAttachment, this));
63
64        return this.uploader;
65    };
66
67    WPUF_Uploader.prototype = {
68
69        init: function (up, params) {
70            this.showHide();
71            $('#' + this.container).prepend('<div class="wpuf-file-warning"></div>');
72        },
73
74        showHide: function () {
75
76            if ( this.count >= this.max) {
77
78                if ( this.count > this.max ) {
79                    $('#' + this.container + ' .wpuf-file-warning').html( wpuf_frontend_upload.warning );
80                } else {
81                    $('#' + this.container + ' .wpuf-file-warning').html( wpuf_frontend_upload.warning );
82                }
83
84                $('#' + this.container).find('.file-selector').hide();
85
86                return;
87            };
88            $('#' + this.container + ' .wpuf-file-warning').html( '' );
89            $('#' + this.container).find('.file-selector').show();
90        },
91
92        added: function (up, files) {
93            var $container = $('#' + this.container).find('.wpuf-attachment-upload-filelist');
94
95            this.showHide();
96
97            $.each(files, function(i, file) {
98                $(".wpuf-submit-button").attr("disabled", "disabled");
99
100                $container.append(
101                    '<div class="upload-item" id="' + file.id + '"><div class="progress progress-striped active"><div class="bar"></div></div><div class="filename original">' +
102                    file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
103                    '</div></div>');
104            });
105
106            up.refresh();
106 // Reposition Flash/Silverlight
107            up.start();
108        },
109
110        upload: function (uploader) {
111            this.count = uploader.files.length - this.removed_files.length ;
112            this.showHide();
113        },
114
115        progress: function (up, file) {
116            var item = $('#' + file.id);
117
118            $('.bar', item).css({ width: file.percent + '%' });
119            $('.percent', item).html( file.percent + '%' );
120        },
121
122        error: function (up, error) {
123            $('#' + this.container).find('#' + error.file.id).remove();
124
125            var msg = '';
126            switch (error.code) {
127                case -600:
128                    msg = wpuf_frontend_upload.plupload.size_error;
129                    break;
130
131                case -601:
132                    msg = wpuf_frontend_upload.plupload.type_error;
133                    break;
134
135                default:
136                    msg = 'Error #' + error.code + ': ' + error.message;
137                    break;
138            }
139
140            alert(msg);
141
142            this.count -= 1;
143            this.showHide();
144            this.uploader.refresh();
145        },
146
147        uploaded: function (up, file, response) {
148            try {
149                var res = $.parseJSON(response.response);
150            }catch (e) {
151                var text = true;
152            }
153
154            var self = this;
155
156            $('#' + file.id + " b").html("100%");
157            $('#' + file.id).remove();
158
159            if( text ) {
160                this.perFileCount++;
161                this.UploadedFiles++;
162                var $container = $('#' + this.container).find('.wpuf-attachment-list');
163                $container.append(response.response);
164
165                if ( this.perFileCount > this.max ) {
166                    var attach_id = $('.wpuf-image-wrap:last a.attachment-delete',$container).data('attach-id');
167                    self.removeExtraAttachment(attach_id);
168                    $('.wpuf-image-wrap',$container).last().remove();
169                    this.perFileCount--;
170                }
171
172            } else {
173                alert(res.data.replace( /(<([^>]+)>)/ig, ''));
174
175                up.files.pop();
176                this.count -= 1;
177                this.showHide();
178
179            }
180
181            var uploaded        = this.UploadedFiles,
182                FileProgress    = up.files.length;
183
184            if ( this.count >= this.max ) {
185                $('#' + this.container).find('.file-selector').hide();
186            }
187
188            if ( FileProgress === uploaded ) {
189                if ( typeof grecaptcha !== 'undefined' && $('.wpuf-form-add #g-recaptcha-response').length ) {
190                    if ( !grecaptcha.getResponse().length ){
191                        return;
192                    }
193                }
194
195                $(".wpuf-submit-button").removeAttr("disabled");
196            }
197        },
198
199        removeAttachment: function(e) {
200            e.preventDefault();
201
202            var self = this,
203            el = $(e.currentTarget);
204
205            Swal.fire({
206                text: wpuf_frontend_upload.confirmMsg,
207                icon: 'warning',
208                showCancelButton: true,
209                confirmButtonColor: '#d54e21',
210                confirmButtonText: wpuf_frontend_upload.delete_it,
211                cancelButtonText: wpuf_frontend_upload.cancel_it,
212                customClass: {
213                    confirmButton: 'btn btn-success',
214                    cancelButton: 'btn btn-danger',
215                }
216            }).then(function (result) {
217                if (!result.isConfirmed) {
218                    return;
219                }
220                var data = {
221                    'attach_id' : el.data('attach-id'),
222                    'nonce' : wpuf_frontend_upload.nonce,
223                    'action' : 'wpuf_file_del'
224                };
225                self.removed_files.push(data);
226                jQuery('#del_attach').val(el.data('attach-id'));
227                jQuery.post(wpuf_frontend_upload.ajaxurl, data, function() {
228                    self.perFileCount--;
229                    el.parent().parent().remove();
230
231                    self.count -= 1;
232                    self.showHide();
233                    self.uploader.refresh();
234                });
235            });
236        },
237
238        removeExtraAttachment : function( attach_id ) {
239            var self = this;
240
241            var data = {
242                'attach_id' : attach_id,
243                'nonce' : wpuf_frontend_upload.nonce,
244                'action' : 'wpuf_file_del'
245            };
246            this.removed_files.push(data);
247            jQuery.post(wpuf_frontend_upload.ajaxurl, data, function() {
248                self.count -= 1;
249                self.showHide();
250                self.uploader.refresh();
251            });
252        }
253
254    };
255})(jQuery);

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.