Abort the post submit when closing the QR. Fix stored captcha timeout checking when submitting. Probably fix some persona checking after post submission. Don't wait for the very slow sys.4chan.org to load to start listening to messages and send XHRs.
This commit is contained in:
parent
ce2cf2891e
commit
e357fec7f5
@ -1233,6 +1233,9 @@
|
||||
close: function() {
|
||||
var i, spoiler, _i, _len, _ref;
|
||||
qr.el.hidden = true;
|
||||
qr.message.send({
|
||||
abort: true
|
||||
});
|
||||
d.activeElement.blur();
|
||||
$.removeClass(qr.el, 'dump');
|
||||
_ref = qr.replies;
|
||||
@ -1542,7 +1545,7 @@
|
||||
return $.add(d.body, qr.el);
|
||||
},
|
||||
submit: function(e) {
|
||||
var captcha, captchas, challenge, err, file, m, now, post, reader, reply, response, threadID;
|
||||
var captcha, captchas, challenge, err, file, m, now, post, reader, reply, response, threadID, time;
|
||||
if (e != null) e.preventDefault();
|
||||
qr.message.send({
|
||||
abort: true
|
||||
@ -1554,7 +1557,7 @@
|
||||
captchas = $.get('captchas', []);
|
||||
if (captchas.length) {
|
||||
now = Date.now();
|
||||
while (captchas[0].time < now) {
|
||||
while ((time = captchas[0].time) && time < now) {
|
||||
captchas.shift();
|
||||
}
|
||||
}
|
||||
@ -1621,7 +1624,6 @@
|
||||
console.dir(b);
|
||||
return;
|
||||
}
|
||||
if (!(conf['Persistent QR'] || qr.replies.length > 1)) qr.close();
|
||||
reply = qr.replies[0];
|
||||
sage = /sage/i.test(reply.email);
|
||||
persona = {
|
||||
@ -1630,11 +1632,15 @@
|
||||
sub: conf['Remember Subject'] ? reply.sub : null
|
||||
};
|
||||
$.set('qr.persona', persona);
|
||||
return reply.rm();
|
||||
if (conf['Persistent QR'] || qr.replies.length > 1) {
|
||||
return reply.rm();
|
||||
} else {
|
||||
return qr.close();
|
||||
}
|
||||
},
|
||||
message: {
|
||||
init: function() {
|
||||
var code, script;
|
||||
var code;
|
||||
code = function(e) {
|
||||
var data, host;
|
||||
data = e.data;
|
||||
@ -1647,13 +1653,7 @@
|
||||
return parent.postMessage(data, '*');
|
||||
}
|
||||
};
|
||||
script = $.el('script', {
|
||||
textContent: "window.addEventListener('message'," + code + ",false)"
|
||||
});
|
||||
return $.ready(function() {
|
||||
$.add(d.head, script);
|
||||
return $.rm(script);
|
||||
});
|
||||
return window.location = "javascript:window.addEventListener('message'," + code + ",false)";
|
||||
},
|
||||
send: function(data) {
|
||||
data.changeContext = true;
|
||||
|
||||
@ -897,6 +897,7 @@ qr =
|
||||
qr.dialog()
|
||||
close: ->
|
||||
qr.el.hidden = true
|
||||
qr.message.send abort: true
|
||||
d.activeElement.blur()
|
||||
$.removeClass qr.el, 'dump'
|
||||
for i in qr.replies
|
||||
@ -1172,7 +1173,7 @@ qr =
|
||||
if captchas.length
|
||||
# remove old captchas
|
||||
now = Date.now()
|
||||
while captchas[0].time < now
|
||||
while (time = captchas[0].time) and time < now
|
||||
captchas.shift()
|
||||
if captcha = captchas.shift()
|
||||
challenge = captcha.challenge
|
||||
@ -1238,9 +1239,6 @@ qr =
|
||||
# error handling
|
||||
return
|
||||
|
||||
unless conf['Persistent QR'] or qr.replies.length > 1
|
||||
qr.close()
|
||||
|
||||
reply = qr.replies[0]
|
||||
sage = /sage/i.test reply.email
|
||||
# cooldown
|
||||
@ -1251,7 +1249,10 @@ qr =
|
||||
sub: if conf['Remember Subject'] then reply.sub else null
|
||||
$.set 'qr.persona', persona
|
||||
|
||||
reply.rm()
|
||||
if conf['Persistent QR'] or qr.replies.length > 1
|
||||
reply.rm()
|
||||
else
|
||||
qr.close()
|
||||
|
||||
message:
|
||||
init: ->
|
||||
@ -1268,11 +1269,8 @@ qr =
|
||||
document.getElementById('iframe').contentWindow.postMessage data, '*'
|
||||
else if host is 'sys.4chan.org'
|
||||
parent.postMessage data, '*'
|
||||
script = $.el 'script',
|
||||
textContent: "window.addEventListener('message',#{code},false)"
|
||||
$.ready ->
|
||||
$.add d.head, script
|
||||
$.rm script
|
||||
# do not wait for 4chan to load
|
||||
window.location = "javascript:window.addEventListener('message',#{code},false)"
|
||||
send: (data) ->
|
||||
data.changeContext = true
|
||||
data.qr = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user