Updater responseType: document
This commit is contained in:
parent
096c081a80
commit
32433cf6d9
@ -331,14 +331,15 @@
|
|||||||
return fd;
|
return fd;
|
||||||
},
|
},
|
||||||
ajax: function(url, callbacks, opts) {
|
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) {
|
if (opts == null) {
|
||||||
opts = {};
|
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();
|
r = new XMLHttpRequest();
|
||||||
type || (type = form && 'post' || 'get');
|
type || (type = form && 'post' || 'get');
|
||||||
r.open(type, url, true);
|
r.open(type, url, true);
|
||||||
|
r.responseType = $.engine === 'presto' && responseType === 'document' ? '' : responseType || '';
|
||||||
for (key in headers) {
|
for (key in headers) {
|
||||||
val = headers[key];
|
val = headers[key];
|
||||||
r.setRequestHeader(key, val);
|
r.setRequestHeader(key, val);
|
||||||
@ -2617,8 +2618,12 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Updater.lastModified = this.getResponseHeader('Last-Modified');
|
Updater.lastModified = this.getResponseHeader('Last-Modified');
|
||||||
doc = d.implementation.createHTMLDocument('');
|
if ($.engine === 'presto') {
|
||||||
doc.documentElement.innerHTML = this.response;
|
doc = d.implementation.createHTMLDocument('');
|
||||||
|
doc.documentElement.innerHTML = this.response;
|
||||||
|
} else {
|
||||||
|
doc = this.response;
|
||||||
|
}
|
||||||
lastPost = Updater.thread.lastElementChild;
|
lastPost = Updater.thread.lastElementChild;
|
||||||
id = lastPost.id.slice(2);
|
id = lastPost.id.slice(2);
|
||||||
nodes = [];
|
nodes = [];
|
||||||
@ -2670,6 +2675,7 @@
|
|||||||
return Updater.request = $.ajax(url, {
|
return Updater.request = $.ajax(url, {
|
||||||
onload: Updater.cb.update
|
onload: Updater.cb.update
|
||||||
}, {
|
}, {
|
||||||
|
responseType: 'document',
|
||||||
headers: {
|
headers: {
|
||||||
'If-Modified-Since': Updater.lastModified
|
'If-Modified-Since': Updater.lastModified
|
||||||
}
|
}
|
||||||
|
|||||||
@ -274,10 +274,15 @@ $.extend $,
|
|||||||
fd.append key, val if val
|
fd.append key, val if val
|
||||||
fd
|
fd
|
||||||
ajax: (url, callbacks, opts={}) ->
|
ajax: (url, callbacks, opts={}) ->
|
||||||
{type, headers, upCallbacks, form} = opts
|
{type, responseType, headers, upCallbacks, form} = opts
|
||||||
r = new XMLHttpRequest()
|
r = new XMLHttpRequest()
|
||||||
type or= form and 'post' or 'get'
|
type or= form and 'post' or 'get'
|
||||||
r.open type, url, true
|
r.open type, url, true
|
||||||
|
r.responseType =
|
||||||
|
if $.engine is 'presto' and responseType is 'document'
|
||||||
|
''
|
||||||
|
else
|
||||||
|
responseType or ''
|
||||||
for key, val of headers
|
for key, val of headers
|
||||||
r.setRequestHeader key, val
|
r.setRequestHeader key, val
|
||||||
$.extend r, callbacks
|
$.extend r, callbacks
|
||||||
@ -2058,8 +2063,11 @@ Updater =
|
|||||||
return
|
return
|
||||||
Updater.lastModified = @getResponseHeader 'Last-Modified'
|
Updater.lastModified = @getResponseHeader 'Last-Modified'
|
||||||
|
|
||||||
doc = d.implementation.createHTMLDocument ''
|
if $.engine is 'presto'
|
||||||
doc.documentElement.innerHTML = @response
|
doc = d.implementation.createHTMLDocument ''
|
||||||
|
doc.documentElement.innerHTML = @response
|
||||||
|
else
|
||||||
|
doc = @response
|
||||||
|
|
||||||
lastPost = Updater.thread.lastElementChild
|
lastPost = Updater.thread.lastElementChild
|
||||||
id = lastPost.id[2..]
|
id = lastPost.id[2..]
|
||||||
@ -2093,15 +2101,16 @@ Updater =
|
|||||||
|
|
||||||
retry: ->
|
retry: ->
|
||||||
@count.textContent = 'Retry'
|
@count.textContent = 'Retry'
|
||||||
@count.className = null
|
@count.className = null
|
||||||
@update()
|
@update()
|
||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
Updater.timer.textContent = 0
|
Updater.timer.textContent = 0
|
||||||
Updater.request?.abort()
|
Updater.request?.abort()
|
||||||
#fool the cache
|
# Fool the cache.
|
||||||
url = location.pathname + '?' + Date.now()
|
url = location.pathname + '?' + Date.now()
|
||||||
Updater.request = $.ajax url, onload: Updater.cb.update,
|
Updater.request = $.ajax url, onload: Updater.cb.update,
|
||||||
|
responseType: 'document'
|
||||||
headers: 'If-Modified-Since': Updater.lastModified
|
headers: 'If-Modified-Since': Updater.lastModified
|
||||||
|
|
||||||
Watcher =
|
Watcher =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user