mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
Merge branch 'blob' of https://github.com/otaku/PrivateBin into otaku-blob
This commit is contained in:
commit
de4b96c5ed
|
@ -1925,7 +1925,37 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
||||||
{
|
{
|
||||||
var imagePrefix = 'data:image/';
|
var imagePrefix = 'data:image/';
|
||||||
|
|
||||||
|
// IE does not support setting a data URI on an a element
|
||||||
|
// Convert dataURI to a Blob and use msSaveBlob to download
|
||||||
|
if (window.Blob && navigator.msSaveBlob) {
|
||||||
|
$attachmentLink.off('click').on('click', function () {
|
||||||
|
// data URI format: data:[<mediaType>][;base64],<data>
|
||||||
|
|
||||||
|
// position in data URI string of where data begins
|
||||||
|
var base64Start = attachmentData.indexOf(',') + 1;
|
||||||
|
// position in data URI string of where mediaType ends
|
||||||
|
var mediaTypeEnd = attachmentData.indexOf(';');
|
||||||
|
|
||||||
|
// extract mediaType
|
||||||
|
var mediaType = attachmentData.substring(5, mediaTypeEnd);
|
||||||
|
// extract data and convert to binary
|
||||||
|
var decodedData = Base64.atob(attachmentData.substring(base64Start));
|
||||||
|
|
||||||
|
// Transform into a Blob
|
||||||
|
var decodedDataLength = decodedData.length;
|
||||||
|
var buf = new Uint8Array(decodedDataLength);
|
||||||
|
|
||||||
|
for (var i = 0; i < decodedDataLength; i++) {
|
||||||
|
buf[i] = decodedData.charCodeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
var blob = new window.Blob([ buf ], { type: mediaType });
|
||||||
|
navigator.msSaveBlob(blob, fileName);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
$attachmentLink.attr('href', attachmentData);
|
$attachmentLink.attr('href', attachmentData);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof fileName !== 'undefined') {
|
if (typeof fileName !== 'undefined') {
|
||||||
$attachmentLink.attr('download', fileName);
|
$attachmentLink.attr('download', fileName);
|
||||||
}
|
}
|
||||||
|
@ -1971,6 +2001,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
|
||||||
me.hideAttachmentPreview();
|
me.hideAttachmentPreview();
|
||||||
$attachmentLink.prop('href', '');
|
$attachmentLink.prop('href', '');
|
||||||
$attachmentLink.prop('download', '');
|
$attachmentLink.prop('download', '');
|
||||||
|
$attachmentLink.off('click');
|
||||||
$attachmentPreview.html('');
|
$attachmentPreview.html('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mfJhWCkoSbEobT+YpbhF2rN0cyEV27Z3ecHWgCSzl3CMywcRrd4oP/efgOfWXknJJpoqe8341j2hoXD7cSlQEQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-fJAdh2DQpns2TMhDmiohfNCQXpjX+f/KpRCiRnWI6hq0lOT/RRFc11+qJzGK5zNFjDvDhCMbMADKn4D03p9Uag==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -54,7 +54,7 @@ if ($QRCODE):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-mfJhWCkoSbEobT+YpbhF2rN0cyEV27Z3ecHWgCSzl3CMywcRrd4oP/efgOfWXknJJpoqe8341j2hoXD7cSlQEQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-fJAdh2DQpns2TMhDmiohfNCQXpjX+f/KpRCiRnWI6hq0lOT/RRFc11+qJzGK5zNFjDvDhCMbMADKn4D03p9Uag==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user