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