diff --git a/4chan_x.user.js b/4chan_x.user.js
index f8876e1a2..c51e00546 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -1286,7 +1286,7 @@
} else if (-1 === qr.mimeTypes.indexOf(file.type)) {
qr.error('Unsupported file type.');
} else {
-
+ qr.selected.setFile(file);
}
return;
}
@@ -1300,8 +1300,8 @@
qr.error("" + file.name + ": Unsupported file type.");
break;
}
- if (qr.replies.length === 1 && !qr.replies[0].file) {
- qr.replies[0].setFile(file);
+ if (!qr.replies[qr.replies.length - 1].file) {
+ qr.replies[qr.replies.length - 1].setFile(file);
} else {
new qr.reply(file);
}
@@ -1316,9 +1316,7 @@
_this = this;
_ref = (previous = qr.replies[qr.replies.length - 1]) ? [previous.name, /^sage$/.test(previous.email) ? null : previous.email, conf['Remember Subject'] ? previous.sub : null] : [$.get("qr_name", null), $.get("qr_email", null), conf['Remember Subject'] ? $.get("qr_sub", null) : null], this.name = _ref[0], this.email = _ref[1], this.sub = _ref[2];
this.com = null;
- this.el = $.el('li', {
- textContent: 'no file'
- });
+ this.el = $.el('li');
$.on(this.el, 'click', function() {
return _this.select();
});
@@ -1328,8 +1326,19 @@
}
_Class.prototype.setFile = function(file) {
+ var reader,
+ _this = this;
this.file = file;
- return this.el.textContent = this.file.fileName;
+ this.el.title = file.name;
+ if (file.type === 'application/pdf') {
+ this.el.style.backgroundImage = null;
+ return;
+ }
+ reader = new FileReader();
+ reader.onload = function(e) {
+ return _this.el.style.backgroundImage = "url(" + e.target.result + ")";
+ };
+ return reader.readAsDataURL(file);
};
_Class.prototype.select = function() {
@@ -1373,7 +1382,7 @@
}
});
qr.mimeTypes = mimeTypes.split(', ');
- qr.el = ui.dialog('qr', 'top:0;right:0;', "
");
+ qr.el = ui.dialog('qr', 'top:0;right:0;', "");
if (!g.REPLY) {
$.on($('select', qr.el), 'mousedown', function(e) {
return e.stopPropagation();
diff --git a/script.coffee b/script.coffee
index 352802f6d..2b2308bd6 100644
--- a/script.coffee
+++ b/script.coffee
@@ -953,8 +953,7 @@ qr =
else if -1 is qr.mimeTypes.indexOf file.type
qr.error 'Unsupported file type.'
else
- # set or modify selected reply's file
- # qr.replies[?].setFile file
+ qr.selected.setFile file
return
for file in @files
if file.size > @max
@@ -963,9 +962,9 @@ qr =
else if -1 is qr.mimeTypes.indexOf file.type
qr.error "#{file.name}: Unsupported file type."
break
- if qr.replies.length is 1 and not qr.replies[0].file
- # set initial reply's file
- qr.replies[0].setFile file
+ unless qr.replies[qr.replies.length - 1].file
+ # set last reply's file
+ qr.replies[qr.replies.length - 1].setFile file
else
new qr.reply file
$.addClass qr.el, 'dump'
@@ -987,15 +986,20 @@ qr =
if conf['Remember Subject'] then $.get("qr_sub", null) else null
]
@com = null
- @el = $.el 'li',
- textContent: 'no file'
+ @el = $.el 'li'
$.on @el, 'click', => @select()
@setFile file if file
$.before $('#addReply', qr.el), @el
qr.replies.push @
setFile: (@file) ->
- # update UI
- @el.textContent = @file.fileName
+ @el.title = file.name
+ if file.type is 'application/pdf'
+ @el.style.backgroundImage = null
+ return
+ reader = new FileReader()
+ reader.onload = (e) =>
+ @el.style.backgroundImage = "url(#{e.target.result})"
+ reader.readAsDataURL file
select: ->
qr.selected?.el.id = null
qr.selected = @
@@ -1005,7 +1009,6 @@ qr =
rm: ->
# rm reply from qr.replies and the UI
-
dialog: ->
# create a new thread or select thread to reply to
unless g.REPLY
@@ -1083,13 +1086,16 @@ qr =
}
#replies > ol > li {
background-color: rgba(0,0,0,.5);
+ background-position: 50% 20%;
+ background-size: cover;
border: 1px solid #000;
box-sizing: border-box;
color: #FFF;
+ cursor: pointer;
display: inline-block;
- height: 80px; width: 80px;
- margin:10px; padding: 2px;
- opacity: .8;
+ height: 90px; width: 90px;
+ margin: 5px; padding: 2px;
+ opacity: .5;
text-shadow: 0 1px 1px #000;
-webkit-transition: opacity .25s;
-moz-transition: opacity .25s;