lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/bwr/file-saver.js/FileSaver.min.js
2020-10-10 10:03:55 +02:00

1 line
2.8 KiB
JavaScript

var saveAs=saveAs||function(w){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var y=w.document,v=function(){return w.URL||w.webkitURL||w},m=y.createElementNS("http://www.w3.org/1999/xhtml","a"),h="download"in m,S=w.webkitRequestFileSystem,O=w.requestFileSystem||S||w.mozRequestFileSystem,E="application/octet-stream",R=0,b=function(e){function t(){"string"==typeof e?v().revokeObjectURL(e):e.remove()}w.chrome?t():setTimeout(t,500)},g=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){!function(e){(w.setImmediate||w.setTimeout)(function(){throw e},0)}(e)}}},N=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},n=function(o,n){o=N(o);function e(){g(s,"writestart progress write writeend".split(" "))}function r(){!l&&t||(t=v().createObjectURL(o)),a?a.location.href=t:null==w.open(t,"_blank")&&"undefined"!=typeof safari&&(w.location.href=t),s.readyState=s.DONE,e(),b(t)}function i(e){return function(){if(s.readyState!==s.DONE)return e.apply(this,arguments)}}var t,a,c,f,u,s=this,d=o.type,l=!1,p={create:!0,exclusive:!1};if(s.readyState=s.INIT,n=n||"download",h)return t=v().createObjectURL(o),m.href=t,m.download=n,f=m,(u=y.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,w,0,0,0,0,0,!1,!1,!1,!1,0,null),f.dispatchEvent(u),s.readyState=s.DONE,e(),void b(t);w.chrome&&d&&d!==E&&(c=o.slice||o.webkitSlice,o=c.call(o,0,o.size,E),l=!0),S&&"download"!==n&&(n+=".download"),d!==E&&!S||(a=w),O?(R+=o.size,O(w.TEMPORARY,R,i(function(e){e.root.getDirectory("saved",p,i(function(e){function t(){e.getFile(n,p,i(function(n){n.createWriter(i(function(t){t.onwriteend=function(e){a.location.href=n.toURL(),s.readyState=s.DONE,g(s,"writeend",e),b(n)},t.onerror=function(){var e=t.error;e.code!==e.ABORT_ERR&&r()},"writestart progress write abort".split(" ").forEach(function(e){t["on"+e]=s["on"+e]}),t.write(o),s.abort=function(){t.abort(),s.readyState=s.DONE},s.readyState=s.WRITING}),r)}),r)}e.getFile(n,{create:!1},i(function(e){e.remove(),t()}),i(function(e){(e.code===e.NOT_FOUND_ERR?t:r)()}))}),r)}),r)):r()},e=n.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t){return navigator.msSaveOrOpenBlob(N(e),t)}:(e.abort=function(){this.readyState=this.DONE,g(this,"abort")},e.readyState=e.INIT=0,e.WRITING=1,e.DONE=2,e.error=e.onwritestart=e.onprogress=e.onwrite=e.onabort=e.onerror=e.onwriteend=null,function(e,t){return new n(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});