Revert "More responseType document/json."
This reverts commit ea73f35be72af9fc7b0fdda5f21a1899b49d1f04. Conflicts: script.coffee
This commit is contained in:
parent
d6a11b79d5
commit
26bb727749
@ -340,7 +340,7 @@
|
||||
r = new XMLHttpRequest();
|
||||
type || (type = form && 'post' || 'get');
|
||||
r.open(type, url, true);
|
||||
r.responseType = $.engine === 'presto' && responseType === 'document' || $.engine === 'webkit' && responseType === 'json' ? '' : responseType || '';
|
||||
r.responseType = $.engine === 'presto' && responseType === 'document' ? '' : responseType || '';
|
||||
for (key in headers) {
|
||||
val = headers[key];
|
||||
r.setRequestHeader(key, val);
|
||||
@ -350,7 +350,7 @@
|
||||
r.send(form);
|
||||
return r;
|
||||
},
|
||||
cache: function(url, responseType, cb) {
|
||||
cache: function(url, cb) {
|
||||
var req;
|
||||
if (req = $.cache.requests[url]) {
|
||||
if (req.readyState === 4) {
|
||||
@ -376,8 +376,6 @@
|
||||
onerror: function() {
|
||||
return delete $.cache.requests[url];
|
||||
}
|
||||
}, {
|
||||
responseType: responseType
|
||||
});
|
||||
req.callbacks = [cb];
|
||||
return $.cache.requests[url] = req;
|
||||
@ -779,7 +777,7 @@
|
||||
_ref = this.href.match(/(\d+)#p(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2];
|
||||
this.textContent = "Loading " + replyID + "...";
|
||||
a = this;
|
||||
return $.cache(this.pathname, 'document', function() {
|
||||
return $.cache(this.pathname, function() {
|
||||
return ExpandComment.parse(this, a, threadID, replyID);
|
||||
});
|
||||
},
|
||||
@ -789,12 +787,8 @@
|
||||
a.textContent = "" + req.status + " " + req.statusText;
|
||||
return;
|
||||
}
|
||||
if ($.engine === 'presto') {
|
||||
doc = d.implementation.createHTMLDocument('');
|
||||
doc.documentElement.innerHTML = req.response;
|
||||
} else {
|
||||
doc = req.response;
|
||||
}
|
||||
doc = d.implementation.createHTMLDocument('');
|
||||
doc.documentElement.innerHTML = req.response;
|
||||
node = d.importNode(doc.getElementById("m" + replyID), true);
|
||||
quotes = node.getElementsByClassName('quotelink');
|
||||
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
|
||||
@ -857,7 +851,7 @@
|
||||
switch (a.textContent[0]) {
|
||||
case '+':
|
||||
a.textContent = a.textContent.replace('+', '\u00d7 Loading...');
|
||||
$.cache(pathname, 'document', function() {
|
||||
$.cache(pathname, function() {
|
||||
return ExpandThread.parse(this, thread, a);
|
||||
});
|
||||
break;
|
||||
@ -894,12 +888,8 @@
|
||||
return;
|
||||
}
|
||||
a.textContent = a.textContent.replace('\u00d7 Loading...', '-');
|
||||
if ($.engine === 'presto') {
|
||||
doc = d.implementation.createHTMLDocument('');
|
||||
doc.documentElement.innerHTML = req.response;
|
||||
} else {
|
||||
doc = req.response;
|
||||
}
|
||||
doc = d.implementation.createHTMLDocument('');
|
||||
doc.documentElement.innerHTML = req.response;
|
||||
threadID = thread.id.slice(1);
|
||||
nodes = [];
|
||||
_ref = $$('.replyContainer', doc);
|
||||
@ -3127,11 +3117,11 @@
|
||||
}
|
||||
root.textContent = "Loading post No." + postID + "...";
|
||||
if (threadID) {
|
||||
return $.cache("/" + board + "/res/" + threadID, 'document', function() {
|
||||
return $.cache("/" + board + "/res/" + threadID, function() {
|
||||
return Get.parsePost(this, board, threadID, postID, root, cb);
|
||||
});
|
||||
} else if (url = Redirect.post(board, postID)) {
|
||||
return $.cache(url, 'json', function() {
|
||||
return $.cache(url, function() {
|
||||
return Get.parseArchivedPost(this, board, postID, root, cb);
|
||||
});
|
||||
}
|
||||
@ -3141,7 +3131,7 @@
|
||||
status = req.status;
|
||||
if (status !== 200) {
|
||||
if (url = Redirect.post(board, postID)) {
|
||||
$.cache(url, 'json', function() {
|
||||
$.cache(url, function() {
|
||||
return Get.parseArchivedPost(this, board, postID, root, cb);
|
||||
});
|
||||
} else {
|
||||
@ -3149,15 +3139,11 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ($.engine === 'presto') {
|
||||
doc = d.implementation.createHTMLDocument('');
|
||||
doc.documentElement.innerHTML = req.response;
|
||||
} else {
|
||||
doc = req.response;
|
||||
}
|
||||
doc = d.implementation.createHTMLDocument('');
|
||||
doc.documentElement.innerHTML = req.response;
|
||||
if (!(pc = doc.getElementById("pc" + postID))) {
|
||||
if (url = Redirect.post(board, postID)) {
|
||||
$.cache(url, 'json', function() {
|
||||
$.cache(url, function() {
|
||||
return Get.parseArchivedPost(this, board, postID, root, cb);
|
||||
});
|
||||
} else {
|
||||
@ -3185,11 +3171,7 @@
|
||||
},
|
||||
parseArchivedPost: function(req, board, postID, root, cb) {
|
||||
var bq, br, capcode, data, email, file, filename, filesize, isOP, max, name, nameBlock, pc, pi, piM, span, spoiler, subject, threadID, thumb_src, timestamp, trip;
|
||||
if ($.engine === 'webkit') {
|
||||
data = JSON.parse(req.response);
|
||||
} else {
|
||||
data = req.response;
|
||||
}
|
||||
data = JSON.parse(req.response);
|
||||
$.addClass(root, 'archivedPost');
|
||||
if (data.error) {
|
||||
root.textContent = data.error;
|
||||
|
||||
@ -279,9 +279,7 @@ $.extend $,
|
||||
type or= form and 'post' or 'get'
|
||||
r.open type, url, true
|
||||
r.responseType =
|
||||
# XXX Chrome doesn't support 'json' as responseType yet.
|
||||
# XXX Opera gives an XMLDocument for 'document'.
|
||||
if $.engine is 'presto' and responseType is 'document' or $.engine is 'webkit' and responseType is 'json'
|
||||
if $.engine is 'presto' and responseType is 'document'
|
||||
''
|
||||
else
|
||||
responseType or ''
|
||||
@ -291,20 +289,17 @@ $.extend $,
|
||||
$.extend r.upload, upCallbacks
|
||||
r.send form
|
||||
r
|
||||
cache: (url, responseType, cb) ->
|
||||
cache: (url, cb) ->
|
||||
if req = $.cache.requests[url]
|
||||
if req.readyState is 4
|
||||
cb.call req
|
||||
else
|
||||
req.callbacks.push cb
|
||||
else
|
||||
req = $.ajax url, {
|
||||
req = $.ajax url,
|
||||
onload: -> cb.call @ for cb in @callbacks
|
||||
onabort: -> delete $.cache.requests[url]
|
||||
onerror: -> delete $.cache.requests[url]
|
||||
}, {
|
||||
responseType: responseType
|
||||
}
|
||||
req.callbacks = [cb]
|
||||
$.cache.requests[url] = req
|
||||
cb:
|
||||
@ -608,17 +603,14 @@ ExpandComment =
|
||||
[_, threadID, replyID] = @href.match /(\d+)#p(\d+)/
|
||||
@textContent = "Loading #{replyID}..."
|
||||
a = @
|
||||
$.cache @pathname, 'document', -> ExpandComment.parse @, a, threadID, replyID
|
||||
$.cache @pathname, -> ExpandComment.parse @, a, threadID, replyID
|
||||
parse: (req, a, threadID, replyID) ->
|
||||
if req.status isnt 200
|
||||
a.textContent = "#{req.status} #{req.statusText}"
|
||||
return
|
||||
|
||||
if $.engine is 'presto'
|
||||
doc = d.implementation.createHTMLDocument ''
|
||||
doc.documentElement.innerHTML = req.response
|
||||
else
|
||||
doc = req.response
|
||||
doc = d.implementation.createHTMLDocument ''
|
||||
doc.documentElement.innerHTML = req.response
|
||||
|
||||
# Import the node to fix quote.hashes
|
||||
# as they're empty when in a different document.
|
||||
@ -666,7 +658,7 @@ ExpandThread =
|
||||
switch a.textContent[0]
|
||||
when '+'
|
||||
a.textContent = a.textContent.replace '+', '\u00d7 Loading...'
|
||||
$.cache pathname, 'document', -> ExpandThread.parse @, thread, a
|
||||
$.cache pathname, -> ExpandThread.parse @, thread, a
|
||||
|
||||
when '\u00d7'
|
||||
a.textContent = a.textContent.replace '\u00d7 Loading...', '+'
|
||||
@ -693,11 +685,8 @@ ExpandThread =
|
||||
|
||||
a.textContent = a.textContent.replace '\u00d7 Loading...', '-'
|
||||
|
||||
if $.engine is 'presto'
|
||||
doc = d.implementation.createHTMLDocument ''
|
||||
doc.documentElement.innerHTML = req.response
|
||||
else
|
||||
doc = req.response
|
||||
doc = d.implementation.createHTMLDocument ''
|
||||
doc.documentElement.innerHTML = req.response
|
||||
|
||||
threadID = thread.id[1..]
|
||||
nodes = []
|
||||
@ -2415,17 +2404,17 @@ Get =
|
||||
|
||||
root.textContent = "Loading post No.#{postID}..."
|
||||
if threadID
|
||||
$.cache "/#{board}/res/#{threadID}", 'document', ->
|
||||
$.cache "/#{board}/res/#{threadID}", ->
|
||||
Get.parsePost @, board, threadID, postID, root, cb
|
||||
else if url = Redirect.post board, postID
|
||||
$.cache url, 'json', ->
|
||||
$.cache url, ->
|
||||
Get.parseArchivedPost @, board, postID, root, cb
|
||||
parsePost: (req, board, threadID, postID, root, cb) ->
|
||||
{status} = req
|
||||
if status isnt 200
|
||||
# The thread can die by the time we check a quote.
|
||||
if url = Redirect.post board, postID
|
||||
$.cache url, 'json', ->
|
||||
$.cache url, ->
|
||||
Get.parseArchivedPost @, board, postID, root, cb
|
||||
else
|
||||
root.textContent =
|
||||
@ -2435,16 +2424,13 @@ Get =
|
||||
"Error #{req.status}: #{req.statusText}."
|
||||
return
|
||||
|
||||
if $.engine is 'presto'
|
||||
doc = d.implementation.createHTMLDocument ''
|
||||
doc.documentElement.innerHTML = req.response
|
||||
else
|
||||
doc = req.response
|
||||
doc = d.implementation.createHTMLDocument ''
|
||||
doc.documentElement.innerHTML = req.response
|
||||
|
||||
unless pc = doc.getElementById "pc#{postID}"
|
||||
# The post can be deleted by the time we check a quote.
|
||||
if url = Redirect.post board, postID
|
||||
$.cache url, 'json', ->
|
||||
$.cache url, ->
|
||||
Get.parseArchivedPost @, board, postID, root, cb
|
||||
else
|
||||
root.textContent = "Post No.#{postID} has not been found."
|
||||
@ -2462,10 +2448,7 @@ Get =
|
||||
$.replace root.firstChild, pc
|
||||
cb() if cb
|
||||
parseArchivedPost: (req, board, postID, root, cb) ->
|
||||
if $.engine is 'webkit'
|
||||
data = JSON.parse req.response
|
||||
else
|
||||
data = req.response
|
||||
data = JSON.parse req.response
|
||||
$.addClass root, 'archivedPost'
|
||||
if data.error
|
||||
root.textContent = data.error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user