diff --git a/4chan_x.user.js b/4chan_x.user.js index 063341774..6d185e176 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1331,19 +1331,17 @@ } _Class.prototype.setFile = function(file) { - var reader, - _this = this; + var url; this.file = file; this.el.title = file.name; if (file.type === 'application/pdf') { this.el.style.backgroundImage = null; return; } - reader = new FileReader(); - reader.onload = function() { - return _this.el.style.backgroundImage = "url(" + reader.result + ")"; - }; - return reader.readAsDataURL(file); + url = window.URL || window.webkitURL; + url.revokeObjectURL(this.url); + this.url = url.createObjectURL(file); + return this.el.style.backgroundImage = "url(" + this.url + ")"; }; _Class.prototype.select = function() { @@ -1360,7 +1358,11 @@ return _results; }; - _Class.prototype.rm = function() {}; + _Class.prototype.rm = function() { + var url; + url = window.URL || window.webkitURL; + return url.revokeObjectURL(this.url); + }; return _Class; diff --git a/script.coffee b/script.coffee index a8f7d9d44..355ec9ba6 100644 --- a/script.coffee +++ b/script.coffee @@ -1001,9 +1001,10 @@ qr = if file.type is 'application/pdf' @el.style.backgroundImage = null return - reader = new FileReader() - reader.onload = => @el.style.backgroundImage = "url(#{reader.result})" - reader.readAsDataURL file + url = window.URL or window.webkitURL + url.revokeObjectURL @url + @url = url.createObjectURL file + @el.style.backgroundImage = "url(#{@url})" select: -> qr.selected?.el.id = null qr.selected = @ @@ -1012,6 +1013,8 @@ qr = $("[name=#{data}]", qr.el).value = @[data] rm: -> # rm reply from qr.replies and the UI + url = window.URL or window.webkitURL + url.revokeObjectURL @url dialog: ->