auto post
This commit is contained in:
parent
280d8b3d52
commit
b29ea64bc3
@ -1294,7 +1294,7 @@
|
||||
QR.el = el = ui.dialog('qr', {
|
||||
top: '0',
|
||||
left: '0'
|
||||
}, " <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <div class=move><input placeholder=Name name=name form=qr_form>Quick Reply</div> <form enctype=multipart/form-data method=post action=http://sys.4chan.org/" + g.BOARD + "/post target=iframe id=qr_form> <input type=hidden name=resto value=" + g.THREAD_ID + "> <input type=hidden name=mode value=regist> <input type=hidden name=recaptcha_challenge_field id=challenge> <input type=hidden name=recaptcha_response_field id=response> <div><input placeholder=Email name=email></div> <div><input placeholder=Subject name=sub><button>Submit</button></div> <div><textarea placeholder=Comment name=com>" + text + "</textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + QR.captcha.challenge + "></div> <div><input placeholder=Verification autocomplete=off id=recaptcha_response_field><span id=cl>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input name=upfile type=file></div> <div><input placeholder=Password name=pwd type=password></div> </form> <a class=error></a> ");
|
||||
}, " <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <div class=move><input placeholder=Name name=name form=qr_form>Quick Reply</div> <form enctype=multipart/form-data method=post action=http://sys.4chan.org/" + g.BOARD + "/post target=iframe id=qr_form> <input type=hidden name=resto value=" + g.THREAD_ID + "> <input type=hidden name=mode value=regist> <input type=hidden name=recaptcha_challenge_field id=challenge> <input type=hidden name=recaptcha_response_field id=response> <div><input placeholder=Email name=email></div> <div><input placeholder=Subject name=sub><button>Submit</button><label>auto<input id=auto type=checkbox></label></div> <div><textarea placeholder=Comment name=com>" + text + "</textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + QR.captcha.challenge + "></div> <div><input placeholder=Verification autocomplete=off id=recaptcha_response_field><span id=cl>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input name=upfile type=file></div> <div><input placeholder=Password name=pwd type=password></div> </form> <a class=error></a> ");
|
||||
if (conf['Cooldown']) {
|
||||
QR.cooldown;
|
||||
}
|
||||
@ -1307,11 +1307,20 @@
|
||||
ta.setSelectionRange(l, l);
|
||||
return ta.focus();
|
||||
},
|
||||
hasContent: function() {
|
||||
return $('textarea', QR.el).value || $('[type=file]', QR.el).files.length;
|
||||
},
|
||||
autoPost: function() {
|
||||
if (!QR.hasContent()) {
|
||||
return;
|
||||
}
|
||||
return QR.submit();
|
||||
},
|
||||
keydown: function(e) {
|
||||
if (!(e.keyCode === 13 && this.value)) {
|
||||
return;
|
||||
}
|
||||
if ($('textarea', QR.el).value || $('[type=file]', QR.el).files.length) {
|
||||
if (QR.hasContent()) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
@ -1343,16 +1352,19 @@
|
||||
n = Math.ceil((cooldown - now) / 1000);
|
||||
b = $('button', QR.el);
|
||||
if (n > 0) {
|
||||
setTimeout(QR.cooldown, 1000);
|
||||
return $.extend(b, {
|
||||
$.extend(b, {
|
||||
textContent: n,
|
||||
disabled: true
|
||||
});
|
||||
return setTimeout(QR.cooldown, 1000);
|
||||
} else {
|
||||
return $.extend(b, {
|
||||
$.extend(b, {
|
||||
textContent: 'Submit',
|
||||
disabled: false
|
||||
});
|
||||
if ($('#auto', QR.el).checked) {
|
||||
return QR.autoPost();
|
||||
}
|
||||
}
|
||||
},
|
||||
receive: function(e) {
|
||||
@ -1379,14 +1391,19 @@
|
||||
}
|
||||
if (!(captcha = QR.captchaShift())) {
|
||||
alert('You forgot to type in the verification.');
|
||||
e.preventDefault();
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
}
|
||||
return;
|
||||
}
|
||||
challenge = captcha.challenge, response = captcha.response;
|
||||
$('#challenge', QR.el).value = challenge;
|
||||
$('#response', QR.el).value = response;
|
||||
if (conf['Auto Hide QR']) {
|
||||
return $('#autohide', QR.el).checked = true;
|
||||
$('#autohide', QR.el).checked = true;
|
||||
}
|
||||
if (!e) {
|
||||
return $('#qr_form', QR.el).submit;
|
||||
}
|
||||
},
|
||||
sys: function() {
|
||||
|
||||
@ -1015,7 +1015,7 @@ QR =
|
||||
<input type=hidden name=recaptcha_challenge_field id=challenge>
|
||||
<input type=hidden name=recaptcha_response_field id=response>
|
||||
<div><input placeholder=Email name=email></div>
|
||||
<div><input placeholder=Subject name=sub><button>Submit</button></div>
|
||||
<div><input placeholder=Subject name=sub><button>Submit</button><label>auto<input id=auto type=checkbox></label></div>
|
||||
<div><textarea placeholder=Comment name=com>#{text}</textarea></div>
|
||||
<div><img src=http://www.google.com/recaptcha/api/image?c=#{QR.captcha.challenge}></div>
|
||||
<div><input placeholder=Verification autocomplete=off id=recaptcha_response_field><span id=cl>#{$.get('captchas', []).length} captchas</span></div>
|
||||
@ -1033,9 +1033,14 @@ QR =
|
||||
l = text.length
|
||||
ta.setSelectionRange l, l
|
||||
ta.focus()
|
||||
hasContent: ->
|
||||
$('textarea', QR.el).value or $('[type=file]', QR.el).files.length
|
||||
autoPost: ->
|
||||
return unless QR.hasContent()
|
||||
QR.submit()
|
||||
keydown: (e) ->
|
||||
return unless e.keyCode is 13 and @value #enter, captcha filled
|
||||
return if $('textarea', QR.el).value or $('[type=file]', QR.el).files.length #not blank
|
||||
return if QR.hasContent()
|
||||
e.preventDefault()
|
||||
QR.captchaPush @
|
||||
quote: (e) ->
|
||||
@ -1058,14 +1063,15 @@ QR =
|
||||
n = Math.ceil (cooldown - now) / 1000
|
||||
b = $ 'button', QR.el
|
||||
if n > 0
|
||||
setTimeout QR.cooldown, 1000
|
||||
$.extend b,
|
||||
textContent: n
|
||||
disabled: true
|
||||
setTimeout QR.cooldown, 1000
|
||||
else
|
||||
$.extend b,
|
||||
textContent: 'Submit'
|
||||
disabled: false
|
||||
QR.autoPost() if $('#auto', QR.el).checked
|
||||
receive: (e) ->
|
||||
{data} = e
|
||||
if data
|
||||
@ -1077,17 +1083,19 @@ QR =
|
||||
$.set "cooldown/#{g.BOARD}", cooldown
|
||||
QR.cooldown()
|
||||
submit: (e) ->
|
||||
#XXX e is undefined if we're called from QR.autoPost
|
||||
$('.error', qr.el).textContent = ''
|
||||
if (el = $('#recaptcha_response_field', QR.el)).value
|
||||
QR.captchaPush el
|
||||
if not captcha = QR.captchaShift()
|
||||
alert 'You forgot to type in the verification.'
|
||||
e.preventDefault()
|
||||
e?.preventDefault()
|
||||
return
|
||||
{challenge, response} = captcha
|
||||
$('#challenge', QR.el).value = challenge
|
||||
$('#response', QR.el).value = response
|
||||
$('#autohide', QR.el).checked = true if conf['Auto Hide QR']
|
||||
$('#qr_form', QR.el).submit if not e
|
||||
sys: ->
|
||||
$.globalEval ->
|
||||
if node = document.querySelector('table font b')?.firstChild
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user