2017-12-25 07:32:34 +01:00
|
|
|
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=e.webkitRequestFileSystem,a=e.requestFileSystem||i||e.mozRequestFileSystem,c="application/octet-stream",f=0,s=function(t){var o=function(){"string"==typeof t?n().revokeObjectURL(t):t.remove()};e.chrome?o():setTimeout(o,500)},u=function(t,n,o){for(var r=(n=[].concat(n)).length;r--;){var i=t["on"+n[r]];if("function"==typeof i)try{i.call(t,o||t)}catch(t){a=t,(e.setImmediate||e.setTimeout)(function(){throw a},0)}}var a},d=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},l=function(l,p){var v,w,y,m=this,h=(l=d(l)).type,S=!1,O=function(){u(m,"writestart progress write writeend".split(" "))},E=function(){if(!S&&v||(v=n().createObjectURL(l)),w)w.location.href=v;else{void 0==e.open(v,"_blank")&&"undefined"!=typeof safari&&(e.location.href=v)}m.readyState=m.DONE,O(),s(v)},R=function(e){return function(){if(m.readyState!==m.DONE)return e.apply(this,arguments)}},b={create:!0,exclusive:!1};if(m.readyState=m.INIT,p||(p="download"),r)return v=n().createObjectURL(l),o.href=v,o.download=p,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)}(o),m.readyState=m.DONE,O(),void s(v);e.chrome&&h&&h!==c&&(y=l.slice||l.webkitSlice,l=y.call(l,0,l.size,c),S=!0),i&&"download"!==p&&(p+=".download"),(h===c||i)&&(w=e),a?(f+=l.size,a(e.TEMPORARY,f,R(function(e){e.root.getDirectory("saved",b,R(function(e){var t=function(){e.getFile(p,b,R(function(e){e.createWriter(R(function(t){t.onwriteend=function(t){w.location.href=e.toURL(),m.readyState=m.DONE,u(m,"writeend",t),s(e)},t.onerror=function(){var e=t.error;e.code!==e.ABORT_ERR&&E()},"writestart progress write abort".split(" ").forEach(function(e){t["on"+e]=m["on"+e]}),t.write(l),m.abort=function(){t.abort(),m.readyState=m.DONE},m.readyState=m.WRITING}),E)}),E)};e.getFile(p,{create:!1},R(function(e){e.remove(),t()}),R(function(e){e.code===e.NOT_FOUND_ERR?t():E()}))}),E)}),E)):E()},p=l.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t){return navigator.msSaveOrOpenBlob(d(e),t)}:(p.abort=function(){this.readyState=this.DONE,u(this,"abort")},p.readyState=p.INIT=0,p.WRITING=1,p.DONE=2,p.error=p.onwritestart=p.onprogress=p.onwrite=p.onabort=p.onerror=p.onwriteend=null,function(e,t){return new l(e,t)})}}("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});
|