From 6810c84e6af73f0766c03a097deccd681295640b Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 25 Jan 2012 04:34:20 +0100 Subject: [PATCH] Sync name/email/subject if there's only one reply. --- 4chan_x.user.js | 13 +++++++++++++ script.coffee | 8 +++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7f24adee8..c9afd650f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1555,6 +1555,19 @@ return qr.selected[this.name] = this.value; }); } + $.on(window, 'storage', function(e) { + var key, val, _ref3, _results; + if (e.key === ("" + NAMESPACE + "qr.persona") && qr.replies.length === 1) { + _ref3 = JSON.parse(e.newValue); + _results = []; + for (key in _ref3) { + val = _ref3[key]; + qr.selected[key] = val; + _results.push($("[name=" + key + "]", qr.el).value = val); + } + return _results; + } + }); qr.status.input = $('[type=submit]', qr.el); qr.status(); qr.captcha.init(); diff --git a/script.coffee b/script.coffee index 058acaad4..13ea074a1 100644 --- a/script.coffee +++ b/script.coffee @@ -1143,9 +1143,11 @@ qr = for input in ['name', 'email', 'sub', 'com'] $.on $("[name=#{input}]", qr.el), 'change', -> qr.selected[@name] = @value # sync between tabs - # $.on window, 'storage', (e) -> - # if match = e.key.match /qr_(.+)$/ - # qr.inputs[match[1]].value = JSON.parse e.newValue + $.on window, 'storage', (e) -> + if e.key is "#{NAMESPACE}qr.persona" and qr.replies.length is 1 + for key, val of JSON.parse e.newValue + qr.selected[key] = val + $("[name=#{key}]", qr.el).value = val qr.status.input = $ '[type=submit]', qr.el qr.status()