PageSourceSearch

https://www.scanex.ru/local/js/plugins/jquery.uploadifive.min.js?151618694129475

js scanex.ru collected 2026-10-02 08:09:57 UTC 29,475 bytes, 619 lines download raw bytes

1/*
2 UploadiFive 1.1.2
3 Copyright (c) 2012 Reactive Apps, Ronnie Garcia
4 Released under the UploadiFive Standard License <http://www.uploadify.com/uploadifive-standard-license>
5 */
6(function (b) {
7    var a = {
8        init: function (c) {
9            return this.each(function () {
10                var g = b(this);
11                g.data("uploadifive", {
12                    inputs: {},
13                    inputCount: 0,
14                    fileID: 0,
15                    queue: {count: 0, selected: 0, replaced: 0, errors: 0, queued: 0, cancelled: 0},
16                    uploads: {current: 0, attempts: 0, successful: 0, errors: 0, count: 0}
17                });
18                var d = g.data("uploadifive");
19                var f = d.settings = b.extend({
20                    auto: true,
21                    buttonClass: false,
22                    buttonText: "Select Files",
23                    checkScript: false,
24                    dnd: true,
25                    dropTarget: false,
26                    fileObjName: "Filedata",
27                    fileSizeLimit: 0,
28                    fileType: false,
29                    formData: {},
30                    height: 30,
31                    itemTemplate: false,
32                    method: "post",
33                    multi: true,
34                    overrideEvents: [],
35                    queueID: false,
36                    queueSizeLimit: 0,
37                    removeCompleted: false,
38                    simUploadLimit: 0,
39                    truncateLength: 0,
40                    uploadLimit: 0,
41                    uploadScript: "uploadifive.php",
42                    width: 100
43                }, c);
44                if (isNaN(f.fileSizeLimit)) {
45                    var e = parseInt(f.fileSizeLimit) * 1.024;
46                    if (f.fileSizeLimit.indexOf("KB") > -1) {
47                        f.fileSizeLimit = e * 1000;
48                    } else {
49                        if (f.fileSizeLimit.indexOf("MB") > -1) {
50                            f.fileSizeLimit = e * 1000000;
51                        } else {
52                            if (f.fileSizeLimit.indexOf("GB") > -1) {
53                                f.fileSizeLimit = e * 1000000000;
54                            }
55                        }
56                    }
57                } else {
58                    f.fileSizeLimit = f.fileSizeLimit * 1024;
59                }
60                d.inputTemplate = b('<input type="file">').css({
61                    "font-size": f.height + "px",
62                    opacity: 0,
63                    position: "absolute",
64                    right: "-3px",
65                    top: "-3px",
66                    "z-index": 999
67                });
68                d.createInput = function () {
69                    var j = d.inputTemplate.clone();
70                    var k = j.name = "input" + d.inputCount++;
71                    if (f.multi) {
72                        j.attr("multiple", true);
73                    }
74                    j.bind("change", function () {
75                        d.queue.selected = 0;
76                        d.queue.replaced = 0;
77                        d.queue.errors = 0;
78                        d.queue.queued = 0;
79                        var l = this.files.length;
80                        d.queue.selected = l;
81                        if ((d.queue.count + l) > f.queueSizeLimit && f.queueSizeLimit !== 0) {
82                            if (b.inArray("onError", f.overrideEvents) < 0) {
83                                alert("The maximum number of queue items has been reached (" + f.queueSizeLimit + ").  Please select fewer files.");
84                            }
85                            if (typeof f.onError === "function") {
86                                f.onError.call(g, "QUEUE_LIMIT_EXCEEDED");
87                            }
88                        } else {
89                            for (var m = 0; m < l; m++) {
90                                file = this.files[m];
91                                d.addQueueItem(file);
92                            }
93                            d.inputs[k] = this;
94                            d.createInput();
95                        }
96                        if (f.auto) {
97                            a.upload.call(g);
98                        }
99                        if (typeof f.onSelect === "function") {
100                            f.onSelect.call(g, d.queue);
101                        }
102                    });
103                    if (d.currentInput) {
104                        d.currentInput.hide();
105                    }
106                    d.button.append(j);
107                    d.currentInput = j;
108                };
109                d.destroyInput = function (j) {
110                    b(d.inputs[j]).remove();
111                    delete d.inputs[j];
112                    d.inputCount--;
113                };
114                d.drop = function (m) {
115                    d.queue.selected = 0;
116                    d.queue.replaced = 0;
117                    d.queue.errors = 0;
118                    d.queue.queued = 0;
119                    var l = m.dataTransfer;
120                    var k = l.name = "input" + d.inputCount++;
121                    var j = l.files.length;
122                    d.queue.selected = j;
123                    if ((d.queue.count + j) > f.queueSizeLimit && f.queueSizeLimit !== 0) {
124                        if (b.inArray("onError", f.overrideEvents) < 0) {
125                            alert("The maximum number of queue items has been reached (" + f.queueSizeLimit + ").  Please select fewer files.");
126                        }
127                        if (typeof f.onError === "function") {
128                            f.onError.call(g, "QUEUE_LIMIT_EXCEEDED");
129                        }
130                    } else {
131                        for (var o = 0; o < j; o++) {
132                            file = l.files[o];
133                            d.addQueueItem(file);
134                        }
135                        d.inputs[k] = l;
136                    }
137                    if (f.auto) {
138                        a.upload.call(g);
139                    }
140                    if (typeof f.onDrop === "function") {
141                        f.onDrop.call(g, l.files, l.files.length);
142                    }
143                    m.preventDefault();
144                    m.stopPropagation();
145                };
146                d.fileExistsInQueue = function (k) {
147                    for (var j in d.inputs) {
148                        input = d.inputs[j];
149                        limit = input.files.length;
150                        for (var l = 0; l < limit; l++) {
151                            existingFile = input.files[l];
152                            if (existingFile.name == k.name && !existingFile.complete) {
153                                return true;
154                            }
155                        }
156                    }
157                    return false;
158                };
159                d.removeExistingFile = function (k) {
160                    for (var j in d.inputs) {
161                        input = d.inputs[j];
162                        limit = input.files.length;
163                        for (var l = 0; l < limit; l++) {
164                            existingFile = input.files[l];
165                            if (existingFile.name == k.name && !existingFile.complete) {
166                                d.queue.replaced++;
167                                a.cancel.call(g, existingFile, true);
168                            }
169                        }
170                    }
171                };
172                if (f.itemTemplate == false) {
173                    d.queueItem = b('<div class="uploadifive-queue-item file-list">                        <a class="delete" href="#"></a>                        <span class="filename"></span>                        <div class="progress">                            <div class="progress-bar"></div>                        </div>                    </div>');
174                } else {
175                    d.queueItem = b(f.itemTemplate);
176                }
177                d.addQueueItem = function (k) {
178                    if (b.inArray("onAddQueueItem", f.overrideEvents) < 0) {
179                        d.removeExistingFile(k);
180                        k.queueItem = d.queueItem.clone();
181                        k.queueItem.attr("id", f.id + "-file-" + d.fileID++);
182                        k.queueItem.find(".delete").bind("click", function () {
183                            a.cancel.call(g, k);
184                            return false;
185                        });
186                        var m = k.name;
187                        if (m.length > f.truncateLength && f.truncateLength != 0) {
188                            m = m.substring(0, f.truncateLength) + "...";
189                        }
190                        k.queueItem.find(".filename").html(m);
191                        k.queueItem.data("file", k);
192                        d.queueEl.append(k.queueItem);
193                    }
194                    if (typeof f.onAddQueueItem === "function") {
195                        f.onAddQueueItem.call(g, k);
196                    }
197                    if (f.fileType) {
198                        if (b.isArray(f.fileType)) {
199                            var j = false;
200                            for (var l = 0; l < f.fileType.length; l++) {
201                                if (k.type.indexOf(f.fileType[l]) > -1) {
202                                    j = true;
203                                }
204                            }
205                            if (!j) {
206                                d.error("FORBIDDEN_FILE_TYPE", k);
207                            }
208                        } else {
209                            if (k.type.indexOf(f.fileType) < 0) {
210                                d.error("FORBIDDEN_FILE_TYPE", k);
211                            }
212                        }
213                    }
214                    if (k.size > f.fileSizeLimit && f.fileSizeLimit != 0) {
215                        d.error("FILE_SIZE_LIMIT_EXCEEDED", k);
216                    } else {
217                        d.queue.queued++;
218                        d.queue.count++;
219                    }
220                };
221                d.removeQueueItem = function (m, l, k) {
222                    if (!k) {
223                        k = 0;
224                    }
225                    var j = l ? 0 : 500;
226                    if (m.queueItem) {
227                        if (m.queueItem.find(".fileinfo").html() != " - Completed") {
228                            m.queueItem.find(".fileinfo").html(" - Cancelled");
229                        }
230                        m.queueItem.find(".progress-bar").width(0);
231                        m.queueItem.delay(k).fadeOut(j, function () {
232                            b(this).remove();
233                        });
234                        delete m.queueItem;
235                        d.queue.count--;
236                    }
237                };
238                d.filesToUpload = function () {
239                    var k = 0;
240                    for (var j in d.inputs) {
241                        input = d.inputs[j];
242                        limit = input.files.length;
243                        for (var l = 0; l < limit; l++) {
244                            file = input.files[l];
245                            if (!file.skip && !file.complete) {
246                                k++;
247                            }
248                        }
249                    }
250                    return k;
251                };
252                d.checkExists = function (k) {
253                    if (b.inArray("onCheck", f.overrideEvents) < 0) {
254                        b.ajaxSetup({async: false});
255                        var j = b.extend(f.formData, {filename: k.name});
256                        b.post(f.checkScript, j, function (l) {
257                            k.exists = parseInt(l);
258                        });
259                        if (k.exists) {
260                            if (!confirm("A file named " + k.name + " already exists in the upload folder.\nWould you like to replace it?")) {
261                                a.cancel.call(g, k);
262                                return true;
263                            }
264                        }
265                    }
266                    if (typeof f.onCheck === "function") {
267                        f.onCheck.call(g, k, k.exists);
268                    }
269                    return false;
270                };
271                d.uploadFile = function (k, l) {
272                    if (!k.skip && !k.complete && !k.uploading) {
273                        k.uploading = true;
274                        d.uploads.current++;
275                        d.uploads.attempted++;
276                        xhr = k.xhr = new XMLHttpRequest();
277                        if (typeof FormData === "function" || typeof FormData === "object") {
278                            var m = new FormData();
279                            m.append(f.fileObjName, k);
280                            for (i in f.formData) {
281                                m.append(i, f.formData[i]);
282                            }
283                            xhr.open(f.method, f.uploadScript, true);
284                            xhr.upload.addEventListener("progress", function (n) {
285                                if (n.lengthComputable) {
286                                    d.progress(n, k);
287                                }
288                            }, false);
289                            xhr.addEventListener("load", function (n) {
290                                if (this.readyState == 4) {
291                                    k.uploading = false;
292                                    if (this.status == 200) {
293                                        if (k.xhr.responseText !== "Invalid file type.") {
294                                            d.uploadComplete(n, k, l);
295                                        } else {
296                                            d.error(k.xhr.responseText, k, l);
297                                        }
298                                    } else {
299                                        if (this.status == 404) {
300                                            d.error("404_FILE_NOT_FOUND", k, l);
301                                        } else {
302                                            if (this.status == 403) {
303                                                d.error("403_FORBIDDEN", k, l);
304                                            } else {
305                                                d.error("Unknown Error", k, l);
306                                            }
307                                        }
308                                    }
309                                }
310                            });
311                            xhr.send(m);
312                        } else {
313                            var j = new FileReader();
314                            j.onload = function (q) {
315                                var t = "-------------------------" + (new Date).getTime(), p = "--", o = "\r\n", s = "";
316                                s += p + t + o;
317                                s += 'Content-Disposition: form-data; name="' + f.fileObjName + '"';
318                                if (k.name) {
319                                    s += '; filename="' + k.name + '"';
320                                }
321                                s += o;
322                                s += "Content-Type: application/octet-stream" + o + o;
323                                s += q.target.result + o;
324                                for (key in f.formData) {
325                                    s += p + t + o;
326                                    s += 'Content-Disposition: form-data; name="' + key + '"' + o + o;
327                                    s += f.formData[key] + o;
328                                }
329                                s += p + t + p + o;
330                                xhr.upload.addEventListener("progress", function (u) {
331                                    d.progress(u, k);
332                                }, false);
333                                xhr.addEventListener("load", function (v) {
334                                    k.uploading = false;
335                                    var u = this.status;
336                                    if (u == 404) {
337                                        d.error("404_FILE_NOT_FOUND", k, l);
338                                    } else {
339                                        if (k.xhr.responseText != "Invalid file type.") {
340                                            d.uploadComplete(v, k, l);
341                                        } else {
342                                            d.error(k.xhr.responseText, k, l);
343                                        }
344                                    }
345                                }, false);
346                                var n = f.uploadScript;
347                                if (f.method == "get") {
348                                    var r = b(f.formData).param();
349                                    n += r;
350                                }
351                                xhr.open(f.method, f.uploadScript, true);
352                                xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + t);
353                                if (typeof f.onUploadFile === "function") {
354                                    f.onUploadFile.call(g, k);
355                                }
356                                xhr.sendAsBinary(s);
357                            };
358                            j.readAsBinaryString(k);
359                        }
360                    }
361                };
362                d.progress = function (l, j) {
363                    if (b.inArray("onProgress", f.overrideEvents) < 0) {
364                        if (l.lengthComputable) {
365                            var k = Math.round((l.loaded / l.total) * 100);
366                        }
367                        j.queueItem.find(".fileinfo").html(" - " + k + "%");
368                        j.queueItem.find(".progress-bar").css("width", k + "%");
369                    }
370                    if (typeof f.onProgress === "function") {
371                        f.onProgress.call(g, j, l);
372                    }
373                };
374                d.error = function (l, j, k) {
375                    if (b.inArray("onError", f.overrideEvents) < 0) {
376                        switch (l) {
377                            case"404_FILE_NOT_FOUND":
378                                errorMsg = "404 Error";
379                                break;
380                            case"403_FORBIDDEN":
381                                errorMsg = "403 Forbidden";
382                                break;
383                            case"FORBIDDEN_FILE_TYPE":
384                                errorMsg = "Forbidden File Type";
385                                break;
386                            case"FILE_SIZE_LIMIT_EXCEEDED":
387                                errorMsg = "File Too Large";
388                                break;
389                            default:
390                                errorMsg = "Unknown Error";
391                                break;
392                        }
393                        j.queueItem.addClass("error").find(".fileinfo").html(" - " + errorMsg);
394                        j.queueItem.find(".progress").remove();
395                        j.queueItem.remove();
396                    }
397                    if (typeof f.onError === "function") {
398                        f.onError.call(g, l, j);
399                    }
400                    j.skip = true;
401                    if (l == "404_FILE_NOT_FOUND") {
402                        d.uploads.errors++;
403                    } else {
404                        d.queue.errors++;
405                    }
406                    if (k) {
407                        a.upload.call(g, null, true);
408                    }
409                };
410                d.uploadComplete = function (l, j, k) {
411                    if (b.inArray("onUploadComplete", f.overrideEvents) < 0) {
412                        j.queueItem.find(".progress-bar").css("width", "100%");
413                        //j.queueItem.find(".fileinfo").html(" - Completed");
414                        //j.queueItem.find(".progress").slideUp(250);
415                        j.queueItem.addClass("complete");
416                    }
417                    if (typeof f.onUploadComplete === "function") {
418                        f.onUploadComplete.call(g, j, j.xhr.responseText);
419                    }
420                    if (f.removeCompleted) {
421                        setTimeout(function () {
422                            a.cancel.call(g, j);
423                        }, 3000);
424                    }
425                    j.complete = true;
426                    d.uploads.successful++;
427                    d.uploads.count++;
428                    d.uploads.current--;
429                    delete j.xhr;
430                    if (k) {
431                        a.upload.call(g, null, true);
432                    }
433                };
434                d.queueComplete = function () {
435                    if (typeof f.onQueueComplete === "function") {
436                        f.onQueueComplete.call(g, d.uploads);
437                    }
438                };
439                if (window.File && window.FileList && window.Blob && (window.FileReader || window.FormData)) {
440                    f.id = "uploadifive-" + g.attr("id");
441                    d.button = b('<div id="' + f.id + '" class="uploadifive-button">' + f.buttonText + "</div>");
442                    if (f.buttonClass) {
443                        d.button.addClass(f.buttonClass);
444                    }
445                    d.button.css({
446                        height: f.height,
447                        "line-height": f.height + "px",
448                        overflow: "hidden",
449                        position: "relative",
450                        "text-align": "center",
451                        width: f.width
452                    });
453                    g.before(d.button).appendTo(d.button).hide();
454                    d.createInput.call(g);
455                    if (!f.queueID) {
456                        f.queueID = f.id + "-queue";
457                        d.queueEl = b('<div id="' + f.queueID + '" class="uploadifive-queue" />');
458                        d.button.after(d.queueEl);
459                    } else {
460                        d.queueEl = b("#" + f.queueID);
461                    }
462                    if (f.dnd) {
463                        var h = f.dropTarget ? b(f.dropTarget) : d.queueEl.get(0);
464                        h.addEventListener("dragleave", function (j) {
465                            j.preventDefault();
466                            j.stopPropagation();
467                        }, false);
468                        h.addEventListener("dragenter", function (j) {
469                            j.preventDefault();
470                            j.stopPropagation();
471                        }, false);
472                        h.addEventListener("dragover", function (j) {
473                            j.preventDefault();
474                            j.stopPropagation();
475                        }, false);
476                        h.addEventListener("drop", d.drop, false);
477                    }
478                    if (!XMLHttpRequest.prototype.sendAsBinary) {
479                        XMLHttpRequest.prototype.sendAsBinary = function (k) {
480                            function l(n) {
481                                return n.charCodeAt(0) & 255;
482                            }
483
484                            var m = Array.prototype.map.call(k, l);
485                            var j = new Uint8Array(m);
486                            this.send(j.buffer);
487                        };
488                    }
489                    if (typeof f.onInit === "function") {
490                        f.onInit.call(g);
491                    }
492                } else {
493                    if (typeof f.onFallback === "function") {
494                        f.onFallback.call(g);
495                    }
496                    return false;
497                }
498            });
499        }, debug: function () {
500            return this.each(function () {
501                console.log(b(this).data("uploadifive"));
502            });
503        }, clearQueue: function () {
504            this.each(function () {
505                var f = b(this), c = f.data("uploadifive"), e = c.settings;
506                for (var d in c.inputs) {
507                    input = c.inputs[d];
508                    limit = input.files.length;
509                    for (i = 0; i < limit; i++) {
510                        file = input.files[i];
511                        a.cancel.call(f, file);
512                    }
513                }
514                if (typeof e.onClearQueue === "function") {
515                    e.onClearQueue.call(f, b("#" + c.settings.queueID));
516                }
517            });
518        }, cancel: function (d, c) {
519            this.each(function () {
520                var g = b(this), e = g.data("uploadifive"), f = e.settings;
521                if (typeof d === "string") {
522                    if (!isNaN(d)) {
523                        fileID = "uploadifive-" + b(this).attr("id") + "-file-" + d;
524                    }
525                    d = b("#" + fileID).data("file");
526                }
527                d.skip = true;
528                e.filesCancelled++;
529                if (d.uploading) {
530                    e.uploads.current--;
531                    d.uploading = false;
532                    d.xhr.abort();
533                    delete d.xhr;
534                    a.upload.call(g);
535                }
536                if (b.inArray("onCancel", f.overrideEvents) < 0) {
537                    e.removeQueueItem(d, c);
538                }
539                if (typeof f.onCancel === "function") {
540                    f.onCancel.call(g, d);
541                }
542            });
543        }, upload: function (c, d) {
544            this.each(function () {
545                var h = b(this), e = h.data("uploadifive"), f = e.settings;
546                if (c) {
547                    e.uploadFile.call(h, c);
548                } else {
549                    if ((e.uploads.count + e.uploads.current) < f.uploadLimit || f.uploadLimit == 0) {
550                        if (!d) {
551                            e.uploads.attempted = 0;
552                            e.uploads.successsful = 0;
553                            e.uploads.errors = 0;
554                            var g = e.filesToUpload();
555                            if (typeof f.onUpload === "function") {
556                                f.onUpload.call(h, g);
557                            }
558                        }
559                        b("#" + f.queueID).find(".uploadifive-queue-item").not(".error, .complete").each(function () {
560                            _file = b(this).data("file");
561                            if ((e.uploads.current >= f.simUploadLimit && f.simUploadLimit !== 0) || (e.uploads.current >= f.uploadLimit && f.uploadLimit !== 0) || (e.uploads.count >= f.uploadLimit && f.uploadLimit !== 0)) {
562                                return false;
563                            }
564                            if (f.checkScript) {
565                                _file.checking = true;
566                                skipFile = e.checkExists(_file);
567                                _file.checking = false;
568                                if (!skipFile) {
569                                    e.uploadFile(_file, true);
570                                }
571                            } else {
572                                e.uploadFile(_file, true);
573                            }
574                        });
575                        if (b("#" + f.queueID).find(".uploadifive-queue-item").not(".error, .complete").size() == 0) {
576                            e.queueComplete();
577                        }
578                    } else {
579                        if (e.uploads.current == 0) {
580                            if (b.inArray("onError", f.overrideEvents) < 0) {
581                                if (e.filesToUpload() > 0 && f.uploadLimit != 0) {
582                                    alert("The maximum upload limit has been reached.");
583                                }
584                            }
585                            if (typeof f.onError === "function") {
586                                f.onError.call(h, "UPLOAD_LIMIT_EXCEEDED", e.filesToUpload());
587                            }
588                        }
589                    }
590                }
591            });
592        }, destroy: function () {
593            this.each(function () {
594                var e = b(this), c = e.data("uploadifive"), d = c.settings;
595                a.clearQueue.call(e);
596                if (!d.queueID) {
597                    b("#" + d.queueID).remove();
598                }
599                e.siblings("input").remove();
600                e.show().insertBefore(c.button);
601                c.button.remove();
602                if (typeof d.onDestroy === "function") {
603                    d.onDestroy.call(e);
604                }
605            });
606        }
607    };
608    b.fn.uploadifive = function (c) {
609        if (a[c]) {
610            return a[c].apply(this, Array.prototype.slice.call(arguments, 1));
611        } else {
612            if (typeof c === "object" || !c) {
613                return a.init.apply(this, arguments);
614            } else {
615                b.error("The method " + c + " does not exist in $.uploadify");
616            }
617        }
618    };
619})(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.