Merge pull request #358 from MayhemYDG/master

Close #301, fix #302
This commit is contained in:
James Campos 2011-10-30 12:41:20 -07:00
commit f84577c2da
2 changed files with 69 additions and 16 deletions

View File

@ -61,7 +61,7 @@
*/ */
(function() { (function() {
var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, QR, SECOND, Time, anonymize, conf, config, d, expandComment, expandThread, filter, firstRun, flatten, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, nav, options, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher; var $, $$, DAY, Favicon, HOUR, MINUTE, Main, NAMESPACE, QR, SECOND, Time, anonymize, conf, config, d, expandComment, expandThread, filter, firstRun, flatten, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, nav, options, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, strikethroughQuotes, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher;
var __slice = Array.prototype.slice; var __slice = Array.prototype.slice;
config = { config = {
main: { main: {
@ -586,6 +586,23 @@
} }
} }
}; };
strikethroughQuotes = {
init: function() {
return g.callbacks.push(function(root) {
var el, quote, _i, _len, _ref, _results;
if (root.className === 'inline') {
return;
}
_ref = $$('.quotelink', root);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
_results.push((el = $.id(quote.hash.slice(1))) ? el.parentNode.parentNode.parentNode.hidden ? $.addClass(quote, 'filtered') : void 0 : void 0);
}
return _results;
});
}
};
expandComment = { expandComment = {
init: function() { init: function() {
var a, _i, _len, _ref, _results; var a, _i, _len, _ref, _results;
@ -791,9 +808,14 @@
} }
}, },
hide: function(reply) { hide: function(reply) {
var id; var id, quote, _i, _len, _ref;
replyHiding.hideHide(reply); replyHiding.hideHide(reply);
id = reply.id; id = reply.id;
_ref = $$(".quotelink[href='#" + id + "'], .backlink[href='#" + id + "']");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
$.addClass(quote, 'filtered');
}
g.hiddenReplies[id] = Date.now(); g.hiddenReplies[id] = Date.now();
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
}, },
@ -816,9 +838,14 @@
} }
}, },
show: function(table) { show: function(table) {
var id; var id, quote, _i, _len, _ref;
table.hidden = false; table.hidden = false;
id = $('td[id]', table).id; id = $('td[id]', table).id;
_ref = $$(".quotelink[href='#" + id + "'], .backlink[href='#" + id + "']");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
$.removeClass(quote, 'filtered');
}
delete g.hiddenReplies[id]; delete g.hiddenReplies[id];
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
} }
@ -2330,7 +2357,7 @@
} }
link = $.el('a', { link = $.el('a', {
href: "#" + id, href: "#" + id,
className: 'backlink', className: root.hidden ? 'filtered backlink' : 'backlink',
textContent: quoteBacklink.funk(id) textContent: quoteBacklink.funk(id)
}); });
if (conf['Quote Preview']) { if (conf['Quote Preview']) {
@ -2414,16 +2441,15 @@
} }
}, },
rm: function(q, id) { rm: function(q, id) {
var hidden, inlined, table, _i, _len, _ref; var inlined, table, _i, _len, _ref;
table = $.x("following::*[@id='i" + id + "']", q); table = $.x("following::*[@id='i" + id + "']", q);
_ref = $$('input', table); _ref = $$('.backlink.inlined:not(.filtered)', table);
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
inlined = _ref[_i]; inlined = _ref[_i];
if (hidden = $.id(inlined.name)) { $.x('ancestor::table[1]', $.id(inlined.hash.slice(1))).hidden = false;
if (!hidden.classList.contains('op')) { }
$.x('ancestor::table[1]', hidden).hidden = false; if (!q.classList.contains('filtered')) {
} $.x('ancestor::table[1]', $.id(id)).hidden = false;
}
} }
return $.rm(table); return $.rm(table);
}, },
@ -3036,6 +3062,9 @@
if (conf['Reply Hiding']) { if (conf['Reply Hiding']) {
replyHiding.init(); replyHiding.init();
} }
if (conf['Filter'] || conf['Reply Hiding']) {
strikethroughQuotes.init();
}
if (conf['Anonymize']) { if (conf['Anonymize']) {
anonymize.init(); anonymize.init();
} }
@ -3324,6 +3353,9 @@
.filetitle, .replytitle, .postername, .commentpostername, .postertrip {\ .filetitle, .replytitle, .postername, .commentpostername, .postertrip {\
background: none;\ background: none;\
}\ }\
.filtered {\
text-decoration: line-through;\
}\
\ \
/* Firefox bug: hidden tables are not hidden. fixed in 9.0 */\ /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */\
[hidden] {\ [hidden] {\

View File

@ -425,6 +425,15 @@ filter =
if img = $ 'img[md5]', root if img = $ 'img[md5]', root
filter.test 'md5', img.getAttribute('md5') filter.test 'md5', img.getAttribute('md5')
strikethroughQuotes =
init: ->
g.callbacks.push (root) ->
return if root.className is 'inline'
for quote in $$ '.quotelink', root
if el = $.id quote.hash[1..]
if el.parentNode.parentNode.parentNode.hidden
$.addClass quote, 'filtered'
expandComment = expandComment =
init: -> init: ->
for a in $$ '.abbr a' for a in $$ '.abbr a'
@ -571,6 +580,9 @@ replyHiding =
replyHiding.hideHide reply replyHiding.hideHide reply
id = reply.id id = reply.id
for quote in $$ ".quotelink[href='##{id}'], .backlink[href='##{id}']"
$.addClass quote, 'filtered'
g.hiddenReplies[id] = Date.now() g.hiddenReplies[id] = Date.now()
$.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies $.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
@ -594,6 +606,9 @@ replyHiding =
table.hidden = false table.hidden = false
id = $('td[id]', table).id id = $('td[id]', table).id
for quote in $$ ".quotelink[href='##{id}'], .backlink[href='##{id}']"
$.removeClass quote, 'filtered'
delete g.hiddenReplies[id] delete g.hiddenReplies[id]
$.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies $.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
@ -1762,7 +1777,7 @@ quoteBacklink =
continue if !conf['OP Backlinks'] and el.className is 'op' continue if !conf['OP Backlinks'] and el.className is 'op'
link = $.el 'a', link = $.el 'a',
href: "##{id}" href: "##{id}"
className: 'backlink' className: if root.hidden then 'filtered backlink' else 'backlink'
textContent: quoteBacklink.funk id textContent: quoteBacklink.funk id
if conf['Quote Preview'] if conf['Quote Preview']
$.bind link, 'mouseover', quotePreview.mouseover $.bind link, 'mouseover', quotePreview.mouseover
@ -1816,10 +1831,10 @@ quoteInline =
rm: (q, id) -> rm: (q, id) ->
#select the corresponding table or loading td #select the corresponding table or loading td
table = $.x "following::*[@id='i#{id}']", q table = $.x "following::*[@id='i#{id}']", q
for inlined in $$ 'input', table for inlined in $$ '.backlink.inlined:not(.filtered)', table
if hidden = $.id inlined.name $.x('ancestor::table[1]', $.id inlined.hash[1..]).hidden = false
unless hidden.classList.contains 'op' unless q.classList.contains 'filtered'
$.x('ancestor::table[1]', hidden).hidden = false $.x('ancestor::table[1]', $.id id).hidden = false
$.rm table $.rm table
parse: (req, pathname, id, threadID, inline) -> parse: (req, pathname, id, threadID, inline) ->
@ -2308,6 +2323,9 @@ Main =
if conf['Reply Hiding'] if conf['Reply Hiding']
replyHiding.init() replyHiding.init()
if conf['Filter'] or conf['Reply Hiding']
strikethroughQuotes.init()
if conf['Anonymize'] if conf['Anonymize']
anonymize.init() anonymize.init()
@ -2586,6 +2604,9 @@ Main =
.filetitle, .replytitle, .postername, .commentpostername, .postertrip { .filetitle, .replytitle, .postername, .commentpostername, .postertrip {
background: none; background: none;
} }
.filtered {
text-decoration: line-through;
}
/* Firefox bug: hidden tables are not hidden. fixed in 9.0 */ /* Firefox bug: hidden tables are not hidden. fixed in 9.0 */
[hidden] { [hidden] {