This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 127
/
filesaver.min.js
4 lines (4 loc) · 5 KB
/
filesaver.min.js
1
2
3
4
/*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
if(!(typeof Blob==="function"||typeof Blob==="object")||typeof URL==="undefined"){if((typeof Blob==="function"||typeof Blob==="object")&&typeof webkitURL!=="undefined"){self.URL=webkitURL}else{var Blob=(function(a){var b=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder||(function(o){var f=function(x){return Object.prototype.toString.call(x).match(/^\[object\s(.*)\]$/)[1]},w=function l(){this.data=[]},v=function h(z,x,y){this.data=z;this.size=z.length;this.type=x;this.encoding=y},p=w.prototype,u=v.prototype,r=o.FileReaderSync,d=function(x){this.code=this[this.name=x]},q=("NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR").split(" "),t=q.length,k=o.URL||o.webkitURL||o,s=k.createObjectURL,e=k.revokeObjectURL,j=k,n=o.btoa,i=o.atob,g=o.ArrayBuffer,m=o.Uint8Array;v.fake=u.fake=true;while(t--){d.prototype[q[t]]=t+1}if(!k.createObjectURL){j=o.URL={}}j.createObjectURL=function(y){var z=y.type,x;if(z===null){z="application/octet-stream"}if(y instanceof v){x="data:"+z;if(y.encoding==="base64"){return x+";base64,"+y.data}else{if(y.encoding==="URI"){return x+","+decodeURIComponent(y.data)}}if(n){return x+";base64,"+n(y.data)}else{return x+","+encodeURIComponent(y.data)}}else{if(s){return s.call(k,y)}}};j.revokeObjectURL=function(x){if(x.substring(0,5)!=="data:"&&e){e.call(k,x)}};p.append=function(B){var D=this.data;if(m&&(B instanceof g||B instanceof m)){var C="",y=new m(B),z=0,A=y.length;for(;z<A;z++){C+=String.fromCharCode(y[z])}D.push(C)}else{if(f(B)==="Blob"||f(B)==="File"){if(r){var x=new r;D.push(x.readAsBinaryString(B))}else{throw new d("NOT_READABLE_ERR")}}else{if(B instanceof v){if(B.encoding==="base64"&&i){D.push(i(B.data))}else{if(B.encoding==="URI"){D.push(decodeURIComponent(B.data))}else{if(B.encoding==="raw"){D.push(B.data)}}}}else{if(typeof B!=="string"){B+=""}D.push(unescape(encodeURIComponent(B)))}}}};p.getBlob=function(x){if(!arguments.length){x=null}return new v(this.data.join(""),x,"raw")};p.toString=function(){return"[object BlobBuilder]"};u.slice=function(A,x,z){var y=arguments.length;if(y<3){z=null}return new v(this.data.slice(A,y>1?x:this.data.length),z,this.encoding)};u.toString=function(){return"[object Blob]"};return w}(a));return function c(g,f){var j=f?(f.type||""):"";var e=new b();if(g){for(var h=0,d=g.length;h<d;h++){e.append(g[h])}}return e.getBlob(j)}}(self))}
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
}var saveAs=saveAs||(navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator))||(function(i){var t=i.document,m=function(){return i.URL||i.webkitURL||i},f=i.URL||i.webkitURL||i,p=t.createElementNS("http://www.w3.org/1999/xhtml","a"),h=!i.externalHost&&"download" in p,k=function(u){var e=t.createEvent("MouseEvents");e.initMouseEvent("click",true,false,i,0,0,0,0,0,false,false,false,false,0,null);u.dispatchEvent(e)},q=i.webkitRequestFileSystem,r=i.requestFileSystem||q||i.mozRequestFileSystem,n=function(e){(i.setImmediate||i.setTimeout)(function(){throw e},0)},c="application/octet-stream",l=0,b=[],j=function(){var u=b.length;while(u--){var e=b[u];if(typeof e==="string"){f.revokeObjectURL(e)}else{e.remove()}}b.length=0},s=function(u,e,x){e=[].concat(e);var w=e.length;while(w--){var y=u["on"+e[w]];if(typeof y==="function"){try{y.call(u,x||u)}catch(v){n(v)}}}},g=function(u,v){var w=this,C=u.type,F=false,y,x,e=function(){var G=m().createObjectURL(u);b.push(G);return G},B=function(){s(w,"writestart progress write writeend".split(" "))},E=function(){if(F||!y){y=e(u)}if(x){x.location.href=y}else{window.open(y,"_blank")}w.readyState=w.DONE;B()},A=function(G){return function(){if(w.readyState!==w.DONE){return G.apply(this,arguments)}}},z={create:true,exclusive:false},D;w.readyState=w.INIT;if(!v){v="download"}if(h){y=e(u);p.href=y;p.download=v;k(p);w.readyState=w.DONE;B();return}if(i.chrome&&C&&C!==c){D=u.slice||u.webkitSlice;u=D.call(u,0,u.size,c);F=true}if(q&&v!=="download"){v+=".download"}if(C===c||q){x=i}if(!r){E();return}l+=u.size;r(i.TEMPORARY,l,A(function(G){G.root.getDirectory("saved",z,A(function(H){var I=function(){H.getFile(v,z,A(function(J){J.createWriter(A(function(K){K.onwriteend=function(L){x.location.href=J.toURL();b.push(J);w.readyState=w.DONE;s(w,"writeend",L)};K.onerror=function(){var L=K.error;if(L.code!==L.ABORT_ERR){E()}};"writestart progress write abort".split(" ").forEach(function(L){K["on"+L]=w["on"+L]});K.write(u);w.abort=function(){K.abort();w.readyState=w.DONE};w.readyState=w.WRITING}),E)}),E)};H.getFile(v,{create:false},A(function(J){J.remove();I()}),A(function(J){if(J.code===J.NOT_FOUND_ERR){I()}else{E()}}))}),E)}),E)},d=g.prototype,a=function(e,u){return new g(e,u)};d.abort=function(){var e=this;e.readyState=e.DONE;s(e,"abort")};d.readyState=d.INIT=0;d.WRITING=1;d.DONE=2;d.error=d.onwritestart=d.onprogress=d.onwrite=d.onabort=d.onerror=d.onwriteend=null;try{i.addEventListener("unload",j,false)}catch(o){}return a}(self));if(typeof module!=="undefined"){module.exports=saveAs};