1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

#17 - Detect images and display them as image files

This commit is contained in:
Rémy HUBSCHER 2013-01-19 12:37:39 +01:00
parent b2a9812688
commit 0879a8556e

View File

@ -379,11 +379,24 @@ window.zerobin = {
},
upload: function(files) {
var current_file = files[0];
var reader = new FileReader();
if(current_file.type.indexOf('image') == 0) {
reader.onload = function(event) {
$('#content').val(event.target.result).trigger('change');
$('#content').hide();
var img = $('<img/>');
$(img).attr('src', event.target.result);
$(img).css('max-width', '742px');
$('#content').after(img);
};
reader.readAsDataURL(current_file);
} else {
reader.onload = function(event) {
$('#content').val(event.target.result).trigger('change');
};
reader.readAsText(files[0]);
reader.readAsText(current_file);
}
}
};
@ -539,6 +552,13 @@ if (content && key) {
/* Decrypted content goes back to initial container*/
$('#paste-content').text(content);
if(content.indexOf('data:image') == 0) {
$('#paste-content').hide();
var img = $('<img/>');
$(img).attr('src', content);
$(img).css('max-width', '742px');
$('#paste-content').after(img);
}
bar.set('Code coloration...', '95%');
/* Add a continuation to let the UI redraw */