filesbox/web/dist/js/FileSaver.min.js
2024-07-26 14:10:54 +08:00

2 lines
2.3 KiB
JavaScript

/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */var saveAs=saveAs||function(n){"use strict";if(!(typeof n=="undefined"||typeof navigator!="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent))){var h=n.document,c=function(){return n.URL||n.webkitURL||n},f=h.createElementNS("http://www.w3.org/1999/xhtml","a"),S="download"in f,g=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},O=/constructor/i.test(n.HTMLElement)||n.safari,v=/CriOS\/[\d]+/.test(navigator.userAgent),b=function(e){(n.setImmediate||n.setTimeout)(function(){throw e},0)},I="application/octet-stream",E=1e3*40,w=function(e){var t=function(){typeof e=="string"?c().revokeObjectURL(e):e.remove()};setTimeout(t,E)},N=function(e,t,a){t=[].concat(t);for(var r=t.length;r--;){var u=e["on"+t[r]];if(typeof u=="function")try{u.call(e,a||e)}catch(d){b(d)}}},m=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},y=function(e,t,a){a||(e=m(e));var r=this,u=e.type,d=u===I,i,l=function(){N(r,"writestart progress write writeend".split(" "))},T=function(){if((v||d&&O)&&n.FileReader){var s=new FileReader;s.onloadend=function(){var p=v?s.result:s.result.replace(/^data:[^;]*;/,"data:attachment/file;"),x=n.open(p,"_blank");x||(n.location.href=p),p=void 0,r.readyState=r.DONE,l()},s.readAsDataURL(e),r.readyState=r.INIT;return}if(i||(i=c().createObjectURL(e)),d)n.location.href=i;else{var L=n.open(i,"_blank");L||(n.location.href=i)}r.readyState=r.DONE,l(),w(i)};if(r.readyState=r.INIT,S){i=c().createObjectURL(e),setTimeout(function(){f.href=i,f.download=t,g(f),l(),w(i),r.readyState=r.DONE});return}T()},o=y.prototype,R=function(e,t,a){return new y(e,t||e.name||"download",a)};return typeof navigator!="undefined"&&navigator.msSaveOrOpenBlob?function(e,t,a){return t=t||e.name||"download",a||(e=m(e)),navigator.msSaveOrOpenBlob(e,t)}:(o.abort=function(){},o.readyState=o.INIT=0,o.WRITING=1,o.DONE=2,o.error=o.onwritestart=o.onprogress=o.onwrite=o.onabort=o.onerror=o.onwriteend=null,R)}}(typeof self!="undefined"&&self||typeof window!="undefined"&&window||this.content);typeof module!="undefined"&&module.exports?module.exports.saveAs=saveAs:typeof define!="undefined"&&define!==null&&define.amd!==null&&define("FileSaver.js",function(){return saveAs});