// JavaScript Document
jQuery.extend({
createUploadIframe:function(id,uri)
{
//create frame
varframeId='jUploadFrame'+id;
if(window.ActiveXObject)//var io = document.createElement('');
(jQuery.browser.version=="9.0"||jQuery"10.0"){
vario=document.createElement('iframe');
io.id=frameId;
io.name;
}else"6.0""7.0""8.0"'');
(typeofuri=='boolean'){
io.src'javascript:false';
}
'string'=uri}
else{
);
io;
io}
io.style.position'absolute'.top'-1000px'.left;
document.body.appendChild(io);
returnio},
createUploadFormfileElementIddata//create form
varformId'jUploadForm';
varfileId'jUploadFile'varform=jQuery'
'varoldElement'#'+fileElementId);varnewElement(oldElement).clone();
jQuery).attr'id'fileId);
jQuery).before(newElement).appendTo(form);
//add data
(data{
forvariindata{
$'
}
varrequestDone=false;
// Create the request object
varxml={};
){
jQuery"ajaxSend"[xml]);
}
varuploadCallback(isTimeout){
// Wait for a response to come back
.getElementById(frameIdtry.contentWindow){
xml.responseText=io.document?io.innerHTML:null;
xml.responseXMLXMLDocument:io.contentDocumentcatch(e.handleErrorxmle(xml||isTimeout"timeout"){
requestDonetruevarstatustry{
status=isTimeout!="timeout"?"success":"error"// Make sure that the request was successful or notmodified
(status"error"// process the data (runs the xml through httpData regardless of callback)
vardata.uploadHttpData(xml.dataType.success// ifa local callback was specified,fire it and pass it the data
s.success(datastatus};
// Fire the global callback
jQuery"ajaxSuccess"};
}else{
jQuerystatus}
){
status;
jQuery// The request was completed
jQuery"ajaxComplete"};
// Handle the global AJAX counter
!--jQuery"ajaxStop"};
.complete){
s(xml};
jQuery).unbind();
setTimeout(){
).remove();
}},100);
xml};
// Timeout checker
.timeout>0){
setTimeout(){(!requestDone){uploadCallback);}},0)">.timeout+formId'action'.url'method''POST''target'frameId.encoding){
form.encoding'multipart/form-data'{
form.enctype}
jQuery).submit();
){
jQuery/*if(window.attachEvent){
document.getElementById(frameId).attachEvent('onload',uploadCallback);
}
else{
document.getElementById(frameId).addEventListener('load',uploadCallback,false);
} */
jQuery+frameId).load(uploadCallbackreturn{abortfunction(){}};
uploadHttpData(rtype!type;
data=type"xml"||data?r:r.responseText// ifthe type is "script",eval it in global context
(type"script".globalEval(data}
// Get the JavaScript object,ifJSON is used.
"json"){
data=r;
varstart=data.indexOf">"(start!=-1varend"
data.substringendeval"data = "// evaluate scripts within html
"html""
}
returndata/*handleError: function( s,xml,status,e ) {
// If a local callback was specified,fire it
if ( s.error )
s.error( xml,e );
// Fire the global callback
if ( s.global )
jQuery.event.trigger( "ajaxError",[xml,s,e] );
}*/
handleErrorxhre// If a local callback was specified,fire it
if.error{
s.error.call.context||s// Fire the global callback
{
?jQuery.context:jQuery).trigger"ajaxError"[xhr}
});