From d5df9b071426f3b8891b7956d8cc23468f1610cf Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 11 Jan 2012 16:41:04 +0100 Subject: [PATCH] More name/email/subject save/load work. --- 4chan_x.user.js | 11 ++++++++++- script.coffee | 9 ++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 5b0863808..2942acbed 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1320,6 +1320,10 @@ } _Class.prototype.load = function() { + var data; + for (data in this) { + if (data !== 'file') $("[name=" + data + "]", qr.el).value = this[data]; + } return log(this); }; @@ -1329,7 +1333,7 @@ })(), dialog: function() { - var mimeTypes, thread, threads, _i, _len, _ref; + var input, mimeTypes, thread, threads, _i, _j, _len, _len2, _ref, _ref2; if (!g.REPLY) { threads = ''; _ref = $$('.op'); @@ -1364,6 +1368,11 @@ $.on($('form', qr.el), 'submit', qr.submit); $.on($('[type=file]', qr.el), 'change', qr.fileInput); new qr.reply().load(); + _ref2 = ['name', 'email', 'sub', 'com']; + for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { + input = _ref2[_j]; + $.on($("[name=" + input + "]", qr.el), 'change', function() {}); + } return $.add(d.body, qr.el); }, submit: function(e) { diff --git a/script.coffee b/script.coffee index fe1f8ce64..3d417a933 100644 --- a/script.coffee +++ b/script.coffee @@ -980,14 +980,15 @@ qr = ] else [ - $.get("qr_name", null), + $.get("qr_name", null), $.get("qr_email", null), if conf['Remember Subject'] then $.get("qr_sub", null) else null ] @com = null qr.replies.push @ load: -> - # load reply's data in the QR dialog + for data of @ + $("[name=#{data}]", qr.el).value = @[data] unless data is 'file' # visual feedback in the list log @ rm: -> @@ -1121,7 +1122,9 @@ textarea.field { $.on $('[type=file]', qr.el), 'change', qr.fileInput new qr.reply().load() - #onchange this reply = + for input in ['name', 'email', 'sub', 'com'] + # save this reply's data + $.on $("[name=#{input}]", qr.el), 'change', -> # (getReply?)[@name] = @value # sync between tabs # $.on window, 'storage', (e) -> # if match = e.key.match /qr_(.+)$/