Removed self from cspheader
Refactored some variable names
This commit is contained in:
parent
faf596aeb7
commit
4cb0ce5114
|
@ -361,7 +361,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fr = new FileReader();
|
var fileReader = new FileReader();
|
||||||
if (file === undefined) {
|
if (file === undefined) {
|
||||||
file = controller.fileInput[0].files[0];
|
file = controller.fileInput[0].files[0];
|
||||||
$('#dragAndDropFileName').text('');
|
$('#dragAndDropFileName').text('');
|
||||||
|
@ -371,34 +371,34 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
|
|
||||||
attachmentHelpers.file = file;
|
attachmentHelpers.file = file;
|
||||||
|
|
||||||
fr.onload = function (e) {
|
fileReader.onload = function (event) {
|
||||||
var dataURL = e.target.result;
|
var dataURL = event.target.result;
|
||||||
attachmentHelpers.attachmentData = dataURL;
|
attachmentHelpers.attachmentData = dataURL;
|
||||||
|
|
||||||
if (controller.messagePreview.parent().hasClass('active')) {
|
if (controller.messagePreview.parent().hasClass('active')) {
|
||||||
attachmentHelpers.handleFilePreviews(controller.attachmentPreview, dataURL);
|
attachmentHelpers.handleFilePreviews(controller.attachmentPreview, dataURL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fr.readAsDataURL(file);
|
fileReader.readAsDataURL(file);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the preview of files.
|
* Handle the preview of files.
|
||||||
* @argument {DOM Element} element where the preview should be appended.
|
* @argument {DOM Element} targetElement where the preview should be appended.
|
||||||
* @argument {File Data} data of the file to be displayed.
|
* @argument {File Data} data of the file to be displayed.
|
||||||
*/
|
*/
|
||||||
handleFilePreviews: function (element, data) {
|
handleFilePreviews: function (targetElement, data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
var mimeType = this.getMimeTypeFromDataURL(data);
|
var mimeType = this.getMimeTypeFromDataURL(data);
|
||||||
|
|
||||||
if (mimeType.match(/image\//i)) {
|
if (mimeType.match(/image\//i)) {
|
||||||
this.showImagePreview(element, data);
|
this.showImagePreview(targetElement, data);
|
||||||
} else if (mimeType.match(/video\//i)) {
|
} else if (mimeType.match(/video\//i)) {
|
||||||
this.showVideoPreview(element, data, mimeType);
|
this.showVideoPreview(targetElement, data, mimeType);
|
||||||
} else if (mimeType.match(/audio\//i)) {
|
} else if (mimeType.match(/audio\//i)) {
|
||||||
this.showAudioPreview(element, data, mimeType);
|
this.showAudioPreview(targetElement, data, mimeType);
|
||||||
} else if (mimeType.match(/\/pdf/i)) {
|
} else if (mimeType.match(/\/pdf/i)) {
|
||||||
this.showPDFPreview(element, data);
|
this.showPDFPreview(targetElement, data);
|
||||||
}
|
}
|
||||||
//else {
|
//else {
|
||||||
//console.log("file but no image/video/audio/pdf");
|
//console.log("file but no image/video/audio/pdf");
|
||||||
|
@ -416,16 +416,16 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
return dataURL.slice(dataURL.indexOf('data:') + 5, dataURL.indexOf(';base64,'));
|
return dataURL.slice(dataURL.indexOf('data:') + 5, dataURL.indexOf(';base64,'));
|
||||||
},
|
},
|
||||||
|
|
||||||
showImagePreview: function (element, image) {
|
showImagePreview: function (targetElement, image) {
|
||||||
element.html(
|
targetElement.html(
|
||||||
$(document.createElement('img'))
|
$(document.createElement('img'))
|
||||||
.attr('src', image)
|
.attr('src', image)
|
||||||
.attr('class', 'img-thumbnail')
|
.attr('class', 'img-thumbnail')
|
||||||
);
|
);
|
||||||
element.removeClass('hidden');
|
targetElement.removeClass('hidden');
|
||||||
},
|
},
|
||||||
|
|
||||||
showVideoPreview: function (element, video, mimeType) {
|
showVideoPreview: function (targetElement, video, mimeType) {
|
||||||
var videoPlayer = $(document.createElement('video'))
|
var videoPlayer = $(document.createElement('video'))
|
||||||
.attr('controls', 'true')
|
.attr('controls', 'true')
|
||||||
.attr('autoplay', 'true')
|
.attr('autoplay', 'true')
|
||||||
|
@ -435,11 +435,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
videoPlayer.append($(document.createElement('source'))
|
videoPlayer.append($(document.createElement('source'))
|
||||||
.attr('type', mimeType)
|
.attr('type', mimeType)
|
||||||
.attr('src', video));
|
.attr('src', video));
|
||||||
element.html(videoPlayer);
|
targetElement.html(videoPlayer);
|
||||||
element.removeClass('hidden');
|
targetElement.removeClass('hidden');
|
||||||
},
|
},
|
||||||
|
|
||||||
showAudioPreview: function (element, audio, mimeType) {
|
showAudioPreview: function (targetElement, audio, mimeType) {
|
||||||
var audioPlayer = $(document.createElement('audio'))
|
var audioPlayer = $(document.createElement('audio'))
|
||||||
.attr('controls', 'true')
|
.attr('controls', 'true')
|
||||||
.attr('autoplay', 'true');
|
.attr('autoplay', 'true');
|
||||||
|
@ -447,11 +447,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
audioPlayer.append($(document.createElement('source'))
|
audioPlayer.append($(document.createElement('source'))
|
||||||
.attr('type', mimeType)
|
.attr('type', mimeType)
|
||||||
.attr('src', audio));
|
.attr('src', audio));
|
||||||
element.html(audioPlayer);
|
targetElement.html(audioPlayer);
|
||||||
element.removeClass('hidden');
|
targetElement.removeClass('hidden');
|
||||||
},
|
},
|
||||||
|
|
||||||
showPDFPreview: function (element, pdf) {
|
showPDFPreview: function (targetElement, pdf) {
|
||||||
//PDFs are only displayed if the filesize is smaller than about 1MB (after base64 encoding).
|
//PDFs are only displayed if the filesize is smaller than about 1MB (after base64 encoding).
|
||||||
//Bigger filesizes currently cause crashes in various browsers.
|
//Bigger filesizes currently cause crashes in various browsers.
|
||||||
//See also: https://code.google.com/p/chromium/issues/detail?id=69227
|
//See also: https://code.google.com/p/chromium/issues/detail?id=69227
|
||||||
|
@ -463,14 +463,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
//Fallback for browsers, that don't support the vh unit
|
//Fallback for browsers, that don't support the vh unit
|
||||||
var clientHeight = $(window).height();
|
var clientHeight = $(window).height();
|
||||||
|
|
||||||
element.html(
|
targetElement.html(
|
||||||
$(document.createElement('embed'))
|
$(document.createElement('embed'))
|
||||||
.attr('src', pdf)
|
.attr('src', pdf)
|
||||||
.attr('type', 'application/pdf')
|
.attr('type', 'application/pdf')
|
||||||
.attr('class', 'pdfPreview')
|
.attr('class', 'pdfPreview')
|
||||||
.css('height', clientHeight)
|
.css('height', clientHeight)
|
||||||
);
|
);
|
||||||
element.removeClass('hidden');
|
targetElement.removeClass('hidden');
|
||||||
} else {
|
} else {
|
||||||
controller.showError(i18n._('File too large, to display a preview. Please download the attachment.'));
|
controller.showError(i18n._('File too large, to display a preview. Please download the attachment.'));
|
||||||
}
|
}
|
||||||
|
@ -483,17 +483,17 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ignoreDragDrop(e) {
|
function ignoreDragDrop(event) {
|
||||||
e.stopPropagation();
|
event.stopPropagation();
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop(e) {
|
function drop(event) {
|
||||||
e.stopPropagation();
|
event.stopPropagation();
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (fileInput) {
|
if (fileInput) {
|
||||||
var file = e.dataTransfer.files[0];
|
var file = event.dataTransfer.files[0];
|
||||||
//Clear the file input:
|
//Clear the file input:
|
||||||
fileInput.wrap('<form>').closest('form').get(0).reset();
|
fileInput.wrap('<form>').closest('form').get(0).reset();
|
||||||
fileInput.unwrap();
|
fileInput.unwrap();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Configuration
|
||||||
'languagedefault' => '',
|
'languagedefault' => '',
|
||||||
'urlshortener' => '',
|
'urlshortener' => '',
|
||||||
'icon' => 'identicon',
|
'icon' => 'identicon',
|
||||||
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; media-src \'self\' data:; object-src \'self\' data:; Referrer-Policy: \'no-referrer\'',
|
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; media-src data:; object-src data:; Referrer-Policy: \'no-referrer\'',
|
||||||
'zerobincompatibility' => false,
|
'zerobincompatibility' => false,
|
||||||
),
|
),
|
||||||
'expire' => array(
|
'expire' => array(
|
||||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-/n0xL/OCmeki+nYzqkpLjJNaoEcEBR3cVxvjXF9ESuqVuD81WpicSm2ZF/bHA+pjNuC0QzMBzsKaQwBI96/6JA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-/5orRNmbpvxqudg675a1LiF3wQ5DlMGoT6jI/iXDZN2x2DrLHnB3tSE0wGY6qpeY+eX9vv6mZ/6AuPm0gnU2/A==" 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]-->
|
||||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-/n0xL/OCmeki+nYzqkpLjJNaoEcEBR3cVxvjXF9ESuqVuD81WpicSm2ZF/bHA+pjNuC0QzMBzsKaQwBI96/6JA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-/5orRNmbpvxqudg675a1LiF3wQ5DlMGoT6jI/iXDZN2x2DrLHnB3tSE0wGY6qpeY+eX9vv6mZ/6AuPm0gnU2/A==" 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