From ad24caf3665afca553f304341988c8c63aa3e652 Mon Sep 17 00:00:00 2001 From: James Campos Date: Fri, 2 Sep 2011 20:38:00 -0700 Subject: [PATCH] start attaching files --- 4chan_x.user.js | 18 +++++++++++++++++- script.coffee | 13 ++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 74e7ec264..a3e98b478 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1294,19 +1294,35 @@ QR.el = el = ui.dialog('qr', { top: '0', left: '0' - }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
"); + }, " X
Quick Reply
" + ($.get('captchas', []).length) + " captchas
attach another file
"); if (conf['Cooldown']) { QR.cooldown; } $.bind($('.close', el), 'click', QR.close); $.bind($('form', el), 'submit', QR.submit); $.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown); + $.bind($('#attach', el), 'click', QR.attach); $.append(d.body, el); ta = $('textarea', el); l = text.length; ta.setSelectionRange(l, l); return ta.focus(); }, + change: function() { + $.unbind(this, 'change', QR.change); + return QR.attach(); + }, + attach: function() { + var div; + div = $.el('div', { + innerHTML: 'X' + }); + $.bind($('input', div), 'change', QR.change); + $.bind($('a', div), 'click', function() { + return $.rm(this.parentNode); + }); + return $.append($('#files', QR.el), div); + }, hasContent: function() { return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length; }, diff --git a/script.coffee b/script.coffee index e43142eb5..a4c76e673 100644 --- a/script.coffee +++ b/script.coffee @@ -1020,19 +1020,30 @@ QR =
#{$.get('captchas', []).length} captchas
-
+
+
attach another file
" QR.cooldown if conf['Cooldown'] $.bind $('.close', el), 'click', QR.close $.bind $('form', el), 'submit', QR.submit $.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown + $.bind $('#attach', el), 'click', QR.attach $.append d.body, el ta = $ 'textarea', el l = text.length ta.setSelectionRange l, l ta.focus() + change: -> + $.unbind @, 'change', QR.change + QR.attach() + attach: -> + div = $.el 'div', + innerHTML: 'X' + $.bind $('input', div), 'change', QR.change + $.bind $('a', div), 'click', -> $.rm @parentNode + $.append $('#files', QR.el), div hasContent: -> $('textarea', QR.el).value or $('[type=file]', QR.el).files.length autoPost: ->