inline backlinks, pig disgusting xpath
This commit is contained in:
parent
ed9d2770ff
commit
59ce7274b8
30
4chan_x.js
30
4chan_x.js
@ -1661,6 +1661,9 @@
|
||||
},
|
||||
node: function(root) {
|
||||
var el, id, link, qid, quote, quotes, tid, _i, _len, _ref, _results;
|
||||
if (root.className === 'inline') {
|
||||
return;
|
||||
}
|
||||
id = root.id || $('td[id]', root).id;
|
||||
quotes = {};
|
||||
tid = g.THREAD_ID;
|
||||
@ -1691,6 +1694,9 @@
|
||||
$.bind(link, 'mousemove', ui.hover);
|
||||
$.bind(link, 'mouseout', ui.hoverend);
|
||||
}
|
||||
if ($.config('Quote Inline')) {
|
||||
$.bind(link, 'click', quoteInline.toggle);
|
||||
}
|
||||
_results.push($.before($('td > br, blockquote', el), link));
|
||||
}
|
||||
return _results;
|
||||
@ -1702,7 +1708,7 @@
|
||||
},
|
||||
node: function(root) {
|
||||
var quote, _i, _len, _ref, _results;
|
||||
_ref = $$('a.quotelink', root);
|
||||
_ref = $$('a.quotelink, a.backlink', root);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
quote = _ref[_i];
|
||||
@ -1712,18 +1718,22 @@
|
||||
return _results;
|
||||
},
|
||||
toggle: function(e) {
|
||||
var el, id, inline, next, req, td, threadID;
|
||||
var el, id, inline, req, root, td, threadID;
|
||||
e.preventDefault();
|
||||
if (!(id = this.hash.slice(1))) {
|
||||
return;
|
||||
}
|
||||
if ((next = this.parentNode.nextSibling) && (next.nodeName === 'TABLE')) {
|
||||
$.rm(next);
|
||||
root = $.x('ancestor::td[1]', this);
|
||||
if (td = $("#i" + id, root)) {
|
||||
$.rm($.x('ancestor::table[1]', td));
|
||||
if (this.className === 'backlink') {
|
||||
$.show($.x('ancestor::table[1]', d.getElementById(id)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
inline = $.el('table', {
|
||||
className: 'inline',
|
||||
innerHTML: '<tbody><tr><td class=reply></td></tr></tbody>'
|
||||
innerHTML: "<tbody><tr><td class=reply id=i" + id + "></td></tr></tbody>"
|
||||
});
|
||||
td = $('td', inline);
|
||||
if (el = d.getElementById(id)) {
|
||||
@ -1741,7 +1751,13 @@
|
||||
}));
|
||||
}
|
||||
}
|
||||
return $.after(this.parentNode, inline);
|
||||
if (this.className === 'backlink') {
|
||||
root = $('table, blockquote', root);
|
||||
$.before(root, inline);
|
||||
return $.hide($.x('ancestor::table[1]', el));
|
||||
} else {
|
||||
return $.after(this.parentNode, inline);
|
||||
}
|
||||
},
|
||||
parse: function(req, id, threadID, oldInline) {
|
||||
var body, html, inline, op, reply, td, _i, _len, _ref;
|
||||
@ -1787,7 +1803,7 @@
|
||||
},
|
||||
node: function(root) {
|
||||
var quote, _i, _len, _ref, _results;
|
||||
_ref = $$('a.quotelink', root);
|
||||
_ref = $$('a.quotelink, a.backlink', root);
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
quote = _ref[_i];
|
||||
|
||||
@ -1332,6 +1332,7 @@ quoteBacklink =
|
||||
init: ->
|
||||
g.callbacks.push quoteBacklink.node
|
||||
node: (root) ->
|
||||
return if root.className is 'inline'
|
||||
#better coffee-script way of doing this?
|
||||
id = root.id or $('td[id]', root).id
|
||||
quotes = {}
|
||||
@ -1352,24 +1353,29 @@ quoteBacklink =
|
||||
$.bind link, 'mouseover', quotePreview.mouseover
|
||||
$.bind link, 'mousemove', ui.hover
|
||||
$.bind link, 'mouseout', ui.hoverend
|
||||
if $.config 'Quote Inline'
|
||||
$.bind link, 'click', quoteInline.toggle
|
||||
$.before $('td > br, blockquote', el), link
|
||||
|
||||
quoteInline =
|
||||
init: ->
|
||||
g.callbacks.push quoteInline.node
|
||||
node: (root) ->
|
||||
for quote in $$ 'a.quotelink', root
|
||||
for quote in $$ 'a.quotelink, a.backlink', root
|
||||
quote.removeAttribute 'onclick'
|
||||
$.bind quote, 'click', quoteInline.toggle
|
||||
toggle: (e) ->
|
||||
e.preventDefault()
|
||||
return unless id = @hash[1..]
|
||||
if (next = @parentNode.nextSibling) and (next.nodeName is 'TABLE')
|
||||
$.rm next
|
||||
root = $.x 'ancestor::td[1]', this
|
||||
if td = $ "#i#{id}", root
|
||||
$.rm $.x 'ancestor::table[1]', td
|
||||
if @className is 'backlink'
|
||||
$.show $.x 'ancestor::table[1]', d.getElementById id
|
||||
return
|
||||
inline = $.el 'table',
|
||||
className: 'inline'
|
||||
innerHTML: '<tbody><tr><td class=reply></td></tr></tbody>'
|
||||
innerHTML: "<tbody><tr><td class=reply id=i#{id}></td></tr></tbody>"
|
||||
td = $ 'td', inline
|
||||
if el = d.getElementById id
|
||||
td.innerHTML = el.innerHTML
|
||||
@ -1384,7 +1390,12 @@ quoteInline =
|
||||
else
|
||||
#FIXME need an array of callbacks
|
||||
g.requests[threadID] = $.get @href, (-> quoteInline.parse this, id, threadID, inline)
|
||||
$.after @parentNode, inline
|
||||
if @className is 'backlink'
|
||||
root = $ 'table, blockquote', root
|
||||
$.before root, inline
|
||||
$.hide $.x 'ancestor::table[1]', el
|
||||
else
|
||||
$.after @parentNode, inline
|
||||
parse: (req, id, threadID, oldInline) ->
|
||||
if req.status isnt 200
|
||||
oldInline.innerHTML = "#{req.status} #{req.statusText}"
|
||||
@ -1418,7 +1429,7 @@ quotePreview =
|
||||
$.hide preview
|
||||
$.append d.body, preview
|
||||
node: (root) ->
|
||||
for quote in $$ 'a.quotelink', root
|
||||
for quote in $$ 'a.quotelink, a.backlink', root
|
||||
$.bind quote, 'mouseover', quotePreview.mouseover
|
||||
$.bind quote, 'mousemove', ui.hover
|
||||
$.bind quote, 'mouseout', ui.hoverend
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user