diff --git a/4chan_x.user.js b/4chan_x.user.js index 4bebc12a9..4d6792b4e 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1297,7 +1297,7 @@ return qr.el = null; }, dialog: function(link) { - var THREAD_ID, challenge, html, spoiler, submitDisabled, submitValue; + var THREAD_ID, challenge, el, html, spoiler, submitDisabled, submitValue, _i, _len, _ref; submitValue = $('#com_submit').value; submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; @@ -1308,8 +1308,11 @@ top: '0px', left: '0px' }, html); - qr.refresh(); - $('textarea', qr.el).value = $('textarea').value; + _ref = $$('form[name=post] [name]'); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + el = _ref[_i]; + $("[name=" + el.name + "]", qr.el).value = el.value; + } $.bind($('input[name=name]', qr.el), 'mousedown', function(e) { return e.stopPropagation(); }); @@ -1419,12 +1422,16 @@ return ta.value += text; }, refresh: function() { - var c, m; - $('form', qr.el).reset(); - c = d.cookie; - $('input[name=name]', qr.el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - $('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; - return $('input[name=pwd]', qr.el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; + var newFile, oldFile; + $('[name=sub]', qr.el).value = ''; + $('[name=com]', qr.el).value = ''; + $('[name=recaptcha_response_field]', qr.el).value = ''; + oldFile = $('[type=file]', qr.el); + newFile = $.el('input', { + type: 'file', + name: 'upfile' + }); + return $.replace(oldFile, newFile); }, submit: function(e) { var id, msg, op; diff --git a/script.coffee b/script.coffee index 466966d94..20212c942 100644 --- a/script.coffee +++ b/script.coffee @@ -1060,8 +1060,8 @@ qr = " qr.el = ui.dialog 'qr', top: '0px', left: '0px', html - qr.refresh() - $('textarea', qr.el).value = $('textarea').value + for el in $$ 'form[name=post] [name]' + $("[name=#{el.name}]", qr.el).value = el.value $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() $.bind $('input[name=upfile]', qr.el), 'change', qr.validateFileSize @@ -1161,11 +1161,13 @@ qr = ta.value += text refresh: -> - $('form', qr.el).reset() - c = d.cookie - $('input[name=name]', qr.el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' - $('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' - $('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value + $('[name=sub]', qr.el).value = '' + $('[name=com]', qr.el).value = '' + $('[name=recaptcha_response_field]', qr.el).value = '' + # XXX opera doesn't allow resetting file inputs w/ file.value = '' + oldFile = $ '[type=file]', qr.el + newFile = $.el 'input', type: 'file', name: 'upfile' + $.replace oldFile, newFile submit: (e) -> if msg = qr.postInvalid()