2017-03-25 06:31:35 +01:00
|
|
|
var saveAs=saveAs||function(a){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=b.createElementNS("http://www.w3.org/1999/xhtml","a"),e="download"in d,f=function(c){var d=b.createEvent("MouseEvents");d.initMouseEvent("click",!0,!1,a,0,0,0,0,0,!1,!1,!1,!1,0,null),c.dispatchEvent(d)},g=a.webkitRequestFileSystem,h=a.requestFileSystem||g||a.mozRequestFileSystem,i=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},j=0,k=function(b){var d=function(){"string"==typeof b?c().revokeObjectURL(b):b.remove()};a.chrome?d():setTimeout(d,500)},l=function(a,b,c){b=[].concat(b);for(var d=b.length;d--;){var e=a["on"+b[d]];if("function"==typeof e)try{e.call(a,c||a)}catch(a){i(a)}}},m=function(a){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\ufeff",a],{type:a.type}):a},n=function(b,i){b=m(b);var n,o,p,q=this,r=b.type,s=!1,t=function(){l(q,"writestart progress write writeend".split(" "))},u=function(){if(!s&&n||(n=c().createObjectURL(b)),o)o.location.href=n;else{void 0==a.open(n,"_blank")&&"undefined"!=typeof safari&&(a.location.href=n)}q.readyState=q.DONE,t(),k(n)},v=function(a){return function(){if(q.readyState!==q.DONE)return a.apply(this,arguments)}},w={create:!0,exclusive:!1};return q.readyState=q.INIT,i||(i="download"),e?(n=c().createObjectURL(b),d.href=n,d.download=i,f(d),q.readyState=q.DONE,t(),void k(n)):(a.chrome&&r&&"application/octet-stream"!==r&&(p=b.slice||b.webkitSlice,b=p.call(b,0,b.size,"application/octet-stream"),s=!0),g&&"download"!==i&&(i+=".download"),("application/octet-stream"===r||g)&&(o=a),h?(j+=b.size,void h(a.TEMPORARY,j,v(function(a){a.root.getDirectory("saved",w,v(function(a){var c=function(){a.getFile(i,w,v(function(a){a.createWriter(v(function(c){c.onwriteend=function(b){o.location.href=a.toURL(),q.readyState=q.DONE,l(q,"writeend",b),k(a)},c.onerror=function(){var a=c.error;a.code!==a.ABORT_ERR&&u()},"writestart progress write abort".split(" ").forEach(function(a){c["on"+a]=q["on"+a]}),c.write(b),q.abort=function(){c.abort(),q.readyState=q.DONE},q.readyState=q.WRITING}),u)}),u)};a.getFile(i,{create:!1},v(function(a){a.remove(),c()}),v(function(a){a.code===a.NOT_FOUND_ERR?c():u()}))}),u)}),u)):void u())},o=n.prototype,p=function(a,b){return new n(a,b)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(a,b){return navigator.msSaveOrOpenBlob(m(a),b)}:(o.abort=function(){var a=this;a.readyState=a.DONE,l(a,"abort")},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,p)}}("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});
|