Small refactor.

This commit is contained in:
Nicolas Stepien 2012-01-25 19:19:54 +01:00
parent 41bc376644
commit a65faabcbe
2 changed files with 7 additions and 12 deletions

View File

@ -1273,10 +1273,8 @@
status: function(data) { status: function(data) {
var disabled, input, value; var disabled, input, value;
if (data == null) data = {}; if (data == null) data = {};
input = qr.status.input;
if (data.ready) { if (data.ready) {
qr.status.ready = true; qr.status.ready = true;
if (!qr.el) return;
} else if (!qr.status.ready) { } else if (!qr.status.ready) {
value = 'Loading'; value = 'Loading';
disabled = true; disabled = true;
@ -1287,6 +1285,8 @@
} else if (data.progress) { } else if (data.progress) {
value = data.progress; value = data.progress;
} }
if (!qr.el) return;
input = qr.status.input;
input.value = value || 'Submit'; input.value = value || 'Submit';
return input.disabled = disabled || false; return input.disabled = disabled || false;
}, },
@ -2223,18 +2223,15 @@
} }
}, },
update: function() { update: function() {
var body, frag, id, input, newPosts, reply, scroll, _i, _len, _ref, _ref2; var body, frag, id, newPosts, reply, scroll, _i, _len, _ref, _ref2;
if (this.status === 404) { if (this.status === 404) {
updater.timer.textContent = ''; updater.timer.textContent = '';
updater.count.textContent = 404; updater.count.textContent = 404;
updater.count.className = 'error'; updater.count.className = 'error';
clearTimeout(updater.timeoutID); clearTimeout(updater.timeoutID);
if (input = $('#qr [type=submit]', qr.el)) {
input.disabled = true;
input.value = 404;
}
d.title = d.title.match(/^.+-/)[0] + ' 404'; d.title = d.title.match(/^.+-/)[0] + ' 404';
g.dead = true; g.dead = true;
qr.status();
Favicon.update(); Favicon.update();
return; return;
} }

View File

@ -915,10 +915,8 @@ qr =
$('.error', qr.el).textContent = null $('.error', qr.el).textContent = null
status: (data={}) -> status: (data={}) ->
{input} = qr.status
if data.ready if data.ready
qr.status.ready = true qr.status.ready = true
return unless qr.el
else unless qr.status.ready else unless qr.status.ready
value = 'Loading' value = 'Loading'
disabled = true disabled = true
@ -927,6 +925,8 @@ qr =
disabled = true disabled = true
else if data.progress else if data.progress
value = data.progress value = data.progress
return unless qr.el
{input} = qr.status
input.value = value or 'Submit' input.value = value or 'Submit'
input.disabled = disabled or false input.disabled = disabled or false
@ -1722,11 +1722,9 @@ updater =
updater.count.textContent = 404 updater.count.textContent = 404
updater.count.className = 'error' updater.count.className = 'error'
clearTimeout updater.timeoutID clearTimeout updater.timeoutID
if input = $ '#qr [type=submit]', qr.el
input.disabled = true
input.value = 404
d.title = d.title.match(/^.+-/)[0] + ' 404' d.title = d.title.match(/^.+-/)[0] + ' 404'
g.dead = true g.dead = true
qr.status()
Favicon.update() Favicon.update()
return return