NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
/* FileSaver.js * A saveAs() FileSaver implementation. * 2014-05-27 * * By Eli Grey, http://eligrey.com * License: X11/MIT * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md */ var saveAs=saveAs||"undefined"!==typeof navigator&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator)||function(a){if("undefined"===typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var l=a.document,q=l.createElementNS("http://www.w3.org/1999/xhtml","a"),x=!a.externalHost&&"download"in q,y=function(c){var b=l.createEvent("MouseEvents");b.initMouseEvent("click",!0,!1,a,0,0,0,0,0,!1,!1,!1,!1,0,null);c.dispatchEvent(b)},s=a.webkitRequestFileSystem,v=a.requestFileSystem|| s||a.mozRequestFileSystem,z=function(c){(a.setImmediate||a.setTimeout)(function(){throw c;},0)},t=0,m=[],h=function(){for(var c=m.length;c--;){var b=m[c];"string"===typeof b?(a.URL||a.webkitURL||a).revokeObjectURL(b):b.remove()}m.length=0},u=function(c,b,e){b=[].concat(b);for(var a=b.length;a--;){var d=c["on"+b[a]];if("function"===typeof d)try{d.call(c,e||c)}catch(f){z(f)}}},n=function(c,b){var e=this,d=c.type,h=!1,f,r,l=function(){var b=(a.URL||a.webkitURL||a).createObjectURL(c);m.push(b);return b}, n=function(){u(e,["writestart","progress","write","writeend"])},g=function(){if(h||!f)f=l(c);r?r.location.href=f:window.open(f,"_blank");e.readyState=e.DONE;n()},k=function(b){return function(){if(e.readyState!==e.DONE)return b.apply(this,arguments)}},p={create:!0,exclusive:!1},w;e.readyState=e.INIT;b||(b="download");if(x)f=l(c),q.href=f,q.download=b,y(q),e.readyState=e.DONE,n();else{a.chrome&&d&&"application/octet-stream"!==d&&(w=c.slice||c.webkitSlice,c=w.call(c,0,c.size,"application/octet-stream"), h=!0);s&&"download"!==b&&(b+=".download");if("application/octet-stream"===d||s)r=a;v?(t+=c.size,v(a.TEMPORARY,t,k(function(a){a.root.getDirectory("saved",p,k(function(a){var d=function(){a.getFile(b,p,k(function(a){a.createWriter(k(function(b){b.onwriteend=function(b){r.location.href=a.toURL();m.push(a);e.readyState=e.DONE;u(e,"writeend",b)};b.onerror=function(){var a=b.error;a.code!==a.ABORT_ERR&&g()};["writestart","progress","write","abort"].forEach(function(a){b["on"+a]=e["on"+a]});b.write(c); e.abort=function(){b.abort();e.readyState=e.DONE};e.readyState=e.WRITING}),g)}),g)};a.getFile(b,{create:!1},k(function(a){a.remove();d()}),k(function(a){a.code===a.NOT_FOUND_ERR?d():g()}))}),g)}),g)):g()}},d=n.prototype,p=function(a,b){return new n(a,b)};d.abort=function(){this.readyState=this.DONE;u(this,"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;a.addEventListener("unload",h,!1);p.unload=function(){h(); a.removeEventListener("unload",h,!1)};return p}}("undefined"!==typeof self&&self||"undefined"!==typeof window&&window||this.content);"undefined"!==typeof module&&null!==module?module.exports=saveAs:"undefined"!==typeof define&&null!==define&&null!=define.amd&&define([],function(){return saveAs});