work on inlined quotes, but break on x-board quotes

This commit is contained in:
James Campos 2011-05-24 23:55:11 -07:00
parent 0cec573e18
commit 9cd4248491
2 changed files with 27 additions and 16 deletions

View File

@ -491,12 +491,14 @@
return _results; return _results;
}, },
expand: function(e) { expand: function(e) {
var a, replyID, threadID, _, _ref; var a, replyID, threadID, url, _, _ref;
e.preventDefault(); e.preventDefault();
_ref = this.href.match(/(\d+)#(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2]; _ref = this.href.match(/(\d+)#(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2];
this.textContent = "Loading " + replyID + "..."; this.textContent = "Loading " + replyID + "...";
threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
a = this; a = this;
return $.cache(this.href, (function() { return $.cache(url, (function() {
return expandComment.parse(this, a, threadID, replyID); return expandComment.parse(this, a, threadID, replyID);
})); }));
}, },
@ -548,18 +550,19 @@
} }
}, },
toggle: function(thread) { toggle: function(thread) {
var a, num, prev, table, threadID, _results; var a, num, prev, table, threadID, url, _results;
threadID = thread.firstChild.id; threadID = thread.firstChild.id;
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
a = $('a.omittedposts', thread); a = $('a.omittedposts', thread);
switch (a.textContent[0]) { switch (a.textContent[0]) {
case '+': case '+':
a.textContent = a.textContent.replace('+', 'X Loading...'); a.textContent = a.textContent.replace('+', 'X Loading...');
return $.cache("res/" + threadID, (function() { return $.cache(url, (function() {
return expandThread.parse(this, thread, a); return expandThread.parse(this, thread, a);
})); }));
case 'X': case 'X':
a.textContent = a.textContent.replace('X Loading...', '+'); a.textContent = a.textContent.replace('X Loading...', '+');
return $.cache["res/" + threadID].abort(); return $.cache[url].abort();
case '-': case '-':
a.textContent = a.textContent.replace('-', '+'); a.textContent = a.textContent.replace('-', '+');
num = g.BOARD === 'b' ? 3 : 5; num = g.BOARD === 'b' ? 3 : 5;
@ -1761,7 +1764,7 @@
return _results; return _results;
}, },
toggle: function(e) { toggle: function(e) {
var el, id, inline, root, table, threadID; var el, id, inline, root, table, threadID, url;
id = this.hash.slice(1); id = this.hash.slice(1);
e.preventDefault(); e.preventDefault();
root = $.x('ancestor::td[1]', this); root = $.x('ancestor::td[1]', this);
@ -1789,7 +1792,8 @@
}); });
$.after(this.parentNode, inline); $.after(this.parentNode, inline);
threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id; threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
$.cache(this.href, (function() { url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
$.cache(url, (function() {
return quoteInline.parse(this, id, threadID, inline); return quoteInline.parse(this, id, threadID, inline);
})); }));
} }
@ -1864,7 +1868,7 @@
return $.removeClass(el, 'qphl'); return $.removeClass(el, 'qphl');
}, },
mouseover: function(e) { mouseover: function(e) {
var el, id, qp, quote, replyID, threadID, _i, _len, _ref; var el, id, qp, quote, replyID, threadID, url, _i, _len, _ref;
id = this.hash.slice(1); id = this.hash.slice(1);
qp = $('#qp'); qp = $('#qp');
if (el = d.getElementById(id)) { if (el = d.getElementById(id)) {
@ -1882,8 +1886,9 @@
} }
} else { } else {
qp.innerHTML = "Loading " + id + "..."; qp.innerHTML = "Loading " + id + "...";
threadID = this.pathname.split('/').pop(); threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
$.cache(this.href, (function() { url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
$.cache(url, (function() {
return quotePreview.parse(this, id, threadID); return quotePreview.parse(this, id, threadID);
})); }));
} }

View File

@ -336,8 +336,10 @@ expandComment =
e.preventDefault() e.preventDefault()
[_, threadID, replyID] = @href.match /(\d+)#(\d+)/ [_, threadID, replyID] = @href.match /(\d+)#(\d+)/
@textContent = "Loading #{replyID}..." @textContent = "Loading #{replyID}..."
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
a = @ a = @
$.cache @href, (-> expandComment.parse @, a, threadID, replyID) $.cache url, (-> 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}"
@ -373,16 +375,18 @@ expandThread =
toggle: (thread) -> toggle: (thread) ->
threadID = thread.firstChild.id threadID = thread.firstChild.id
url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
a = $ 'a.omittedposts', thread a = $ 'a.omittedposts', thread
switch a.textContent[0] switch a.textContent[0]
when '+' when '+'
a.textContent = a.textContent.replace '+', 'X Loading...' a.textContent = a.textContent.replace '+', 'X Loading...'
$.cache "res/#{threadID}", (-> expandThread.parse @, thread, a) $.cache url, (-> expandThread.parse @, thread, a)
when 'X' when 'X'
a.textContent = a.textContent.replace 'X Loading...', '+' a.textContent = a.textContent.replace 'X Loading...', '+'
$.cache["res/#{threadID}"].abort() #FIXME this will kill all callbacks
$.cache[url].abort()
when '-' when '-'
a.textContent = a.textContent.replace '-', '+' a.textContent = a.textContent.replace '-', '+'
@ -1429,7 +1433,8 @@ quoteInline =
$.after @parentNode, inline $.after @parentNode, inline
# or ... is for index page new posts. # or ... is for index page new posts.
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
$.cache @href, (-> quoteInline.parse @, id, threadID, inline) url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
$.cache url, (-> quoteInline.parse @, id, threadID, inline)
$.addClass @, 'inlined' $.addClass @, 'inlined'
parse: (req, id, threadID, inline) -> parse: (req, id, threadID, inline) ->
if req.status isnt 200 if req.status isnt 200
@ -1486,8 +1491,9 @@ quotePreview =
quote.className = 'backlink' quote.className = 'backlink'
else else
qp.innerHTML = "Loading #{id}..." qp.innerHTML = "Loading #{id}..."
threadID = @pathname.split('/').pop() threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
$.cache @href, (-> quotePreview.parse @, id, threadID) url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
$.cache url, (-> quotePreview.parse @, id, threadID)
ui.el = qp ui.el = qp
ui.winHeight = d.body.clientHeight ui.winHeight = d.body.clientHeight
$.show qp $.show qp