Disable the submit button until the iframe is ready.
This commit is contained in:
parent
966b84ea71
commit
41bc376644
@ -1271,15 +1271,24 @@
|
|||||||
return $('.error', qr.el).textContent = null;
|
return $('.error', qr.el).textContent = null;
|
||||||
},
|
},
|
||||||
status: function(data) {
|
status: function(data) {
|
||||||
var disabled, value;
|
var disabled, input, value;
|
||||||
|
if (data == null) data = {};
|
||||||
|
input = qr.status.input;
|
||||||
|
if (data.ready) {
|
||||||
|
qr.status.ready = true;
|
||||||
|
if (!qr.el) return;
|
||||||
|
} else if (!qr.status.ready) {
|
||||||
|
value = 'Loading';
|
||||||
|
disabled = true;
|
||||||
|
}
|
||||||
if (g.dead) {
|
if (g.dead) {
|
||||||
value = 404;
|
value = 404;
|
||||||
disabled = true;
|
disabled = true;
|
||||||
} else if (data) {
|
} else if (data.progress) {
|
||||||
if (data.progress) value = data.progress;
|
value = data.progress;
|
||||||
}
|
}
|
||||||
qr.status.input.value = value || 'Submit';
|
input.value = value || 'Submit';
|
||||||
return qr.status.input.disabled = disabled || false;
|
return input.disabled = disabled || false;
|
||||||
},
|
},
|
||||||
pickThread: function(thread) {
|
pickThread: function(thread) {
|
||||||
return $('select', qr.el).value = thread;
|
return $('select', qr.el).value = thread;
|
||||||
@ -1677,7 +1686,7 @@
|
|||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
init: function() {
|
init: function() {
|
||||||
var code, script;
|
var code, ready, script;
|
||||||
code = function(e) {
|
code = function(e) {
|
||||||
var data, host;
|
var data, host;
|
||||||
data = e.data;
|
data = e.data;
|
||||||
@ -1693,14 +1702,24 @@
|
|||||||
script = $.el('script', {
|
script = $.el('script', {
|
||||||
textContent: "window.addEventListener('message'," + code + ",false)"
|
textContent: "window.addEventListener('message'," + code + ",false)"
|
||||||
});
|
});
|
||||||
|
ready = function() {
|
||||||
|
if (location.hostname === 'sys.4chan.org') {
|
||||||
|
return qr.message.send({
|
||||||
|
status: true,
|
||||||
|
ready: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
if (d.documentElement) {
|
if (d.documentElement) {
|
||||||
$.add(d.documentElement, script);
|
$.add(d.documentElement, script);
|
||||||
$.rm(script);
|
$.rm(script);
|
||||||
|
ready();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.ready(function() {
|
return $.ready(function() {
|
||||||
$.add(d.head, script);
|
$.add(d.head, script);
|
||||||
return $.rm(script);
|
$.rm(script);
|
||||||
|
return ready();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
send: function(data) {
|
send: function(data) {
|
||||||
|
|||||||
@ -914,15 +914,21 @@ qr =
|
|||||||
cleanError: ->
|
cleanError: ->
|
||||||
$('.error', qr.el).textContent = null
|
$('.error', qr.el).textContent = null
|
||||||
|
|
||||||
status: (data) ->
|
status: (data={}) ->
|
||||||
|
{input} = qr.status
|
||||||
|
if data.ready
|
||||||
|
qr.status.ready = true
|
||||||
|
return unless qr.el
|
||||||
|
else unless qr.status.ready
|
||||||
|
value = 'Loading'
|
||||||
|
disabled = true
|
||||||
if g.dead
|
if g.dead
|
||||||
value = 404
|
value = 404
|
||||||
disabled = true
|
disabled = true
|
||||||
else if data
|
else if data.progress
|
||||||
if data.progress
|
value = data.progress
|
||||||
value = data.progress
|
input.value = value or 'Submit'
|
||||||
qr.status.input.value = value or 'Submit'
|
input.disabled = disabled or false
|
||||||
qr.status.input.disabled = disabled or false
|
|
||||||
|
|
||||||
pickThread: (thread) ->
|
pickThread: (thread) ->
|
||||||
$('select', qr.el).value = thread
|
$('select', qr.el).value = thread
|
||||||
@ -1183,7 +1189,6 @@ qr =
|
|||||||
unless response
|
unless response
|
||||||
err = 'No valid captcha.'
|
err = 'No valid captcha.'
|
||||||
|
|
||||||
# more error prevention ?
|
|
||||||
if err
|
if err
|
||||||
qr.error err
|
qr.error err
|
||||||
return
|
return
|
||||||
@ -1273,15 +1278,20 @@ qr =
|
|||||||
else if host is 'sys.4chan.org'
|
else if host is 'sys.4chan.org'
|
||||||
parent.postMessage data, '*'
|
parent.postMessage data, '*'
|
||||||
script = $.el 'script', textContent: "window.addEventListener('message',#{code},false)"
|
script = $.el 'script', textContent: "window.addEventListener('message',#{code},false)"
|
||||||
|
ready = ->
|
||||||
|
if location.hostname is 'sys.4chan.org'
|
||||||
|
qr.message.send status: true, ready: true
|
||||||
# Chrome can access the documentElement on document-start
|
# Chrome can access the documentElement on document-start
|
||||||
if d.documentElement
|
if d.documentElement
|
||||||
$.add d.documentElement, script
|
$.add d.documentElement, script
|
||||||
$.rm script
|
$.rm script
|
||||||
|
ready()
|
||||||
return
|
return
|
||||||
# other browsers will have to wait
|
# other browsers will have to wait
|
||||||
$.ready ->
|
$.ready ->
|
||||||
$.add d.head, script
|
$.add d.head, script
|
||||||
$.rm script
|
$.rm script
|
||||||
|
ready()
|
||||||
send: (data) ->
|
send: (data) ->
|
||||||
data.changeContext = true
|
data.changeContext = true
|
||||||
data.qr = true
|
data.qr = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user