commit
30b3f50046
@ -326,13 +326,20 @@
|
||||
$.add(d.head, script);
|
||||
return $.rm(script);
|
||||
},
|
||||
ajax: function(url, cb, type, event) {
|
||||
var r;
|
||||
if (type == null) type = 'get';
|
||||
if (event == null) event = 'onload';
|
||||
ajax: function(url, cb, opts) {
|
||||
var event, headers, key, r, type, val;
|
||||
if (opts == null) opts = {};
|
||||
type = opts.type, event = opts.event, headers = opts.headers;
|
||||
type || (type = 'get');
|
||||
event || (event = 'onload');
|
||||
r = new XMLHttpRequest();
|
||||
for (key in headers) {
|
||||
val = headers[key];
|
||||
r.setRequestHeader(key, val);
|
||||
}
|
||||
r[event] = cb;
|
||||
r.open(type, url, true);
|
||||
r.send();
|
||||
return r;
|
||||
},
|
||||
cache: function(url, cb) {
|
||||
@ -354,7 +361,6 @@
|
||||
}
|
||||
return _results;
|
||||
}));
|
||||
req.send();
|
||||
req.callbacks = [cb];
|
||||
return $.cache.requests[url] = req;
|
||||
}
|
||||
@ -2096,9 +2102,11 @@
|
||||
updater.timer.textContent = 0;
|
||||
if ((_ref = updater.request) != null) _ref.abort();
|
||||
url = location.pathname + '?' + Date.now();
|
||||
updater.request = $.ajax(url, updater.cb.update);
|
||||
updater.request.setRequestHeader('If-Modified-Since', updater.lastModified);
|
||||
return updater.request.send();
|
||||
return updater.request = $.ajax(url, updater.cb.update, {
|
||||
headers: {
|
||||
'If-Modified-Since': updater.lastModified
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -2996,12 +3004,14 @@
|
||||
thumb = this.previousSibling;
|
||||
imgExpand.contract(thumb);
|
||||
if (engine === 'webkit') {
|
||||
req = $.ajax(this.src, (function() {
|
||||
return req = $.ajax(this.src, (function() {
|
||||
if (this.status !== 404) {
|
||||
return setTimeout(imgExpand.retry, 10000, thumb);
|
||||
}
|
||||
}), 'head', 'onreadystatechange');
|
||||
return req.send();
|
||||
}), {
|
||||
type: 'head',
|
||||
event: 'onreadystatechange'
|
||||
});
|
||||
} else if (!g.dead) {
|
||||
return setTimeout(imgExpand.retry, 10000, thumb);
|
||||
}
|
||||
|
||||
@ -231,10 +231,16 @@ $.extend $,
|
||||
textContent: "(#{code})()"
|
||||
$.add d.head, script
|
||||
$.rm script
|
||||
ajax: (url, cb, type='get', event='onload') ->
|
||||
ajax: (url, cb, opts={}) ->
|
||||
{type, event, headers} = opts
|
||||
type or= 'get'
|
||||
event or= 'onload'
|
||||
r = new XMLHttpRequest()
|
||||
for key, val of headers
|
||||
r.setRequestHeader key, val
|
||||
r[event] = cb
|
||||
r.open type, url, true
|
||||
r.send()
|
||||
r
|
||||
cache: (url, cb) ->
|
||||
if req = $.cache.requests[url]
|
||||
@ -244,7 +250,6 @@ $.extend $,
|
||||
req.callbacks.push cb
|
||||
else
|
||||
req = $.ajax url, (-> cb.call @ for cb in @callbacks)
|
||||
req.send()
|
||||
req.callbacks = [cb]
|
||||
$.cache.requests[url] = req
|
||||
cb:
|
||||
@ -1684,9 +1689,7 @@ updater =
|
||||
updater.request?.abort()
|
||||
#fool the cache
|
||||
url = location.pathname + '?' + Date.now()
|
||||
updater.request = $.ajax url, updater.cb.update
|
||||
updater.request.setRequestHeader 'If-Modified-Since', updater.lastModified
|
||||
updater.request.send()
|
||||
updater.request = $.ajax url, updater.cb.update, headers: 'If-Modified-Since': updater.lastModified
|
||||
|
||||
watcher =
|
||||
init: ->
|
||||
@ -2321,8 +2324,7 @@ imgExpand =
|
||||
if engine is 'webkit'
|
||||
req = $.ajax @src, (->
|
||||
setTimeout imgExpand.retry, 10000, thumb if @status isnt 404
|
||||
), 'head', 'onreadystatechange'
|
||||
req.send()
|
||||
), type: 'head', event: 'onreadystatechange'
|
||||
#Firefox returns a status code of 0 because of the same origin policy
|
||||
#Oprah doesn't send any request
|
||||
else unless g.dead
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user