PageSourceSearch

https://correspondant.lamanchelibre.fr/wpublic/js/jquery.upload-1.0.2.js?20260922084155

js lamanchelibre.fr collected 2026-09-24 20:37:40 UTC 4,151 bytes, 139 lines download raw bytes

1/*
2 * jQuery.upload v1.0.2
3 *
4 * Copyright (c) 2010 lagos
5 * Dual licensed under the MIT and GPL licenses.
6 *
7 * http://lagoscript.org
8 */
9(function ($) {
10
11    var uuid = 0;
12
13    $.fn.upload = function (url, data, callback, type) {
14        var self = this, inputs, checkbox, checked,
15			iframeName = 'jquery_upload' + ++uuid,
16			iframe = $('<iframe id="'+iframeName+'" name="' + iframeName + '" style="position:absolute;top:-9999px" />').appendTo('body'),
17			form = '<form target="' + iframeName + '" method="post" enctype="multipart/form-data" />';
18
19        if ($.isFunction(data)) {
20            type = callback;
21            callback = data;
22            data = {};
23        }
24
25        checkbox = $('input:checkbox', this);
26        checked = $('input:checked', this);
27        form = self.wrapAll(form).parent('form').attr('action', url);
28
29        // Make sure radios and checkboxes keep original values
30        // (IE resets checkd attributes when appending)
31        checkbox.removeAttr('checked');
32        checked.attr('checked', true);
33
34        inputs = createInputs(data);
35        inputs = inputs ? $(inputs).appendTo(form) : null;
36
37        form.submit(function () {
38            
39            iframe.load(function () {
40                var data = handleData(this,iframeName, type),
41					checked = $('input:checked', self);
42
43                form.after(self).remove();
44                checkbox.removeAttr('checked');
45                checked.attr('checked', true);
46                if (inputs) {
47                    inputs.remove();
48                }
49
50                setTimeout(function () {
51                    iframe.remove();
52                    if (type === 'script') {
53                        $.globalEval(data);
54                    }
55                    if (callback) {
56                        callback.call(self, data);
57                    }
58                }, 0);
59            });
60            
61        }).submit();
62
63        $('#browseUpload').css('display', 'block');
64
65
66        return this;
67    };
68
69    function createInputs(data) {
70        return $.map(param(data), function (param) {
71            return '<input type="hidden" name="' + param.name + '" value="' + param.value + '"/>';
72        }).join('');
73    }
74
75    function param(data) {
76        if ($.isArray(data)) {
77            return data;
78        }
79        var params = [];
80
81        function add(name, value) {
82            params.push({name: name, value: value});
83        }
84
85        if (typeof data === 'object') {
86            $.each(data, function (name) {
87                if ($.isArray(this)) {
88                    $.each(this, function () {
89                        add(name, this);
90                    });
91                } else {
92                    add(name, $.isFunction(this) ? this() : this);
93                }
94            });
95        } else if (typeof data === 'string') {
96            $.each(data.split('&'), function () {
97                var param = $.map(this.split('='), function (v) {
98                    return decodeURIComponent(v.replace(/\+/g, ' '));
99                });
100
101                add(param[0], param[1]);
102            });
103        }
104
105        return params;
106    }
107
108    function handleData(iframe,name, type) {
109       
110      var data, contents = $(iframe).contents().get(0);
111
112        if ($.isXMLDoc(contents) || contents.XMLDocument) {
113            return contents.XMLDocument || contents;
114        }
115        data = $(contents).find('body').html();
116
117        switch (type) {
118            case 'xml':
119                data = parseXml(data);
120                break;
121            case 'json':
122                data = window.eval('(' + data + ')');
123                break;
124        }
125        return data;
126    }
127
128    function parseXml(text) {
129        if (window.DOMParser) {
130            return new DOMParser().parseFromString(text, 'application/xml');
131        } else {
132            var xml = new ActiveXObject('Microsoft.XMLDOM');
133            xml.async = false;
134            xml.loadXML(text);
135            return xml;
136        }
137    }
138
139})(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.