PageSourceSearch

https://cpaa.co.uk/cms3t/res/js/jQuery/jquery.AjaxUpload.js

js cpaa.co.uk collected 2026-10-08 02:29:45 UTC 4,553 bytes, 193 lines download raw bytes

1jQuery.extend({
2
3	handleError: function () {},
4
5	createUploadIframe: function (id, uri) {
6		var frameId = 'jQuery' + id;
7
8		if (window.ActiveXObject) {
9		/*/	
10			var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
11		/*/	
12			var io = document.createElement("iframe");
13			io.setAttribute("id", frameId);
14			io.setAttribute("name", frameId);
15		/**/	
16
17			if (typeof uri == 'boolean') {
18				io.src = 'javascript:false';
19			} else if (typeof uri == 'string') {
20				io.src = uri;
21			}
22			
23		} else {
24			
25			var io = document.createElement('iframe');
26			io.id = frameId;
27			io.name = frameId;
28		}
29
30		io.style.position = 'absolute';
31		io.style.top = '-1000px';
32		io.style.left = '-1000px';
33
34		document.body.appendChild(io);
35
36		return io;
37	},
38
39	ajaxUpload: function (s) {
40		// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
41		s = jQuery.extend({}, jQuery.ajaxSettings, s);
42
43		var id = new Date().getTime();
44		
45		io = jQuery.createUploadIframe(id, s.secureuri);
46
47		// Watch for a new set of requests
48		if (s.global && !jQuery.active++) 
49			jQuery.event.trigger("ajaxStart");
50
51		var requestDone = false;
52
53		// Create the request object
54		var xml = {};
55
56		if (s.global) 
57			jQuery.event.trigger("ajaxSend", [xml, s]);
58
59		// Wait for a response to come back
60		var uploadCallback = function (isTimeout) {
61
62			function showErrorInfo(e) {
63			}
64
65			try {
66
67				xml.responseText = io.contentWindow.document.body ? io.contentWindow.document.body.innerHTML : null;
68
69				xml.responseXML = io.contentWindow.document.XMLDocument ? io.contentWindow.document.XMLDocument : io.contentWindow.document;
70
71			} catch (e) {
72				showErrorInfo(e);
73			}
74
75			if (xml || isTimeout == "timeout") {
76				requestDone = true;
77				var status;
78				try {
79					status = isTimeout != "timeout" ? "success" : "error";
80					// Make sure that the request was successful or notmodified
81
82					if (status != "error") {
83
84						// process the data (runs the xml through httpData regardless of callback)
85						var data = jQuery.uploadHttpData(xml, s.dataType);
86
87						// If a local callback was specified, fire it and pass it the data
88						if (s.success) s.success(data, status);
89
90						// Fire the global callback
91						if (s.global) jQuery.event.trigger("ajaxSuccess", [xml, s]);
92
93					} else jQuery.handleError(s, xml, status);
94
95				} catch (e) {
96
97					status = "error";
98					jQuery.handleError(s, xml, status, e);
99				}
100
101				// The request was completed
102				if (s.global) jQuery.event.trigger("ajaxComplete", [xml, s]);
103
104				// Handle the global AJAX counter
105				if (s.global && !--jQuery.active) jQuery.event.trigger("ajaxStop");
106
107				// Process result
108				if (s.complete) s.complete(xml, status);
109
110				jQuery(io).unbind();
111
112				setTimeout(function () {
113					try {
114						jQuery(io).remove();
115						jQuery(form).remove();
116
117					} catch (e) {
118						xml = null;
119					}
120
121				}, 100);
122
123			}
124
125		}
126		
127		// Timeout checker
128		if (s.timeout > 0) {
129
130			setTimeout(function () {
131				// Check to see if the request is still happening
132				if (!requestDone) {
133					uploadCallback("timeout");
134				}
135
136			}, s.timeout);
137
138		}
139
140		try {
141
142			var frameId = 'jQuery' + id;
143			var io = document.getElementById(frameId);
144
145			// Initialize the HTML form properties in case they are
146			// not defined in the HTML form.
147			s.uploadform.action = s.url;
148			s.uploadform.method = 'POST';
149			s.uploadform.target = frameId;
150		//	s.uploadform.target = '_blank';
151		
152			if (s.uploadform.encoding) {
153				// IE does not respect property enctype for HTML forms.
154				// Instead use property encoding.
155				s.uploadform.encoding = 'multipart/form-data';
156			} else {
157				s.uploadform.enctype = 'multipart/form-data';
158			}
159
160			if (window.attachEvent) {
161				io.attachEvent('onload', uploadCallback);
162			} else {
163				io.addEventListener('load', uploadCallback, false);
164			}
165			
166			s.uploadform.submit();
167
168		} catch (e) {
169			jQuery.handleError(s, xml, null, e);
170		}
171
172		return {
173			abort: function () {}
174		};
175
176	},
177
178	uploadHttpData: function (r, type) {
179		var data = !type;
180		data = type == "xml" || data ? r.responseXML : r.responseText;
181
182		// If the type is "script", eval it in global context
183		if ( type == "script" )    jQuery.globalEval( data );     // only for jquery 1.1...
184
185		// Get the JavaScript object, if JSON is used.
186		if ( type == "json" )      eval( "data = " + data );     // only for jquery 1.1...
187
188		// evaluate scripts within html
189		if ( type == "html" )        jQuery("<div>").html(data);  // only for jquery 1.1...
190
191		return data;
192	}
193});

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.