From 61a155bef9bb89e0213d242d6c057c50be7cc582 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 4 May 2011 19:54:26 -0700 Subject: [PATCH] tweaks --- 4chan_x.js | 38 +++++++++++--------------------------- script.coffee | 43 ++++++++++++++----------------------------- 2 files changed, 25 insertions(+), 56 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 761528791..d0ad53521 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1141,48 +1141,32 @@ } }, dialog: function(link) { - var clone, dialog, el, html, resto, script, spoiler, xpath, _i, _len, _ref; - html = "
Quick Reply X
"; + var MAX_FILE_SIZE, THREAD_ID, clone, dialog, el, form, html, spoiler; + MAX_FILE_SIZE = $('input[name="MAX_FILE_SIZE"]').value; + THREAD_ID = g.THREAD_ID || link.pathname.split('/').pop(); + html = "
Quick Reply X
"; dialog = ui.dialog('qr', { top: '0px', left: '0px' }, html); el = $('#autohide', dialog); $.bind(el, 'click', qr.cb.autohide); - $('input[name="MAX_FILE_SIZE"]', dialog).value = $('.postarea input[name="MAX_FILE_SIZE"]').value; if ($('.postarea label')) { spoiler = $.el('label', { innerHTML: " [Spoiler Image?]" }); - $.append($('div:nth-of-type(2)', dialog), spoiler); + $.after($('input[name=email]', dialog), spoiler); } clone = $('#recaptcha_widget_div').cloneNode(true); $.append($('#qr_captcha', dialog), clone); - $('input[name=recaptcha_response_field]', clone).placeholder = 'Verification'; - $('input[name=recaptcha_response_field]', clone).className = 'inputtext'; - $.append(d.body, dialog); - return; - clone = $('form[name=post]').cloneNode(true); - _ref = $$('script', clone); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - script = _ref[_i]; - $.remove(script); - } - clone.target = 'iframe'; - $.bind(clone, 'submit', qr.cb.submit); + $.extend($('input[name=recaptcha_response_field]', clone), { + placeholder: 'Verification', + className: 'inputtext' + }); + form = dialog.lastChild; + $.bind(form, 'submit', qr.cb.submit); $.bind($('input[name=recaptcha_response_field]', clone), 'keydown', Recaptcha.listener); - if (!g.REPLY) { - xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]'; - resto = $.el('input', { - type: 'hidden', - name: 'resto', - value: $.x(xpath, link).name - }); - $.before(clone.lastChild, resto); - } - $.append(dialog, clone); $.append(d.body, dialog); - dialog.style.width = dialog.offsetWidth; return dialog; }, persist: function() { diff --git a/script.coffee b/script.coffee index ead516f75..b97a7fb5a 100644 --- a/script.coffee +++ b/script.coffee @@ -875,10 +875,14 @@ qr = clearInterval qr.cooldownIntervalID dialog: (link) -> + #maybe should be global + MAX_FILE_SIZE = $('input[name="MAX_FILE_SIZE"]').value + THREAD_ID = g.THREAD_ID or link.pathname.split('/').pop() html = " -
Quick Reply X
-
- +
Quick Reply X
+ + +
@@ -892,42 +896,23 @@ qr = el = $ '#autohide', dialog $.bind el, 'click', qr.cb.autohide - $('input[name="MAX_FILE_SIZE"]', dialog).value = $('.postarea input[name="MAX_FILE_SIZE"]').value - if $ '.postarea label' spoiler = $.el 'label', innerHTML: " [Spoiler Image?]" - $.append $('div:nth-of-type(2)', dialog), spoiler + $.after $('input[name=email]', dialog), spoiler + # TODO try w/o cloning clone = $('#recaptcha_widget_div').cloneNode(true) $.append $('#qr_captcha', dialog), clone - $('input[name=recaptcha_response_field]', clone).placeholder = 'Verification' - $('input[name=recaptcha_response_field]', clone).className = 'inputtext' + $.extend $('input[name=recaptcha_response_field]', clone), + placeholder: 'Verification' + className: 'inputtext' - $.append d.body, dialog - return - - clone = $('form[name=post]').cloneNode(true) - for script in $$ 'script', clone - $.remove script - clone.target = 'iframe' - $.bind clone, 'submit', qr.cb.submit + form = dialog.lastChild + $.bind form, 'submit', qr.cb.submit $.bind $('input[name=recaptcha_response_field]', clone), 'keydown', Recaptcha.listener - if not g.REPLY - #figure out which thread we're replying to - xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]' - resto = $.el 'input', - type: 'hidden' - name: 'resto' - value: $.x(xpath, link).name - - # place resto before table to let userstyles know we're responding to a thread - $.before clone.lastChild, resto - - $.append dialog, clone $.append d.body, dialog - dialog.style.width = dialog.offsetWidth # lock dialog