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