PageSourceSearch

https://s61m.com/js/buildfileupload.js

js s61m.com collected 2026-10-06 13:14:22 UTC 11,171 bytes, 256 lines download raw bytes

1; (function($$) {
2    buildfileupload=function(s) {
3            try {
4                var reader = new FileReader();
5                canvaszoom = false;
6				
7				//webkitrlativepath=undefinde //lastmodifiedate=undefinde //name=img.gif //type= image/gif //size=18871 //slice = function slice() {[native code]}
8                if (s.files.type && s.files.type.indexOf('image/') >= 0) {
9					//¿ØÖÆÊÇ·ñ½øÐÐcanvaszoom
10					canvaszoom = true;
11					if(s.files.type.indexOf('image/gif') >= 0 && s.files.size <= 307200){
12                    	canvaszoom = false;
13					}
14                }
15                var picupload = function(picdata) {
16                    if (!XMLHttpRequest.prototype.sendAsBinary) {
17                        XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
18                            function byteValue(x) {
19                                return x.charCodeAt(0) & 0xff;
20                            }
21                            var ords = Array.prototype.map.call(datastr, byteValue);
22                            var ui8a = new Uint8Array(ords);
23                            this.send(ui8a.buffer);
24                        }
25                    }
26                    var xhr = new XMLHttpRequest(),
27                    file = s.files,
28                    index = 0,
29                    start_time = new Date().getTime(),
30                    boundary = '------multipartformboundary' + (new Date).getTime(),
31                    builder;
32                    builder = getbuilder(s, file.name, picdata, boundary);
33                    if (s.uploadpercent) {
34                        xhr.upload.onprogress = function(e) {
35                            if (e.lengthComputable) {
36                                var percent = Math.ceil((e.loaded / e.total) * 100);
37                                $$('#' + s.uploadpercent).html(percent + '%');
38                            }
39                        };
40                    }
41                    xhr.open("POST", s.uploadurl, true);
42                    xhr.setRequestHeader('content-type', 'multipart/form-data; boundary=' + boundary);
43                    xhr.sendAsBinary(builder);
44                    xhr.onerror = function() {
45                        s.error();
46                    };
47                    xhr.onabort = function() {
48                        s.error();
49                    };
50                    xhr.ontimeout = function() {
51                        s.error();
52                    };
53                    xhr.onload = function() {
54                        if (xhr.responseText) {
55                            s.success(xhr.responseText,file);
56                        }
57                    };
58                    var oldobj = $$('#filedata');
59                    var newobj = $$(oldobj).clone();
60                    oldobj.before(newobj).remove();
61                };
62                if (canvaszoom) {
63                    var detectsubsampling = function(img, imgwidth, imgheight) {
64                        if (imgheight * imgwidth > 1024 * 1024) {
65                            var tmpcanvas = document.createElement('canvas');
66                            tmpcanvas.width = tmpcanvas.height = 1;
67                            var tmpctx = tmpcanvas.getContext('2d');
68                            ctx.drawImage(img, -imgwidth + 1, 0);
69                            return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
70                        } else {
71                            return false;
72                        }
73                    };
74                    var detectverticalsquash = function(img, imgheight) {
75                        var tmpcanvas = document.createElement('canvas');
76                        tmpcanvas.width = 1;
77                        tmpcanvas.height = imgheight;
78                        var tmpctx = tmpcanvas.getContext('2d');
79                        tmpctx.drawImage(img, 0, 0);
80                        var data = tmpctx.getImageData(0, 0, 1, imgheight).data;
81                        var sy = 0;
82                        var ey = imgheight;
83                        var py = imgheight;
84                        while (py > sy) {
85                            var alpha = data[(py - 1) * 4 + 3];
86                            if (alpha === 0) {
87                                ey = py;
88                            } else {
89                                sy = py;
90                            }
91                            py = (ey + sy) >> 1;
92                        }
93                        var ratio = py / imgheight;
94                        return (ratio === 0) ? 1 : ratio;
95                    };
96                    var maxheight = 800;
97                    var maxwidth = 800;
98                    var canvas = document.createElement('canvas');
99                    var ctx = canvas.getContext('2d');
100                    var img = document.createElement('img');
101                    img.onload = function() {
102                        var imgwidth = this.width;
103                        var imgheight = this.height;
104                        var canvaswidth = maxwidth;
105                        var canvasheight = maxheight;
106                        var newwidth = imgwidth;
107                        var newheight = imgheight;
108                        if (imgwidth / imgheight <= canvaswidth / canvasheight && imgheight >= canvasheight) {
109                            newheight = canvasheight;
110                            newwidth = Math.ceil(canvasheight / imgheight * imgwidth);
111                        } else if (imgwidth / imgheight > canvaswidth / canvasheight && imgwidth >= canvaswidth) {
112                            newwidth = canvaswidth;
113                            newheight = Math.ceil(canvaswidth / imgwidth * imgheight);
114                        }
115                        ctx.save();
116                        if (detectsubsampling(this, imgwidth, imgheight)) {
117                            imgheight = imgheight / 2;
118                            imgwidth = imgwidth / 2;
119                        }
120                        var vertsquashratio = detectverticalsquash(this, imgheight);
121                        canvas.height = newheight;
122                        canvas.width = newwidth;
123                        ctx.drawImage(this, 0, 0, imgwidth, imgheight, 0, 0, newwidth, newheight / vertsquashratio);
124                        ctx.restore();
125                        var newdataurl = canvas.toDataURL(s.files.type).replace(/data:.+;base64,/, '');
126                        if (typeof atob == 'function') {
127                            picupload(atob(newdataurl));
128                        } else {
129                            picupload($$.fn.base64decode(newdataurl));
130                        }
131                    };
132                    $$('#unseearea').append(img);
133                    $$(img).css('display', 'none');
134                }
135                reader.index = 0;
136                reader.onloadend = function(e) {
137                    if (canvaszoom) {
138                        img.src = e.target.result;
139                    } else {
140                        picupload(e.target.result);
141                    }
142                    return;
143                };
144                if (canvaszoom) {
145                    reader.readAsDataURL(s.files);
146                } else {
147                    reader.readAsBinaryString(s.files);
148                }
149            } catch(err) {
150                return s.error();
151            }
152            return;
153        },
154        getbuilder=function(s, filename, filedata, boundary) {
155			//filename = '00.jpg';
156			//s.uploadinputname = filename ;
157			
158			
159            var dashdash = '--',
160            crlf = '\r\n',
161            builder = '';
162            for (var i in s.uploadformdata) {
163                builder += dashdash;
164                builder += boundary;
165                builder += crlf;
166                builder += 'Content-Disposition: form-data; name="' + i + '"';
167                builder += crlf;
168                builder += crlf;
169                builder += s.uploadformdata[i];
170                builder += crlf;
171            }
172            builder += dashdash;
173            builder += boundary;
174            builder += crlf;
175            builder += 'Content-Disposition: form-data; name="' + s.uploadinputname + '"';
176            builder += '; filename="' + filename + '"';
177            builder += crlf;
178            builder += 'Content-Type: application/octet-stream';
179            builder += crlf;
180            builder += crlf;
181            builder += filedata;
182            builder += crlf;
183            builder += dashdash;
184            builder += boundary;
185            builder += dashdash;
186            builder += crlf;
187            return builder;
188        },list=function(s) {
189			//ÁгöÁбí
190			var str = '';
191			console.log(s.name);
192				
193			return true;
194			//});
195		}
196})(jQuery);; (function($$) {
197    $$.extend($$.fn, {
198        base64encode: function(input) {
199            var output = '';
200            var chr1, chr2, chr3 = '';
201            var enc1, enc2, enc3, enc4 = '';
202            var i = 0;
203            do {
204                chr1 = input.charCodeAt(i++);
205                chr2 = input.charCodeAt(i++);
206                chr3 = input.charCodeAt(i++);
207                enc1 = chr1 >> 2;
208                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
209                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
210                enc4 = chr3 & 63;
211                if (isNaN(chr2)) {
212                    enc3 = enc4 = 64;
213                } else if (isNaN(chr3)) {
214                    enc4 = 64;
215                }
216                output = output + this._keys.charAt(enc1) + this._keys.charAt(enc2) + this._keys.charAt(enc3) + this._keys.charAt(enc4);
217                chr1 = chr2 = chr3 = '';
218                enc1 = enc2 = enc3 = enc4 = '';
219            } while ( i < input . length );
220            return output;
221        },
222        base64decode: function(input) {
223            var output = '';
224            var chr1, chr2, chr3 = '';
225            var enc1, enc2, enc3, enc4 = '';
226            var i = 0;
227            if (input.length % 4 != 0) {
228                return '';
229            }
230            var base64test = /[^A-Za-z0-9\+\/\=]/g;
231            if (base64test.exec(input)) {
232                return '';
233            }
234            do {
235                enc1 = this._keys.indexOf(input.charAt(i++));
236                enc2 = this._keys.indexOf(input.charAt(i++));
237                enc3 = this._keys.indexOf(input.charAt(i++));
238                enc4 = this._keys.indexOf(input.charAt(i++));
239                chr1 = (enc1 << 2) | (enc2 >> 4);
240                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
241                chr3 = ((enc3 & 3) << 6) | enc4;
242                output = output + String.fromCharCode(chr1);
243                if (enc3 != 64) {
244                    output += String.fromCharCode(chr2);
245                }
246                if (enc4 != 64) {
247                    output += String.fromCharCode(chr3);
248                }
249                chr1 = chr2 = chr3 = '';
250                enc1 = enc2 = enc3 = enc4 = '';
251            } while ( i < input . length );
252            return output;
253        },
254        _keys: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
254+/=',
255    })
256})(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.