• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/lighttpd-1.4.39/external_file/js/
1var global=this;
2global.uploadlib=new function(){var f=null,d=null,g=0,e=0,h=0,i=0,l=0,m=null,n=null;this.WebDAVUploadHandler=function(){f=this};this.WebDAVUploadHandler.prototype.initialize=function(b,a,c,j){d=a;m=c;n=j;f.url=b;f.webdav=new davlib.DavClient;f.webdav.initialize();for(b=e=l=i=h=e=g=0;b<d.length;b++)l+=d[b].thefile.size};this.WebDAVUploadHandler.prototype.uploadFile=function(){for(var b=0,a;a=d[b];b++)if(a.status=="Init"||a.status=="Upload"){var c=a.thefile.size;g=b;a.status="Upload";var b=e,j=b+5242880-
31;if(j>=c)j=c-1,a.status="end_send";e=j+1;f._putToWeb(a.thepath,a.thefile,b,j,c);return 1}return 0};this.WebDAVUploadHandler.prototype._putToWeb=function(b,a,c,d,g){try{var e=new FileReader,h=0;e.onloadend=function(e){if(e.target.readyState==FileReader.DONE){var i=f.url+encodeURIComponent(b)+encodeURIComponent(a.name);f.webdav.PUT(i,e.target.result,h,c,d,g,"T",f._complete_callbackfunction,f._progress_callbackfunction)}};if(a.webkitSlice){var k=a.webkitSlice(c,d+1);e.readAsArrayBuffer(k);h=1}else a.mozSlice?
4(k=a.mozSlice(c,d+1),e.readAsBinaryString(k),h=0):(k=a.slice(c,d+1),e.readAsArrayBuffer(k),h=1)}catch(i){alert(i.message)}};this.WebDAVUploadHandler.prototype._progress_callbackfunction=function(b){if(!(d.length<=0)&&b.lengthComputable){var a=d[g];if(!(a==null||a==void 0)){var c=0;b.loaded>0&&b.loaded/b.total==1&&(c=1);c==1&&(h+=5242880,i+=5242880);b=Math.min(100,100*(h/a.thefile.size));c=Math.min(100,100*(i/l));m&&m(a.id,a.thefile.name,a.status,b,c)}}};this.WebDAVUploadHandler.prototype._complete_callbackfunction=
5function(b){if(!(d.length<=0)){var a=d[g],c=!1;if(!(a==null||a==void 0)){if(b)if(b==200||b==201||b==204){if(d[g].status=="end_send")d[g].status="done",h=e=0}else d[g].status="UploadFail";f.uploadFile()==0&&(c=!0);n&&n(a.id,a.thefile.name,a.status,b,c)}}}};
6