Revert "Updater responseType: document"

This reverts commit 32433cf6d9b6d464cf99a7f111459a1325444443.
This commit is contained in:
Nicolas Stepien 2012-06-22 13:49:43 +02:00
parent 26bb727749
commit f8fe4e4ef8
2 changed files with 22 additions and 55 deletions

View File

@ -332,15 +332,14 @@
return fd; return fd;
}, },
ajax: function(url, callbacks, opts) { ajax: function(url, callbacks, opts) {
var form, headers, key, r, responseType, type, upCallbacks, val; var form, headers, key, r, type, upCallbacks, val;
if (opts == null) { if (opts == null) {
opts = {}; opts = {};
} }
type = opts.type, responseType = opts.responseType, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form; type = opts.type, 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);
@ -2132,7 +2131,6 @@
}; };
opts = { opts = {
form: $.formData(post), form: $.formData(post),
responseType: 'document',
upCallbacks: { upCallbacks: {
onload: function() { onload: function() {
return QR.status({ return QR.status({
@ -2148,14 +2146,10 @@
}; };
return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts); return QR.ajax = $.ajax($.id('postForm').parentNode.action, callbacks, opts);
}, },
response: function(response) { response: function(html) {
var bs, doc, err, msg, persona, postNumber, reply, thread, _, _ref; var bs, doc, err, msg, persona, postNumber, reply, thread, _, _ref;
if ($.engine === 'presto') { doc = d.implementation.createHTMLDocument('');
doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = html;
doc.documentElement.innerHTML = response;
} else {
doc = response;
}
if (doc.title === '4chan - Banned') { if (doc.title === '4chan - Banned') {
bs = $$('b', doc); bs = $$('b', doc);
err = $.el('span', { err = $.el('span', {
@ -2639,12 +2633,8 @@
return; return;
} }
Updater.lastModified = this.getResponseHeader('Last-Modified'); Updater.lastModified = this.getResponseHeader('Last-Modified');
if ($.engine === 'presto') { doc = d.implementation.createHTMLDocument('');
doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = this.response;
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 = [];
@ -2696,7 +2686,6 @@
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
} }
@ -3764,18 +3753,13 @@
return DeleteButton.error(self); return DeleteButton.error(self);
} }
}, { }, {
form: $.formData(form), form: $.formData(form)
responseType: 'document'
}); });
}, },
load: function(self, response) { load: function(self, html) {
var doc, msg, s; var doc, msg, s;
if ($.engine === 'presto') { doc = d.implementation.createHTMLDocument('');
doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = html;
doc.documentElement.innerHTML = response;
} else {
doc = response;
}
if (doc.title === '4chan - Banned') { if (doc.title === '4chan - Banned') {
s = 'Banned!'; s = 'Banned!';
} else if (msg = doc.getElementById('errmsg')) { } else if (msg = doc.getElementById('errmsg')) {

View File

@ -274,15 +274,10 @@ $.extend $,
fd.append key, val if val fd.append key, val if val
fd fd
ajax: (url, callbacks, opts={}) -> ajax: (url, callbacks, opts={}) ->
{type, responseType, headers, upCallbacks, form} = opts {type, 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
@ -1618,7 +1613,6 @@ QR =
textContent: 'Connection error, or you are banned.' textContent: 'Connection error, or you are banned.'
opts = opts =
form: $.formData post form: $.formData post
responseType: 'document'
upCallbacks: upCallbacks:
onload: -> onload: ->
# Upload done, waiting for response. # Upload done, waiting for response.
@ -1629,12 +1623,9 @@ QR =
QR.ajax = $.ajax $.id('postForm').parentNode.action, callbacks, opts QR.ajax = $.ajax $.id('postForm').parentNode.action, callbacks, opts
response: (response) -> response: (html) ->
if $.engine is 'presto' doc = d.implementation.createHTMLDocument ''
doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = html
doc.documentElement.innerHTML = response
else
doc = response
if doc.title is '4chan - Banned' # Ban/warn check if doc.title is '4chan - Banned' # Ban/warn check
bs = $$ 'b', doc bs = $$ 'b', doc
err = $.el 'span', err = $.el 'span',
@ -2080,11 +2071,8 @@ Updater =
return return
Updater.lastModified = @getResponseHeader 'Last-Modified' Updater.lastModified = @getResponseHeader 'Last-Modified'
if $.engine is 'presto' doc = d.implementation.createHTMLDocument ''
doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = @response
doc.documentElement.innerHTML = @response
else
doc = @response
lastPost = Updater.thread.lastElementChild lastPost = Updater.thread.lastElementChild
id = lastPost.id[2..] id = lastPost.id[2..]
@ -2118,16 +2106,15 @@ 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 =
@ -2954,15 +2941,11 @@ DeleteButton =
onerror: -> DeleteButton.error self onerror: -> DeleteButton.error self
}, { }, {
form: $.formData form form: $.formData form
responseType: 'document'
} }
load: (self, response) -> load: (self, html) ->
if $.engine is 'presto' doc = d.implementation.createHTMLDocument ''
doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = html
doc.documentElement.innerHTML = response
else
doc = response
if doc.title is '4chan - Banned' # Ban/warn check if doc.title is '4chan - Banned' # Ban/warn check
s = 'Banned!' s = 'Banned!'
else if msg = doc.getElementById 'errmsg' # error! else if msg = doc.getElementById 'errmsg' # error!