diff --git a/4chan_x.user.js b/4chan_x.user.js
index 5387bb5c1..dea3b5598 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -1248,31 +1248,38 @@
time: Date.now()
};
},
- node: function(root) {
- var quote;
- quote = $('a.quotejs + a', root);
- return $.bind(quote, 'click', QR.quote);
+ captchaPush: function(el) {
+ var captcha, captchas;
+ captcha = QR.captcha;
+ captcha.response = el.value;
+ captchas = $.get('captchas', []);
+ captchas.push(captcha);
+ $.set('captchas', captchas);
+ el.value = '';
+ Recaptcha.reload();
+ return el.nextSibling.textContent = captchas.length + ' captchas';
},
- quote: function(e) {
- var i, ss, ta, text, v;
- e.preventDefault();
- text = ">>" + this.textContent + "\n";
- if (!QR.el) {
- QR.dialog(text);
- return;
+ captchaShift: function() {
+ var captcha, captchas, cutoff;
+ captchas = $.get('captchas', []);
+ cutoff = Date.now() - 5 * HOUR + 5 * MINUTE;
+ while (captcha = captchas.shift()) {
+ if (captcha.time > cutoff) {
+ break;
+ }
}
- ta = $('textarea', QR.el);
- v = ta.value;
- ss = ta.selectionStart;
- ta.value = v.slice(0, ss) + text + v.slice(ss);
- i = ss + text.length;
- ta.setSelectionRange(i, i);
- return ta.focus();
+ $.set('captchas', captchas);
+ return captcha;
},
close: function() {
$.rm(QR.el);
return QR.el = null;
},
+ node: function(root) {
+ var quote;
+ quote = $('a.quotejs + a', root);
+ return $.bind(quote, 'click', QR.quote);
+ },
dialog: function(text) {
var el, l, ta;
if (text == null) {
@@ -1301,28 +1308,30 @@
e.preventDefault();
return QR.captchaPush(this);
},
- captchaPush: function(el) {
- var captcha, captchas;
- captcha = QR.captcha;
- captcha.response = el.value;
- captchas = $.get('captchas', []);
- captchas.push(captcha);
- $.set('captchas', captchas);
- el.value = '';
- Recaptcha.reload();
- return el.nextSibling.textContent = captchas.length + ' captchas';
- },
- captchaShift: function() {
- var captcha, captchas, cutoff;
- captchas = $.get('captchas', []);
- cutoff = Date.now() - 5 * HOUR + 5 * MINUTE;
- while (captcha = captchas.shift()) {
- if (captcha.time > cutoff) {
- break;
- }
+ quote: function(e) {
+ var i, ss, ta, text, v;
+ e.preventDefault();
+ text = ">>" + this.textContent + "\n";
+ if (!QR.el) {
+ QR.dialog(text);
+ return;
+ }
+ ta = $('textarea', QR.el);
+ v = ta.value;
+ ss = ta.selectionStart;
+ ta.value = v.slice(0, ss) + text + v.slice(ss);
+ i = ss + text.length;
+ ta.setSelectionRange(i, i);
+ return ta.focus();
+ },
+ receive: function(e) {
+ var data;
+ data = e.data;
+ if (data) {
+ return $.extend($('a.error', QR.el), JSON.parse(data));
+ } else {
+ return QR.close();
}
- $.set('captchas', captchas);
- return captcha;
},
submit: function(e) {
var captcha, challenge, el, response;
@@ -1352,15 +1361,6 @@
parent.postMessage(data, '*');
return location = 'about:blank';
});
- },
- receive: function(e) {
- var data;
- data = e.data;
- if (data) {
- return $.extend($('a.error', QR.el), JSON.parse(data));
- } else {
- return QR.close();
- }
}
};
qr = {
diff --git a/script.coffee b/script.coffee
index e5e159824..f912349ad 100644
--- a/script.coffee
+++ b/script.coffee
@@ -978,25 +978,29 @@ QR =
QR.captcha =
challenge: c
time: Date.now()
- node: (root) ->
- quote = $ 'a.quotejs + a', root
- $.bind quote, 'click', QR.quote
- quote: (e) ->
- e.preventDefault()
- text = ">>#{@textContent}\n"
- if not QR.el
- QR.dialog text
- return
- ta = $ 'textarea', QR.el
- v = ta.value
- ss = ta.selectionStart
- ta.value = v[0...ss] + text + v[ss..]
- i = ss + text.length
- ta.setSelectionRange i, i
- ta.focus()
+ captchaPush: (el) ->
+ {captcha} = QR
+ captcha.response = el.value
+ captchas = $.get 'captchas', []
+ captchas.push captcha
+ $.set 'captchas', captchas
+ el.value = ''
+ Recaptcha.reload()
+ el.nextSibling.textContent = captchas.length + ' captchas'
+ captchaShift: ->
+ captchas = $.get 'captchas', []
+ cutoff = Date.now() - 5*HOUR + 5*MINUTE
+ while captcha = captchas.shift()
+ if captcha.time > cutoff
+ break
+ $.set 'captchas', captchas
+ captcha
close: ->
$.rm QR.el
QR.el = null
+ node: (root) ->
+ quote = $ 'a.quotejs + a', root
+ $.bind quote, 'click', QR.quote
dialog: (text='') ->
QR.el = el = ui.dialog 'qr', top: '0', left: '0', "
X
@@ -1029,23 +1033,25 @@ QR =
return if $('textarea', QR.el).value or $('[type=file]', QR.el).files.length #not blank
e.preventDefault()
QR.captchaPush @
- captchaPush: (el) ->
- {captcha} = QR
- captcha.response = el.value
- captchas = $.get 'captchas', []
- captchas.push captcha
- $.set 'captchas', captchas
- el.value = ''
- Recaptcha.reload()
- el.nextSibling.textContent = captchas.length + ' captchas'
- captchaShift: ->
- captchas = $.get 'captchas', []
- cutoff = Date.now() - 5*HOUR + 5*MINUTE
- while captcha = captchas.shift()
- if captcha.time > cutoff
- break
- $.set 'captchas', captchas
- captcha
+ quote: (e) ->
+ e.preventDefault()
+ text = ">>#{@textContent}\n"
+ if not QR.el
+ QR.dialog text
+ return
+ ta = $ 'textarea', QR.el
+ v = ta.value
+ ss = ta.selectionStart
+ ta.value = v[0...ss] + text + v[ss..]
+ i = ss + text.length
+ ta.setSelectionRange i, i
+ ta.focus()
+ receive: (e) ->
+ {data} = e
+ if data
+ $.extend $('a.error', QR.el), JSON.parse data
+ else
+ QR.close()
submit: (e) ->
$('.error', qr.el).textContent = ''
if (el = $('#recaptcha_response_field', QR.el)).value
@@ -1064,12 +1070,6 @@ QR =
data = JSON.stringify {textContent, href}
parent.postMessage data, '*'
location = 'about:blank'
- receive: (e) ->
- {data} = e
- if data
- $.extend $('a.error', QR.el), JSON.parse data
- else
- QR.close()
qr =
# TODO