text: /**
   * QUpload v0.1.2
   * 
   * @author qpwoeiru96 <qpwoeiru96@gmail.com>
   * @version  0.1.2 stable
   * @link  http://sou.la/blog
   */
  !function(a,b,c){function k(){}function l(b){var d=this,e=null,f=0,g=null,h={name:null,size:null,time:null,start:null,end:null,token:null};this.options=b,this.setFile=function(a){d.abort(),f=0,e=a,h={name:e.name,size:e.size,time:Math.ceil(e.lastModifiedDate.getTime()/1e3),start:null,end:null,token:null}},this.getFile=function(){return null!==e&&e instanceof File?e:(d.emit("error",["",301]),!1)},this.setInfo=function(a,b){h[a]=b},this.getInfo=function(a){return"undefined"==typeof a?h:h[a]},this.setXHR=function(a){g=a},this.getXHR=function(){return g},this.getStatus=function(){return+f},this.getTokenInfo=function(){if(null===d.getInfo("name"))return d.emit("error",["",301]),!1;var b={name:d.getInfo("name"),size:d.getInfo("size"),time:d.getInfo("time")};a.ajax({url:d.options.tokenUrl,type:"GET",data:b,dataType:"json",cache:!1}).fail(function(){d.emit("error",["",201])}).done(function(a){d.emit("fetchTokenComplete",[a])})},this.upload=function(){var f,g,b=d.getInfo("token"),e=d.getFile();return""===a.trim(b)?(d.emit("error",["",201]),!1):(f=a.ajaxSettings.xhr(),a(f.upload).bind("progress",function(a){d.emit("progress",[a.originalEvent.loaded,+d.getInfo("size")])}),g=a.param({token:b,start:0,end:d.getInfo("size")}),d.setXHR(f),a.ajax({url:[d.options.uploadUrl,g].join("?"),type:"POST",dataType:"json",data:e,processData:!1,contentType:e.type,xhr:function(){return f}}).fail(function(){d.emit("error",["",201])}).done(function(){d.emit("complete",[d.getInfo("token")])}),e=c,void 0)},this.multiChunkUpload=function(){var b,e,f,g,h,i,j,k;return 2===d.getStatus()?(d.emit("progress",[+d.getInfo("size"),+d.getInfo("size")]),d.emit("complete",[d.getInfo("token")]),void 0):(b=d.getInfo("start"),e=d.getInfo("end"),f=d.getInfo("token"),g=d.getFile(),""===a.trim(f)?(d.emit("error",["",201]),!1):(h=g.slice||g.webkitSlice||g.mozSlice,i=h.call(g,b,e,g.type),j=a.ajaxSettings.xhr(),a(j.upload).bind("progress",function(a){d.emit("progress",[+b+a.originalEvent.loaded,+d.getInfo("size")])}),k=a.param({token:f,start:b,end:e}),d.setXHR(j),a.ajax({url:[d.options.uploadUrl,k].join("?"),type:"POST",dataType:"json",data:i,processData:!1,contentType:i.type,xhr:function(){return j}}).fail(function(){d.emit("error",["",201])}).done(function(a){d.emit("uploadChunkFinished",[a])}),i=c,void 0))},this.addEventListener("fetchTokenComplete",function(a){var b=a.range.split("-");f=a.status,d.setInfo("token",a.token),d.setInfo("start",b[0]),d.setInfo("end",b[1]),this.multiChunkUpload()}),this.addEventListener("uploadChunkFinished",function(a){f=a.status;var b=a.range.split("-");d.setInfo("start",b[0]),d.setInfo("end",b[1]),2===d.getStatus()?d.emit("complete",[d.getInfo("token")]):d.multiChunkUpload()}),this.abort=function(){var a=d.getXHR();a&&a.abort()},this.reset=function(){this.abort(),e=null,f=0,g=null,h={name:null,size:null,time:null,start:null,end:null,token:null}}}function m(a,b){var c=function(){return document[b]||window[b]||document.getElementById(b)};this.upload=function(){c().upload()},this.abort=function(){c().abort()},this.reset=function(){c().reset()}}function o(b){var e,g,j,k,o,p,c=this;this.options=a.extend({tokenUrl:"token.php",uploadUrl:"upload.php",swfPath:"qupload.swf",maxFileSize:134217728,allowedExt:"gif|jpg|png|zip|rar",locale:"zh-cn"},b),this.id=f(),e=3,g=1,d?(j="QUpload_input_"+this.id,k=a("<form/>").attr("id",j).hide().appendTo(document.body).html('<input type="file" style="pointer: cursor;"/>'),k.find("input").on("change",function(){var a,b;this.files.length>0&&(a=this.files.item(0),b=a.name.split(".").pop(),-1===c.options.allowedExt.split("|").indexOf(b.toLowerCase())?(c.uploader.emit("error",[[c.options.allowedExt.split("|").join("/"),b].join("|"),101]),c.reset()):a.size>c.options.maxFileSize?(c.uploader.emit("error",[[h(c.options.maxFileSize),h(a.size)].join("|"),102]),c.reset()):(c.uploader.setFile(a),c.uploader.emit("select",[{name:a.name,size:a.size,time:Math.round(a.lastModifiedDate.getTime()/1e3)}])))}),this.uploader=new l(this.options,this.id)):(o="QUpload_flash_"+this.id,p=a("<div/>").attr("id",o).css({height:e,width:e,display:"block",opacity:1,background:"#000",cursor:"pointer",position:"absolute",top:0,left:0,overflow:"hidden",lineHeight:0,fontSize:0}).appendTo(document.body),i(this.options.swfPath,o,this.id,e,e,{flashProxyId:this.id,uploadUrl:this.options.uploadUrl,tokenUrl:this.options.tokenUrl,maxFileSize:this.options.maxFileSize,allowedExt:this.options.allowedExt}),this.uploader=new m(this.options,this.id),n.register(this.id,this.uploader)),this.inject=function(b){var c=d?k:p,e=a(b);d?e.on("click",function(){k.find("input").get(0).click()}):e.on("mousemove",function(a){c.css({top:a.pageY-g,left:a.pageX-g})})},this.upload=function(){d?this.uploader.getTokenInfo():this.uploader.upload()},this.reset=function(){d&&document.getElementById("QUpload_input_"+this.id).reset(),this.uploader.reset()},this.abort=function(){this.uploader.abort()},this.addEventListener=function(a,b){return-1!=="progress|error|complete|select".indexOf(a)?c.uploader.addEventListener(a,b):void 0},this.removeEventListener=function(a,b){return-1!=="progress|error|complete|select".indexOf(a)?c.uploader.removeEventListener(a,b):void 0}}var n,d=b.File&&b.File.prototype.slice&&b.XMLHttpRequest,e=!!b.ActiveXObject,f=function(){return"QU"+Math.round(2147483647*Math.random()+268435456).toString(16)},g=function(a,b){return a.replace(/\{\$([\w]+)\}/gi,function(a,c){return"undefined"!=typeof b[c]?b[c]:a})},h=function(a){return 1024>a?a.toString()+"B":1048576>a?(a/1024).toFixed(2).toString()+"KB":1073741824>a?(a/1048576).toFixed(2).toString()+"MB":(a/1073741824).toFixed(2).toString()+"GB"},i=function(b,c,d,f,h,i){var k,l,m,j=[];for(k in i)j.push(escape(k)+"="+escape(i[k]));l=(e?'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" height="{$height}" width="{$width}" name="{$id}" id="{$id}">':'<object type="application/x-shockwave-flash" data="{$swfPath}" height="{$height}" width="{$width}" name="{$id}" id="{$id}">')+'<param name="Movie" value="{$swfPath}" />'+'<param name="FlashVars" value="{$flashVars}" />'+'<param name="Swfversion" value="11.2.0" />'+'<param name="AllowScriptAccess" value="always"/>'+'<param name="Wmode" value="direct"/>'+'<param name="Loop" value="false"/>'+'<param name="AllowNetworking" value="all"/>'+'<param name="Src" value="{$swfPath}"/>'+"</object>",m=g(l,{swfPath:b,width:f,height:h,flashVars:j.join("&"),id:d}),a("#"+c).html(m)},j=function(){var a="zh-cn",b={"zh-cn":{101:"文件类型不符合需求, 所需: %s, 实际: %s。",102:"文件大小超过限制，最大大小: %s，实际大小: %s。",201:"服务器出错，上传失败，请重试。",301:"请先选择文件再进行上传。",302:"请等待初始化完成，已完成 %s%。"}},c=function(a,b){var c=0;return a.replace(/%s/gi,function(){return b[c++]})},d=function(d,e){var f=d.split("|");return c(b[a][e],f)};return{t:d}}();k.prototype.getEvents=function(){return"undefined"==typeof this.events&&(this.events={}),this.events},k.prototype.addEventListener=function(a,b){"undefined"==typeof this.getEvents()[a]?this.getEvents()[a]=[b]:this.getEvents()[a].push(b)},k.prototype.emit=function(a,b){var c,d;if("undefined"==typeof this.getEvents()[a])return!1;for(c=this.getEvents()[a],"error"===a.toLowerCase()&&(b[0]=j.t(b[0],b[1])),d=0;d<c.length;d++)c[d].apply(this,b)},k.prototype.removeEventListener=function(a,b){var c,d;if("undefined"==typeof this.getEvents()[a])return!0;for(c=this.getEvents()[a],d=0;d<c.length;d++)if(c[d]===b)return c[d]=c[c.length-1],c.pop(),!0;return!1},l.prototype=k.prototype,l.prototype.constructor=l,m.prototype=k.prototype,m.prototype.constructor=m,n={register:function(a,b){this[a]=b}},o.prototype={constructor:o,PROGRESS:"progress",ERROR:"error",COMPLETE:"complete",SELECT:"select"},o.FlashProxy=n,b.QUpload=o}(jQuery,window);