simplify request callback

This commit is contained in:
James Campos 2010-12-28 16:52:06 -08:00
parent f7e2ddbff5
commit c2985dbe95
2 changed files with 6 additions and 8 deletions

View File

@ -806,13 +806,13 @@ threadF = (current) ->
request = (url, callback) -> request = (url, callback) ->
r = new XMLHttpRequest() r = new XMLHttpRequest()
r.onload = -> callback this r.onload = callback
r.open 'get', url, true r.open 'get', url, true
r.send() r.send()
r r
updateCallback = (res) -> updateCallback = ->
body = n 'body', innerHTML: res.responseText body = n 'body', innerHTML: @responseText
replies = $$ 'td.reply', body replies = $$ 'td.reply', body
root = $('br[clear]').previousElementSibling root = $('br[clear]').previousElementSibling

View File

@ -1064,17 +1064,15 @@
request = function(url, callback) { request = function(url, callback) {
var r; var r;
r = new XMLHttpRequest(); r = new XMLHttpRequest();
r.onload = function() { r.onload = callback;
return callback(this);
};
r.open('get', url, true); r.open('get', url, true);
r.send(); r.send();
return r; return r;
}; };
updateCallback = function(res) { updateCallback = function() {
var body, count, i, id, replies, reply, root, span, table; var body, count, i, id, replies, reply, root, span, table;
body = n('body', { body = n('body', {
innerHTML: res.responseText innerHTML: this.responseText
}); });
replies = $$('td.reply', body); replies = $$('td.reply', body);
root = $('br[clear]').previousElementSibling; root = $('br[clear]').previousElementSibling;