merge Recaptcha into QR
This commit is contained in:
parent
879b13477f
commit
8c515063f6
@ -60,7 +60,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
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 $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, QR, 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;
|
var __slice = Array.prototype.slice;
|
||||||
config = {
|
config = {
|
||||||
main: {
|
main: {
|
||||||
@ -1268,6 +1268,9 @@
|
|||||||
QR = {
|
QR = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var holder;
|
var holder;
|
||||||
|
if (!($('form[name=post]') && $('#recaptcha_response_field'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
g.callbacks.push(function(root) {
|
g.callbacks.push(function(root) {
|
||||||
var quote;
|
var quote;
|
||||||
quote = $('a.quotejs + a', root);
|
quote = $('a.quotejs + a', root);
|
||||||
@ -1365,6 +1368,9 @@
|
|||||||
captchas || (captchas = $.get('captchas', []));
|
captchas || (captchas = $.get('captchas', []));
|
||||||
return $('#cl', QR.qr).textContent = captchas.length + ' captchas';
|
return $('#cl', QR.qr).textContent = captchas.length + ' captchas';
|
||||||
},
|
},
|
||||||
|
captchaReload: function() {
|
||||||
|
return window.location = 'javascript:Recaptcha.reload()';
|
||||||
|
},
|
||||||
change: function(e) {
|
change: function(e) {
|
||||||
var file, fr, img, qr;
|
var file, fr, img, qr;
|
||||||
file = this.files[0];
|
file = this.files[0];
|
||||||
@ -1436,7 +1442,6 @@
|
|||||||
});
|
});
|
||||||
$.bind($('form', qr), 'submit', QR.submit);
|
$.bind($('form', qr), 'submit', QR.submit);
|
||||||
$.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown);
|
$.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown);
|
||||||
$.bind($('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener);
|
|
||||||
QR.captchaImg();
|
QR.captchaImg();
|
||||||
QR.captchaLength();
|
QR.captchaLength();
|
||||||
$.add(d.body, qr);
|
$.add(d.body, qr);
|
||||||
@ -1446,7 +1451,14 @@
|
|||||||
return ta.focus();
|
return ta.focus();
|
||||||
},
|
},
|
||||||
keydown: function(e) {
|
keydown: function(e) {
|
||||||
if (!(e.keyCode === 13 && this.value)) {
|
var kc, v;
|
||||||
|
kc = e.keyCode;
|
||||||
|
v = this.value;
|
||||||
|
if (kc === 8 && !v) {
|
||||||
|
QR.captchaReload();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(e.keyCode === 13 && v)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QR.captchaPush(this);
|
QR.captchaPush(this);
|
||||||
@ -1581,7 +1593,7 @@
|
|||||||
sys: function() {
|
sys: function() {
|
||||||
var recaptcha;
|
var recaptcha;
|
||||||
if (recaptcha = $('#recaptcha_response_field')) {
|
if (recaptcha = $('#recaptcha_response_field')) {
|
||||||
$.bind(recaptcha, 'keydown', Recaptcha.listener);
|
$.bind(recaptcha, 'keydown', QR.keydown);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.globalEval(function() {
|
return $.globalEval(function() {
|
||||||
@ -2936,25 +2948,6 @@
|
|||||||
}
|
}
|
||||||
return location.href = url;
|
return location.href = url;
|
||||||
};
|
};
|
||||||
Recaptcha = {
|
|
||||||
init: function() {
|
|
||||||
var el, _i, _len, _ref2;
|
|
||||||
_ref2 = $$('#recaptcha_table a');
|
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
|
||||||
el = _ref2[_i];
|
|
||||||
el.tabIndex = 1;
|
|
||||||
}
|
|
||||||
return $.bind($('#recaptcha_response_field'), 'keydown', Recaptcha.listener);
|
|
||||||
},
|
|
||||||
listener: function(e) {
|
|
||||||
if (e.keyCode === 8 && this.value === '') {
|
|
||||||
return Recaptcha.reload();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
reload: function() {
|
|
||||||
return window.location = 'javascript:Recaptcha.reload()';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
nodeInserted = function(e) {
|
nodeInserted = function(e) {
|
||||||
var callback, target, _i, _len, _ref2, _results;
|
var callback, target, _i, _len, _ref2, _results;
|
||||||
target = e.target;
|
target = e.target;
|
||||||
@ -3157,7 +3150,7 @@
|
|||||||
};
|
};
|
||||||
main = {
|
main = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var callback, canPost, cutoff, form, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6;
|
var callback, cutoff, hiddenThreads, id, lastChecked, now, op, pathname, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6;
|
||||||
pathname = location.pathname.substring(1).split('/');
|
pathname = location.pathname.substring(1).split('/');
|
||||||
g.BOARD = pathname[0], temp = pathname[1];
|
g.BOARD = pathname[0], temp = pathname[1];
|
||||||
if (temp === 'res') {
|
if (temp === 'res') {
|
||||||
@ -3208,23 +3201,10 @@
|
|||||||
$.set('lastChecked', now);
|
$.set('lastChecked', now);
|
||||||
}
|
}
|
||||||
$.addStyle(main.css);
|
$.addStyle(main.css);
|
||||||
if ((form = $('form[name=post]')) && (canPost = !!$('#recaptcha_response_field'))) {
|
|
||||||
Recaptcha.init();
|
|
||||||
if (g.REPLY && conf['Auto Watch Reply'] && conf['Thread Watcher']) {
|
|
||||||
$.bind(form, 'submit', function() {
|
|
||||||
if ($('img.favicon').src === Favicon.empty) {
|
|
||||||
return watcher.watch(null, g.THREAD_ID);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
threading.init();
|
threading.init();
|
||||||
if (g.REPLY && (id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) {
|
if (g.REPLY && (id = location.hash.slice(1)) && /\d/.test(id[0]) && !$.id(id)) {
|
||||||
scrollTo(0, d.body.scrollHeight);
|
scrollTo(0, d.body.scrollHeight);
|
||||||
}
|
}
|
||||||
if (conf['Auto Noko'] && canPost) {
|
|
||||||
form.action += '?noko';
|
|
||||||
}
|
|
||||||
if (conf['Image Expansion']) {
|
if (conf['Image Expansion']) {
|
||||||
imgExpand.init();
|
imgExpand.init();
|
||||||
}
|
}
|
||||||
@ -3249,7 +3229,7 @@
|
|||||||
if (conf['Reply Hiding']) {
|
if (conf['Reply Hiding']) {
|
||||||
replyHiding.init();
|
replyHiding.init();
|
||||||
}
|
}
|
||||||
if (conf['Quick Reply'] && canPost) {
|
if (conf['Quick Reply']) {
|
||||||
QR.init();
|
QR.init();
|
||||||
}
|
}
|
||||||
if (conf['Report Button']) {
|
if (conf['Report Button']) {
|
||||||
|
|||||||
@ -965,6 +965,8 @@ QR =
|
|||||||
#report queueing
|
#report queueing
|
||||||
#check if captchas can be reused on eg dup file error
|
#check if captchas can be reused on eg dup file error
|
||||||
init: ->
|
init: ->
|
||||||
|
#can't reply in some stickies, recaptcha may be blocked, eg by noscript
|
||||||
|
return unless $('form[name=post]') and $('#recaptcha_response_field')
|
||||||
g.callbacks.push (root) ->
|
g.callbacks.push (root) ->
|
||||||
quote = $ 'a.quotejs + a', root
|
quote = $ 'a.quotejs + a', root
|
||||||
$.bind quote, 'click', QR.quote
|
$.bind quote, 'click', QR.quote
|
||||||
@ -1034,6 +1036,8 @@ QR =
|
|||||||
captchaLength: (captchas) ->
|
captchaLength: (captchas) ->
|
||||||
captchas or= $.get 'captchas', []
|
captchas or= $.get 'captchas', []
|
||||||
$('#cl', QR.qr).textContent = captchas.length + ' captchas'
|
$('#cl', QR.qr).textContent = captchas.length + ' captchas'
|
||||||
|
captchaReload: ->
|
||||||
|
window.location = 'javascript:Recaptcha.reload()'
|
||||||
change: (e) ->
|
change: (e) ->
|
||||||
file = @files[0]
|
file = @files[0]
|
||||||
if file.size > QR.MAX_FILE_SIZE
|
if file.size > QR.MAX_FILE_SIZE
|
||||||
@ -1115,7 +1119,6 @@ QR =
|
|||||||
$.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation()
|
$.bind $('.click', qr), 'mousedown', (e) -> e.stopPropagation()
|
||||||
$.bind $('form', qr), 'submit', QR.submit
|
$.bind $('form', qr), 'submit', QR.submit
|
||||||
$.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown
|
$.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown
|
||||||
$.bind $('#recaptcha_response_field', qr), 'keydown', Recaptcha.listener
|
|
||||||
QR.captchaImg()
|
QR.captchaImg()
|
||||||
QR.captchaLength()
|
QR.captchaLength()
|
||||||
$.add d.body, qr
|
$.add d.body, qr
|
||||||
@ -1124,7 +1127,12 @@ QR =
|
|||||||
ta.setSelectionRange l, l
|
ta.setSelectionRange l, l
|
||||||
ta.focus()
|
ta.focus()
|
||||||
keydown: (e) ->
|
keydown: (e) ->
|
||||||
return unless e.keyCode is 13 and @value #enter, captcha filled
|
kc = e.keyCode
|
||||||
|
v = @value
|
||||||
|
if kc is 8 and not v #backspace, empty
|
||||||
|
QR.captchaReload()
|
||||||
|
return
|
||||||
|
return unless e.keyCode is 13 and v #enter, not empty
|
||||||
QR.captchaPush @
|
QR.captchaPush @
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
QR.submit() #derpy, but prevents checking for content twice
|
QR.submit() #derpy, but prevents checking for content twice
|
||||||
@ -1212,7 +1220,7 @@ QR =
|
|||||||
watcher.watch op, id
|
watcher.watch op, id
|
||||||
sys: ->
|
sys: ->
|
||||||
if recaptcha = $ '#recaptcha_response_field' #post reporting
|
if recaptcha = $ '#recaptcha_response_field' #post reporting
|
||||||
$.bind recaptcha, 'keydown', Recaptcha.listener
|
$.bind recaptcha, 'keydown', QR.keydown
|
||||||
return
|
return
|
||||||
$.globalEval ->
|
$.globalEval ->
|
||||||
$ = (css) -> document.querySelector css
|
$ = (css) -> document.querySelector css
|
||||||
@ -2227,18 +2235,6 @@ redirect = ->
|
|||||||
url = "http://boards.4chan.org/#{g.BOARD}"
|
url = "http://boards.4chan.org/#{g.BOARD}"
|
||||||
location.href = url
|
location.href = url
|
||||||
|
|
||||||
Recaptcha =
|
|
||||||
init: ->
|
|
||||||
#hack to tab from comment straight to recaptcha
|
|
||||||
for el in $$ '#recaptcha_table a'
|
|
||||||
el.tabIndex = 1
|
|
||||||
$.bind $('#recaptcha_response_field'), 'keydown', Recaptcha.listener
|
|
||||||
listener: (e) ->
|
|
||||||
if e.keyCode is 8 and @value is '' # backspace to reload
|
|
||||||
Recaptcha.reload()
|
|
||||||
reload: ->
|
|
||||||
window.location = 'javascript:Recaptcha.reload()'
|
|
||||||
|
|
||||||
nodeInserted = (e) ->
|
nodeInserted = (e) ->
|
||||||
{target} = e
|
{target} = e
|
||||||
if target.nodeName is 'TABLE'
|
if target.nodeName is 'TABLE'
|
||||||
@ -2486,13 +2482,6 @@ main =
|
|||||||
|
|
||||||
$.addStyle main.css
|
$.addStyle main.css
|
||||||
|
|
||||||
#recaptcha may be blocked, eg by noscript
|
|
||||||
if (form = $ 'form[name=post]') and (canPost = !!$ '#recaptcha_response_field')
|
|
||||||
Recaptcha.init()
|
|
||||||
if g.REPLY and conf['Auto Watch Reply'] and conf['Thread Watcher']
|
|
||||||
$.bind form, 'submit', -> if $('img.favicon').src is Favicon.empty
|
|
||||||
watcher.watch null, g.THREAD_ID
|
|
||||||
|
|
||||||
#major features
|
#major features
|
||||||
threading.init()
|
threading.init()
|
||||||
|
|
||||||
@ -2501,9 +2490,6 @@ main =
|
|||||||
if g.REPLY and (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id)
|
if g.REPLY and (id = location.hash[1..]) and /\d/.test(id[0]) and !$.id(id)
|
||||||
scrollTo 0, d.body.scrollHeight
|
scrollTo 0, d.body.scrollHeight
|
||||||
|
|
||||||
if conf['Auto Noko'] and canPost
|
|
||||||
form.action += '?noko'
|
|
||||||
|
|
||||||
if conf['Image Expansion']
|
if conf['Image Expansion']
|
||||||
imgExpand.init()
|
imgExpand.init()
|
||||||
|
|
||||||
@ -2528,7 +2514,7 @@ main =
|
|||||||
if conf['Reply Hiding']
|
if conf['Reply Hiding']
|
||||||
replyHiding.init()
|
replyHiding.init()
|
||||||
|
|
||||||
if conf['Quick Reply'] and canPost
|
if conf['Quick Reply']
|
||||||
QR.init()
|
QR.init()
|
||||||
|
|
||||||
if conf['Report Button']
|
if conf['Report Button']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user