Updater responseType: document

This commit is contained in:
Nicolas Stepien 2012-06-20 22:13:23 +02:00
parent 096c081a80
commit 32433cf6d9
2 changed files with 24 additions and 9 deletions

View File

@ -331,14 +331,15 @@
return fd;
},
ajax: function(url, callbacks, opts) {
var form, headers, key, r, type, upCallbacks, val;
var form, headers, key, r, responseType, type, upCallbacks, val;
if (opts == null) {
opts = {};
}
type = opts.type, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form;
type = opts.type, responseType = opts.responseType, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form;
r = new XMLHttpRequest();
type || (type = form && 'post' || 'get');
r.open(type, url, true);
r.responseType = $.engine === 'presto' && responseType === 'document' ? '' : responseType || '';
for (key in headers) {
val = headers[key];
r.setRequestHeader(key, val);
@ -2617,8 +2618,12 @@
return;
}
Updater.lastModified = this.getResponseHeader('Last-Modified');
doc = d.implementation.createHTMLDocument('');
doc.documentElement.innerHTML = this.response;
if ($.engine === 'presto') {
doc = d.implementation.createHTMLDocument('');
doc.documentElement.innerHTML = this.response;
} else {
doc = this.response;
}
lastPost = Updater.thread.lastElementChild;
id = lastPost.id.slice(2);
nodes = [];
@ -2670,6 +2675,7 @@
return Updater.request = $.ajax(url, {
onload: Updater.cb.update
}, {
responseType: 'document',
headers: {
'If-Modified-Since': Updater.lastModified
}

View File

@ -274,10 +274,15 @@ $.extend $,
fd.append key, val if val
fd
ajax: (url, callbacks, opts={}) ->
{type, headers, upCallbacks, form} = opts
{type, responseType, headers, upCallbacks, form} = opts
r = new XMLHttpRequest()
type or= form and 'post' or 'get'
r.open type, url, true
r.responseType =
if $.engine is 'presto' and responseType is 'document'
''
else
responseType or ''
for key, val of headers
r.setRequestHeader key, val
$.extend r, callbacks
@ -2058,8 +2063,11 @@ Updater =
return
Updater.lastModified = @getResponseHeader 'Last-Modified'
doc = d.implementation.createHTMLDocument ''
doc.documentElement.innerHTML = @response
if $.engine is 'presto'
doc = d.implementation.createHTMLDocument ''
doc.documentElement.innerHTML = @response
else
doc = @response
lastPost = Updater.thread.lastElementChild
id = lastPost.id[2..]
@ -2093,15 +2101,16 @@ Updater =
retry: ->
@count.textContent = 'Retry'
@count.className = null
@count.className = null
@update()
update: ->
Updater.timer.textContent = 0
Updater.request?.abort()
#fool the cache
# Fool the cache.
url = location.pathname + '?' + Date.now()
Updater.request = $.ajax url, onload: Updater.cb.update,
responseType: 'document'
headers: 'If-Modified-Since': Updater.lastModified
Watcher =