2 lines
2.9 KiB
JavaScript
2 lines
2.9 KiB
JavaScript
var saveAs=saveAs||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(n){var o=t.createEvent("MouseEvents");o.initMouseEvent("click",!0,!1,e,0,0,0,0,0,!1,!1,!1,!1,0,null),n.dispatchEvent(o)},a=e.webkitRequestFileSystem,c=e.requestFileSystem||a||e.mozRequestFileSystem,f=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},u=0,s=function(t){var o=function(){"string"==typeof t?n().revokeObjectURL(t):t.remove()};e.chrome?o():setTimeout(o,500)},d=function(e,t,n){for(var o=(t=[].concat(t)).length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(e){f(e)}}},l=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e},p=function(t,f){var p,v,w,y=this,m=(t=l(t)).type,S=!1,h=function(){d(y,"writestart progress write writeend".split(" "))},O=function(){!S&&p||(p=n().createObjectURL(t)),v?v.location.href=p:void 0==e.open(p,"_blank")&&"undefined"!=typeof safari&&(e.location.href=p),y.readyState=y.DONE,h(),s(p)},E=function(e){return function(){if(y.readyState!==y.DONE)return e.apply(this,arguments)}},R={create:!0,exclusive:!1};if(y.readyState=y.INIT,f||(f="download"),r)return p=n().createObjectURL(t),o.href=p,o.download=f,i(o),y.readyState=y.DONE,h(),void s(p);e.chrome&&m&&"application/octet-stream"!==m&&(w=t.slice||t.webkitSlice,t=w.call(t,0,t.size,"application/octet-stream"),S=!0),a&&"download"!==f&&(f+=".download"),("application/octet-stream"===m||a)&&(v=e),c?(u+=t.size,c(e.TEMPORARY,u,E(function(e){e.root.getDirectory("saved",R,E(function(e){var n=function(){e.getFile(f,R,E(function(e){e.createWriter(E(function(n){n.onwriteend=function(t){v.location.href=e.toURL(),y.readyState=y.DONE,d(y,"writeend",t),s(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&O()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=y["on"+e]}),n.write(t),y.abort=function(){n.abort(),y.readyState=y.DONE},y.readyState=y.WRITING}),O)}),O)};e.getFile(f,{create:!1},E(function(e){e.remove(),n()}),E(function(e){e.code===e.NOT_FOUND_ERR?n():O()}))}),O)}),O)):O()},v=p.prototype,w=function(e,t){return new p(e,t)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t){return navigator.msSaveOrOpenBlob(l(e),t)}:(v.abort=function(){var e=this;e.readyState=e.DONE,d(e,"abort")},v.readyState=v.INIT=0,v.WRITING=1,v.DONE=2,v.error=v.onwritestart=v.onprogress=v.onwrite=v.onabort=v.onerror=v.onwriteend=null,w)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!=define.amd&&define([],function(){return saveAs});
|
|
//# sourceMappingURL=FileSaver.min.js.map
|