Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ <h2>Open Snapdrop on other devices to send files</h2>
<h3>File Received</h3>
<div class="font-subheading" id="fileName">Filename</div>
<div class="font-body2" id="fileSize"></div>
<div class='preview' style="visibility: hidden;">
<img id='img-preview' src="">
</div>
<div class='preview' style="visibility: hidden;"></div>
<div class="row">
<label for="autoDownload" class="grow">Ask to save each file before downloading</label>
<input type="checkbox" id="autoDownload" checked="">
Expand Down
26 changes: 20 additions & 6 deletions client/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class ReceiveDialog extends Dialog {
window.blop.play();
});
this._filesQueue = [];
this.$previewBox = this.$el.querySelector('.preview')
}

_nextFile(nextFile) {
Expand Down Expand Up @@ -266,10 +267,23 @@ class ReceiveDialog extends Dialog {
$a.click()
return
}
if(file.mime.split('/')[0] === 'image'){
console.log('the file is image');
this.$el.querySelector('.preview').style.visibility = 'inherit';
this.$el.querySelector("#img-preview").src = url;

let mime = file.mime.split('/')[0]
let previewElement = {
image: 'img',
audio: 'audio',
video: 'video'
}

if(Object.keys(previewElement).indexOf(mime) !== -1){
console.log('the file is able to preview');
let element = document.createElement(previewElement[mime]);
element.src = url;
element.controls = true;
element.classList = 'element-preview'

this.$previewBox.style.visibility = 'inherit';
this.$previewBox.appendChild(element)
}

this.$el.querySelector('#fileName').textContent = file.name;
Expand Down Expand Up @@ -297,8 +311,8 @@ class ReceiveDialog extends Dialog {
}

hide() {
this.$el.querySelector('.preview').style.visibility = 'hidden';
this.$el.querySelector("#img-preview").src = "";
this.$previewBox.style.visibility = 'hidden';
this.$previewBox.innerHTML = '';
super.hide();
this._dequeueFile();
}
Expand Down
5 changes: 3 additions & 2 deletions client/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,9 @@ x-dialog x-paper {
color: var(--text-color);
background-color: var(--bg-color-secondary);
}
/* Image Preview */
#img-preview{
/* Image/Video/Audio Preview */
.element-preview {
max-width: 100%;
max-height: 50vh;
margin: auto;
display: block;
Expand Down