fix x-quotes
This commit is contained in:
parent
5995ae1f2c
commit
0cbc3fbb4d
56
4chan_x.js
56
4chan_x.js
@ -492,14 +492,13 @@
|
|||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
expand: function(e) {
|
expand: function(e) {
|
||||||
var a, replyID, threadID, url, _, _ref;
|
var a, replyID, threadID, _, _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;
|
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(url, (function() {
|
return $.cache(this.pathname, (function() {
|
||||||
return expandComment.parse(this, a, threadID, replyID);
|
return expandComment.parse(this, a, threadID, replyID);
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
@ -551,19 +550,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggle: function(thread) {
|
toggle: function(thread) {
|
||||||
var a, num, prev, table, threadID, url, _results;
|
var a, num, pathname, prev, table, threadID, _results;
|
||||||
threadID = thread.firstChild.id;
|
threadID = thread.firstChild.id;
|
||||||
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
|
pathname = "/" + 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(url, (function() {
|
return $.cache(pathname, (function() {
|
||||||
return expandThread.parse(this, thread, a);
|
return expandThread.parse(this, pathname, thread, a);
|
||||||
}));
|
}));
|
||||||
case 'X':
|
case 'X':
|
||||||
a.textContent = a.textContent.replace('X Loading...', '+');
|
a.textContent = a.textContent.replace('X Loading...', '+');
|
||||||
return $.cache[url].abort();
|
return $.cache[pathname].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;
|
||||||
@ -575,8 +574,8 @@
|
|||||||
return _results;
|
return _results;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
parse: function(req, thread, a) {
|
parse: function(req, pathname, thread, a) {
|
||||||
var body, br, next, table, tables, _i, _len, _results;
|
var body, br, next, quote, table, tables, _i, _j, _len, _len2, _ref, _results;
|
||||||
if (req.status !== 200) {
|
if (req.status !== 200) {
|
||||||
a.textContent = "" + req.status + " " + req.statusText;
|
a.textContent = "" + req.status + " " + req.statusText;
|
||||||
$.unbind(a, 'click', expandThread.cb.toggle);
|
$.unbind(a, 'click', expandThread.cb.toggle);
|
||||||
@ -590,11 +589,18 @@
|
|||||||
body = $.el('body', {
|
body = $.el('body', {
|
||||||
innerHTML: req.responseText
|
innerHTML: req.responseText
|
||||||
});
|
});
|
||||||
|
_ref = $$('a.quotelink', body);
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
quote = _ref[_i];
|
||||||
|
if (quote.getAttribute('href') === quote.hash) {
|
||||||
|
quote.pathname = pathname;
|
||||||
|
}
|
||||||
|
}
|
||||||
tables = $$('form[name=delform] table', body);
|
tables = $$('form[name=delform] table', body);
|
||||||
tables.pop();
|
tables.pop();
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = tables.length; _i < _len; _i++) {
|
for (_j = 0, _len2 = tables.length; _j < _len2; _j++) {
|
||||||
table = tables[_i];
|
table = tables[_j];
|
||||||
_results.push($.before(br, table));
|
_results.push($.before(br, table));
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
@ -1760,7 +1766,7 @@
|
|||||||
return _results;
|
return _results;
|
||||||
},
|
},
|
||||||
toggle: function(e) {
|
toggle: function(e) {
|
||||||
var el, id, inline, root, table, threadID, url;
|
var el, id, inline, pathname, root, table, threadID;
|
||||||
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);
|
||||||
@ -1787,16 +1793,16 @@
|
|||||||
innerHTML: "Loading " + id + "..."
|
innerHTML: "Loading " + id + "..."
|
||||||
});
|
});
|
||||||
$.after(this.parentNode, inline);
|
$.after(this.parentNode, inline);
|
||||||
threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
|
pathname = this.pathname;
|
||||||
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
|
threadID = pathname.split('/').pop();
|
||||||
$.cache(url, (function() {
|
$.cache(pathname, (function() {
|
||||||
return quoteInline.parse(this, id, threadID, inline);
|
return quoteInline.parse(this, pathname, id, threadID, inline);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return $.addClass(this, 'inlined');
|
return $.addClass(this, 'inlined');
|
||||||
},
|
},
|
||||||
parse: function(req, id, threadID, inline) {
|
parse: function(req, pathname, id, threadID, inline) {
|
||||||
var body, html, newInline, op, reply, _i, _len, _ref;
|
var body, html, newInline, op, quote, reply, _i, _j, _len, _len2, _ref, _ref2;
|
||||||
if (req.status !== 200) {
|
if (req.status !== 200) {
|
||||||
inline.innerHTML = "" + req.status + " " + req.statusText;
|
inline.innerHTML = "" + req.status + " " + req.statusText;
|
||||||
return;
|
return;
|
||||||
@ -1818,6 +1824,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
newInline = quoteInline.table(id, html);
|
newInline = quoteInline.table(id, html);
|
||||||
|
_ref2 = $$('a.quotelink', newInline);
|
||||||
|
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||||
|
quote = _ref2[_j];
|
||||||
|
if (quote.getAttribute('href') === quote.hash) {
|
||||||
|
quote.pathname = pathname;
|
||||||
|
}
|
||||||
|
}
|
||||||
$.addClass(newInline, 'crossquote');
|
$.addClass(newInline, 'crossquote');
|
||||||
return $.replace(inline, newInline);
|
return $.replace(inline, newInline);
|
||||||
},
|
},
|
||||||
@ -1864,7 +1877,7 @@
|
|||||||
return $.removeClass(el, 'qphl');
|
return $.removeClass(el, 'qphl');
|
||||||
},
|
},
|
||||||
mouseover: function(e) {
|
mouseover: function(e) {
|
||||||
var el, id, qp, quote, replyID, threadID, url, _i, _len, _ref, _ref2;
|
var el, id, qp, quote, replyID, threadID, _i, _len, _ref, _ref2;
|
||||||
id = this.hash.slice(1);
|
id = this.hash.slice(1);
|
||||||
qp = $('#qp');
|
qp = $('#qp');
|
||||||
if (el = d.getElementById(id)) {
|
if (el = d.getElementById(id)) {
|
||||||
@ -1883,8 +1896,7 @@
|
|||||||
} else {
|
} else {
|
||||||
qp.innerHTML = "Loading " + id + "...";
|
qp.innerHTML = "Loading " + id + "...";
|
||||||
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;
|
||||||
url = "http://boards.4chan.org/" + g.BOARD + "/res/" + threadID;
|
$.cache(this.pathname, (function() {
|
||||||
$.cache(url, (function() {
|
|
||||||
return quotePreview.parse(this, id, threadID);
|
return quotePreview.parse(this, id, threadID);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -338,9 +338,8 @@ expandComment =
|
|||||||
[_, 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
|
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
|
||||||
url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
|
|
||||||
a = @
|
a = @
|
||||||
$.cache url, (-> 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}"
|
||||||
@ -376,18 +375,18 @@ expandThread =
|
|||||||
|
|
||||||
toggle: (thread) ->
|
toggle: (thread) ->
|
||||||
threadID = thread.firstChild.id
|
threadID = thread.firstChild.id
|
||||||
url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
|
pathname = "/#{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 url, (-> expandThread.parse @, thread, a)
|
$.cache pathname, (-> expandThread.parse @, pathname, thread, a)
|
||||||
|
|
||||||
when 'X'
|
when 'X'
|
||||||
a.textContent = a.textContent.replace 'X Loading...', '+'
|
a.textContent = a.textContent.replace 'X Loading...', '+'
|
||||||
#FIXME this will kill all callbacks
|
#FIXME this will kill all callbacks
|
||||||
$.cache[url].abort()
|
$.cache[pathname].abort()
|
||||||
|
|
||||||
when '-'
|
when '-'
|
||||||
a.textContent = a.textContent.replace '-', '+'
|
a.textContent = a.textContent.replace '-', '+'
|
||||||
@ -397,7 +396,7 @@ expandThread =
|
|||||||
while (prev = table.previousSibling) and (prev.nodeName is 'TABLE')
|
while (prev = table.previousSibling) and (prev.nodeName is 'TABLE')
|
||||||
$.rm prev
|
$.rm prev
|
||||||
|
|
||||||
parse: (req, thread, a) ->
|
parse: (req, pathname, thread, a) ->
|
||||||
if req.status isnt 200
|
if req.status isnt 200
|
||||||
a.textContent = "#{req.status} #{req.statusText}"
|
a.textContent = "#{req.status} #{req.statusText}"
|
||||||
$.unbind a, 'click', expandThread.cb.toggle
|
$.unbind a, 'click', expandThread.cb.toggle
|
||||||
@ -413,6 +412,9 @@ expandThread =
|
|||||||
body = $.el 'body',
|
body = $.el 'body',
|
||||||
innerHTML: req.responseText
|
innerHTML: req.responseText
|
||||||
|
|
||||||
|
for quote in $$ 'a.quotelink', body
|
||||||
|
if quote.getAttribute('href') is quote.hash
|
||||||
|
quote.pathname = pathname
|
||||||
tables = $$ 'form[name=delform] table', body
|
tables = $$ 'form[name=delform] table', body
|
||||||
tables.pop()
|
tables.pop()
|
||||||
for table in tables
|
for table in tables
|
||||||
@ -1426,11 +1428,11 @@ quoteInline =
|
|||||||
innerHTML: "Loading #{id}..."
|
innerHTML: "Loading #{id}..."
|
||||||
$.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
|
{pathname} = @
|
||||||
url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
|
threadID = pathname.split('/').pop()
|
||||||
$.cache url, (-> quoteInline.parse @, id, threadID, inline)
|
$.cache pathname, (-> quoteInline.parse @, pathname, id, threadID, inline)
|
||||||
$.addClass @, 'inlined'
|
$.addClass @, 'inlined'
|
||||||
parse: (req, id, threadID, inline) ->
|
parse: (req, pathname, id, threadID, inline) ->
|
||||||
if req.status isnt 200
|
if req.status isnt 200
|
||||||
inline.innerHTML = "#{req.status} #{req.statusText}"
|
inline.innerHTML = "#{req.status} #{req.statusText}"
|
||||||
return
|
return
|
||||||
@ -1446,6 +1448,9 @@ quoteInline =
|
|||||||
html = reply.innerHTML
|
html = reply.innerHTML
|
||||||
break
|
break
|
||||||
newInline = quoteInline.table id, html
|
newInline = quoteInline.table id, html
|
||||||
|
for quote in $$ 'a.quotelink', newInline
|
||||||
|
if quote.getAttribute('href') is quote.hash
|
||||||
|
quote.pathname = pathname
|
||||||
$.addClass newInline, 'crossquote'
|
$.addClass newInline, 'crossquote'
|
||||||
$.replace inline, newInline
|
$.replace inline, newInline
|
||||||
table: (id, html) ->
|
table: (id, html) ->
|
||||||
@ -1486,8 +1491,7 @@ quotePreview =
|
|||||||
else
|
else
|
||||||
qp.innerHTML = "Loading #{id}..."
|
qp.innerHTML = "Loading #{id}..."
|
||||||
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
|
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
|
||||||
url = "http://boards.4chan.org/#{g.BOARD}/res/#{threadID}"
|
$.cache @pathname, (-> quotePreview.parse @, id, 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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user