Add captcha refresh on backspace and one-word captcha in the report window. #932

This commit is contained in:
Nicolas Stepien 2013-02-28 00:58:59 +01:00
parent df81ea3815
commit e8012a38da
4 changed files with 47 additions and 1 deletions

View File

@ -43,7 +43,7 @@
*/
(function() {
var $, $$, Anonymize, ArchiveLink, AutoGIF, Board, Build, Clone, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Fourchan, Get, Header, ImageExpand, ImageHover, Keybinds, Main, Menu, Misc, Nav, Notification, Polyfill, Post, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, ReplyHiding, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, d, doc, g,
var $, $$, Anonymize, ArchiveLink, AutoGIF, Board, Build, Clone, Conf, Config, DeleteLink, DownloadLink, ExpandComment, ExpandThread, Favicon, FileInfo, Filter, Fourchan, Get, Header, ImageExpand, ImageHover, Keybinds, Main, Menu, Misc, Nav, Notification, Polyfill, Post, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, ReplyHiding, Report, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, d, doc, g,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
@ -6788,6 +6788,34 @@
}
};
Report = {
init: function() {
if (!/report/.test(location.search)) {
return;
}
return $.ready(this.ready);
},
ready: function() {
var field, form;
form = $('form');
field = $.id('recaptcha_response_field');
$.on(field, 'keydown', function(e) {
if (e.keyCode === 8 && !field.value) {
return $.unsafeWindow.Recaptcha.reload('t');
}
});
return $.on(form, 'submit', function(e) {
var response;
e.preventDefault();
response = field.value.trim();
if (!/\s/.test(response)) {
field.value = "" + response + " " + response;
}
return form.submit();
});
}
};
Board = (function() {
Board.prototype.toString = function() {
@ -7159,6 +7187,7 @@
}
switch (location.hostname) {
case 'sys.4chan.org':
Report.init();
return;
case 'images.4chan.org':
$.ready(function() {

View File

@ -16,6 +16,7 @@ module.exports = function(grunt) {
'lib/polyfill.coffee',
'src/features.coffee',
'src/qr.coffee',
'src/report.coffee',
'src/main.coffee'
],
dest: 'tmp/script.coffee'
@ -65,6 +66,7 @@ module.exports = function(grunt) {
interrupt: true
},
files: [
'Gruntfile.js',
'package.json',
'lib/**/*.coffee',
'src/**/*.coffee',

View File

@ -289,6 +289,7 @@ Main =
switch location.hostname
when 'sys.4chan.org'
Report.init()
return
when 'images.4chan.org'
$.ready ->

14
src/report.coffee Normal file
View File

@ -0,0 +1,14 @@
Report =
init: ->
return unless /report/.test location.search
$.ready @ready
ready: ->
form = $ 'form'
field = $.id 'recaptcha_response_field'
$.on field, 'keydown', (e) ->
$.unsafeWindow.Recaptcha.reload 't' if e.keyCode is 8 and not field.value
$.on form, 'submit', (e) ->
e.preventDefault()
response = field.value.trim()
field.value = "#{response} #{response}" unless /\s/.test response
form.submit()