diff --git a/4chan_x.user.js b/4chan_x.user.js index 817a615d5..a352ad5d0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1299,11 +1299,32 @@ qr.error("" + file.name + ": Unsupported file type."); break; } + new qr.reply(file); } return $.addClass(qr.el, 'dump'); }, + replies: [], + reply: (function() { + + function _Class(file) { + var name, _ref; + this.file = file; + this.com = null; + for (name in qr.inputs) { + this[name] = ((_ref = qr.replies[qr.replies.length - 1]) != null ? _ref[name] : void 0) || $.get("qr_" + name, null); + } + qr.replies.push(this); + } + + _Class.prototype.load = function() { + return log(this); + }; + + return _Class; + + })(), dialog: function() { - var input, mimeTypes, name, thread, threads, _i, _len, _ref, _ref2; + var mimeTypes, thread, threads, _i, _len, _ref; if (!g.REPLY) { threads = ''; _ref = $$('.op'); @@ -1342,11 +1363,7 @@ email: $('[name=email]', qr.el) }; if (conf['Remember Subject']) qr.inputs.subject = $('[name=subject]', qr.el); - _ref2 = qr.inputs; - for (name in _ref2) { - input = _ref2[name]; - input.value = $.get("qr_" + name, null); - } + new qr.reply().load(); $.on(window, 'storage', function(e) { var match; if (match = e.key.match(/qr_(.+)$/)) { diff --git a/script.coffee b/script.coffee index d7ef796b9..d1b44fca5 100644 --- a/script.coffee +++ b/script.coffee @@ -950,7 +950,8 @@ qr = else if -1 is qr.mimeTypes.indexOf file.type qr.error 'Unsupported file type.' else - # modify selected reply's file + # set or modify selected reply's file + # qr.replies[?].file = file return for file in @files if file.size > @max @@ -959,10 +960,20 @@ qr = else if -1 is qr.mimeTypes.indexOf file.type qr.error "#{file.name}: Unsupported file type." break - # add new reply - # set reply's file + new qr.reply file $.addClass qr.el, 'dump' + replies: [] + reply: class + constructor: (@file) -> + @com = null + for name of qr.inputs + @[name] = qr.replies[qr.replies.length-1]?[name] or $.get "qr_#{name}", null + qr.replies.push @ + load: -> + # load reply's data in the QR dialog + log @ + dialog: -> # create a new thread or select thread to reply to unless g.REPLY @@ -1094,8 +1105,7 @@ textarea.field { name: $ '[name=name]', qr.el email: $ '[name=email]', qr.el qr.inputs.subject = $ '[name=subject]', qr.el if conf['Remember Subject'] - for name, input of qr.inputs - input.value = $.get "qr_#{name}", null + new qr.reply().load() # sync between tabs $.on window, 'storage', (e) -> if match = e.key.match /qr_(.+)$/