2018-01-15 16:01:25 +01:00
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2018-01-16 03:43:54 +01:00
|
|
|
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
2018-01-15 16:01:25 +01:00
|
|
|
navigator.userAgent.indexOf('Chrome') === -1;
|
|
|
|
|
2018-01-15 17:04:28 +01:00
|
|
|
if (!isSafari) {
|
|
|
|
return;
|
2018-01-15 16:01:25 +01:00
|
|
|
}
|
|
|
|
|
2018-01-15 17:04:28 +01:00
|
|
|
safari.self.addEventListener('message', (msgEvent: any) => {
|
|
|
|
doDownload(msgEvent.message);
|
|
|
|
}, false);
|
|
|
|
|
2018-01-15 16:01:25 +01:00
|
|
|
function doDownload(msg: any) {
|
|
|
|
if (msg.command === 'downloaderPageData' && msg.data) {
|
|
|
|
const blob = new Blob([msg.data.blobData], msg.data.blobOptions);
|
|
|
|
if (navigator.msSaveOrOpenBlob) {
|
|
|
|
navigator.msSaveBlob(blob, msg.data.fileName);
|
|
|
|
} else {
|
|
|
|
const a = document.createElement('a');
|
2018-01-15 16:13:02 +01:00
|
|
|
a.href = URL.createObjectURL(blob);
|
2018-01-15 16:01:25 +01:00
|
|
|
a.download = msg.data.fileName;
|
|
|
|
document.body.appendChild(a);
|
|
|
|
a.click();
|
|
|
|
document.body.removeChild(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-03 20:21:38 +01:00
|
|
|
window.setTimeout(() => window.close(), 1500);
|
2018-01-15 16:01:25 +01:00
|
|
|
}
|
|
|
|
});
|