make cooldown optional, disabled by default

This commit is contained in:
James Campos 2011-05-02 23:05:53 -07:00
parent a88553e4a2
commit 5ce349fee1
2 changed files with 36 additions and 25 deletions

View File

@ -72,6 +72,7 @@
'Anonymize': [false, 'Make everybody anonymous'], 'Anonymize': [false, 'Make everybody anonymous'],
'Auto Watch': [true, 'Automatically watch threads that you start'], 'Auto Watch': [true, 'Automatically watch threads that you start'],
'Comment Expansion': [true, 'Expand too long comments'], 'Comment Expansion': [true, 'Expand too long comments'],
'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)'],
'Image Auto-Gif': [false, 'Animate gif thumbnails'], 'Image Auto-Gif': [false, 'Animate gif thumbnails'],
'Image Expansion': [true, 'Expand images'], 'Image Expansion': [true, 'Expand images'],
'Image Hover': [false, 'Show full image on mouseover'], 'Image Hover': [false, 'Show full image on mouseover'],
@ -1000,7 +1001,9 @@
$.remove(dialog); $.remove(dialog);
} }
} }
qr.cooldown(true); if ($.config('Cooldown')) {
qr.cooldown(true);
}
} }
Recaptcha.reload(); Recaptcha.reload();
return $('iframe[name=iframe]').src = 'about:blank'; return $('iframe[name=iframe]').src = 'about:blank';
@ -1024,17 +1027,19 @@
$.remove(span); $.remove(span);
} }
} }
if (qr.cooldown()) { if ($.config('Cooldown')) {
e.preventDefault(); if (qr.cooldown()) {
alert('Stop posting so often!'); e.preventDefault();
if (isQR) { alert('Stop posting so often!');
span = $.el('span', { if (isQR) {
className: 'error', span = $.el('span', {
textContent: 'Stop posting so often!' className: 'error',
}); textContent: 'Stop posting so often!'
$.append(this.parentNode, span); });
$.append(this.parentNode, span);
}
return;
} }
return;
} }
recaptcha = $('input[name=recaptcha_response_field]', this); recaptcha = $('input[name=recaptcha_response_field]', this);
if (recaptcha.value) { if (recaptcha.value) {
@ -2125,7 +2130,9 @@
$.addStyle(main.css); $.addStyle(main.css);
Recaptcha.init(); Recaptcha.init();
$.bind($('form[name=post]'), 'submit', qr.cb.submit); $.bind($('form[name=post]'), 'submit', qr.cb.submit);
qr.cooldown(); if ($.config('Cooldown')) {
qr.cooldown();
}
if ($.config('Image Expansion')) { if ($.config('Image Expansion')) {
imgExpand.init(); imgExpand.init();
} }

View File

@ -16,6 +16,7 @@ config =
'Anonymize': [false, 'Make everybody anonymous'] 'Anonymize': [false, 'Make everybody anonymous']
'Auto Watch': [true, 'Automatically watch threads that you start'] 'Auto Watch': [true, 'Automatically watch threads that you start']
'Comment Expansion': [true, 'Expand too long comments'] 'Comment Expansion': [true, 'Expand too long comments']
'Cooldown': [false, 'Prevent \'flood detected\' errors (buggy)']
'Image Auto-Gif': [false, 'Animate gif thumbnails'] 'Image Auto-Gif': [false, 'Animate gif thumbnails']
'Image Expansion': [true, 'Expand images'] 'Image Expansion': [true, 'Expand images']
'Image Hover': [false, 'Show full image on mouseover'] 'Image Hover': [false, 'Show full image on mouseover']
@ -754,7 +755,8 @@ qr =
qr.refresh dialog qr.refresh dialog
else else
$.remove dialog $.remove dialog
qr.cooldown true if $.config 'Cooldown'
qr.cooldown true
Recaptcha.reload() Recaptcha.reload()
$('iframe[name=iframe]').src = 'about:blank' $('iframe[name=iframe]').src = 'about:blank'
@ -772,18 +774,19 @@ qr =
if span = @nextSibling if span = @nextSibling
$.remove span $.remove span
# check if we've posted on this board in another tab if $.config 'Cooldown'
if qr.cooldown() # check if we've posted on this board in another tab
e.preventDefault() if qr.cooldown()
alert 'Stop posting so often!' e.preventDefault()
alert 'Stop posting so often!'
if isQR if isQR
span = $.el 'span', span = $.el 'span',
className: 'error' className: 'error'
textContent: 'Stop posting so often!' textContent: 'Stop posting so often!'
$.append @parentNode, span $.append @parentNode, span
return return
recaptcha = $('input[name=recaptcha_response_field]', this) recaptcha = $('input[name=recaptcha_response_field]', this)
if recaptcha.value if recaptcha.value
@ -1639,9 +1642,10 @@ main =
$.bind $('form[name=post]'), 'submit', qr.cb.submit $.bind $('form[name=post]'), 'submit', qr.cb.submit
qr.cooldown()
#major features #major features
if $.config 'Cooldown'
qr.cooldown()
if $.config 'Image Expansion' if $.config 'Image Expansion'
imgExpand.init() imgExpand.init()