diff --git a/4chan_x.user.js b/4chan_x.user.js index d9f06aa9d..ecde67147 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -57,7 +57,7 @@ */ (function() { - var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref; + var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, QR, Recaptcha, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, qr, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref; var __slice = Array.prototype.slice; config = { main: { @@ -1222,6 +1222,55 @@ } } }; + QR = { + init: function() { + var holder; + $.append(d.body, $.el('iframe', { + name: 'iframe' + })); + holder = $('#recaptcha_challenge_field_holder'); + $.bind(holder, 'DOMNodeInserted', QR.challengeNode); + QR.challengeNode({ + target: holder.firstChild + }); + return g.callbacks.push(QR.node); + }, + challengeNode: function(e) { + return QR.captcha = { + challenge: e.target.value, + time: Date.now() + }; + }, + node: function(root) { + var quote; + quote = $('a.quotejs + a', root); + return $.bind(quote, 'click', QR.quote); + }, + quote: function(e) { + e.preventDefault(); + return QR.dialog(">>" + this.textContent + "\n"); + }, + dialog: function(text) { + var l, ta; + if (text == null) { + text = ''; + } + qr.el = ui.dialog('qr', { + top: '0', + left: '0' + }, " X
Quick Reply
"); + $.bind($('form', qr.el), 'submit', QR.submit); + $.append(d.body, qr.el); + ta = $('textarea', qr.el); + l = text.length; + ta.setSelectionRange(l, l); + return ta.focus(); + }, + submit: function(e) { + $('#challenge', qr.el).value = QR.captcha.challenge; + return $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value; + } + }; qr = { init: function() { var iframe; @@ -2863,7 +2912,7 @@ replyHiding.init(); } if (conf['Quick Reply'] && canPost) { - qr.init(); + QR.init(); } if (conf['Report Button']) { reportButton.init(); @@ -3079,7 +3128,7 @@ width: 100%;\ height: 125px;\ }\ - #qr #close, #qr #autohide {\ + #qr .close, #qr #autohide {\ float: right;\ }\ #qr:not(:hover) > #autohide:checked ~ .autohide {\ diff --git a/script.coffee b/script.coffee index c9f3b6c5d..575ee91ea 100644 --- a/script.coffee +++ b/script.coffee @@ -961,6 +961,52 @@ cooldown = submit.value = 'Submit' qr.autoPost() +QR = + init: -> + $.append d.body, $.el 'iframe', + name: 'iframe' + holder = $ '#recaptcha_challenge_field_holder' + $.bind holder, 'DOMNodeInserted', QR.challengeNode + QR.challengeNode target: holder.firstChild + g.callbacks.push QR.node + challengeNode: (e) -> + QR.captcha = + challenge: e.target.value + time: Date.now() + node: (root) -> + quote = $ 'a.quotejs + a', root + $.bind quote, 'click', QR.quote + quote: (e) -> + e.preventDefault() + QR.dialog ">>#{@textContent}\n" + dialog: (text='') -> + qr.el = ui.dialog 'qr', top: '0', left: '0', " + X +
Quick Reply
+
+ + + + +
+
+
+
+
+
+
+
+ " + $.bind $('form', qr.el), 'submit', QR.submit + $.append d.body, qr.el + ta = $ 'textarea', qr.el + l = text.length + ta.setSelectionRange l, l + ta.focus() + submit: (e) -> + $('#challenge', qr.el).value = QR.captcha.challenge + $('#response', qr.el).value = $('#recaptcha_response_field', qr.el).value + qr = # TODO # error handling / logging @@ -2259,7 +2305,7 @@ main = replyHiding.init() if conf['Quick Reply'] and canPost - qr.init() + QR.init() if conf['Report Button'] reportButton.init() @@ -2462,7 +2508,7 @@ main = width: 100%; height: 125px; } - #qr #close, #qr #autohide { + #qr .close, #qr #autohide { float: right; } #qr:not(:hover) > #autohide:checked ~ .autohide {