Fix filename filtering. ReplyHiding.node performance improvements.

This commit is contained in:
Nicolas Stepien 2012-03-07 20:13:01 +01:00
parent 3232671980
commit 5fd43f180b
2 changed files with 24 additions and 22 deletions

View File

@ -675,8 +675,9 @@
return text.join(''); return text.join('');
}, },
filename: function(post) { filename: function(post) {
var file; var file, filesize;
if (file = $('span', post.filesize)) return file.title; filesize = post.filesize;
if (filesize && (file = $('span', filesize))) return file.title;
return false; return false;
}, },
dimensions: function(post) { dimensions: function(post) {
@ -887,22 +888,21 @@
ReplyHiding = { ReplyHiding = {
init: function() { init: function() {
return g.callbacks.push(this.node); this.a = $.el('a', {
},
node: function(post) {
var a, dd, id, reply;
if (post["class"]) return;
dd = $('.doubledash', post.root);
dd.className = 'replyhider';
a = $.el('a', {
textContent: '[ - ]', textContent: '[ - ]',
href: 'javascript:;' href: 'javascript:;'
}); });
return g.callbacks.push(this.node);
},
node: function(post) {
var a, dd;
if (post["class"]) return;
dd = post.el.previousSibling;
dd.className = 'replyhider';
a = ReplyHiding.a.cloneNode(true);
$.on(a, 'click', ReplyHiding.cb.hide); $.on(a, 'click', ReplyHiding.cb.hide);
$.replace(dd.firstChild, a); $.replace(dd.firstChild, a);
reply = dd.nextSibling; if (post.id in g.hiddenReplies) return ReplyHiding.hide(post.el);
id = reply.id;
if (id in g.hiddenReplies) return ReplyHiding.hide(reply);
}, },
cb: { cb: {
hide: function() { hide: function() {
@ -2811,6 +2811,7 @@
}, },
node: function(post) { node: function(post) {
var name, node; var name, node;
if (post["class"] === 'inline') return;
name = $('.commentpostername, .postername', post.el); name = $('.commentpostername, .postername', post.el);
name.textContent = 'Anonymous'; name.textContent = 'Anonymous';
node = name.nextElementSibling; node = name.nextElementSibling;

View File

@ -593,7 +593,8 @@ Filter =
text.push if data = nodes.snapshotItem(i).data then data else '\n' text.push if data = nodes.snapshotItem(i).data then data else '\n'
text.join '' text.join ''
filename: (post) -> filename: (post) ->
if file = $ 'span', post.filesize {filesize} = post
if filesize and file = $ 'span', filesize
return file.title return file.title
false false
dimensions: (post) -> dimensions: (post) ->
@ -745,22 +746,21 @@ ExpandThread =
ReplyHiding = ReplyHiding =
init: -> init: ->
@a = $.el 'a',
textContent: '[ - ]'
href: 'javascript:;'
g.callbacks.push @node g.callbacks.push @node
node: (post) -> node: (post) ->
return if post.class return if post.class
dd = $ '.doubledash', post.root dd = post.el.previousSibling
dd.className = 'replyhider' dd.className = 'replyhider'
a = $.el 'a', a = ReplyHiding.a.cloneNode true
textContent: '[ - ]'
href: 'javascript:;'
$.on a, 'click', ReplyHiding.cb.hide $.on a, 'click', ReplyHiding.cb.hide
$.replace dd.firstChild, a $.replace dd.firstChild, a
reply = dd.nextSibling if post.id of g.hiddenReplies
id = reply.id ReplyHiding.hide post.el
if id of g.hiddenReplies
ReplyHiding.hide reply
cb: cb:
hide: -> hide: ->
@ -2365,6 +2365,7 @@ Anonymize =
init: -> init: ->
g.callbacks.push @node g.callbacks.push @node
node: (post) -> node: (post) ->
return if post.class is 'inline'
name = $ '.commentpostername, .postername', post.el name = $ '.commentpostername, .postername', post.el
name.textContent = 'Anonymous' name.textContent = 'Anonymous'
node = name.nextElementSibling node = name.nextElementSibling