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('');
},
filename: function(post) {
var file;
if (file = $('span', post.filesize)) return file.title;
var file, filesize;
filesize = post.filesize;
if (filesize && (file = $('span', filesize))) return file.title;
return false;
},
dimensions: function(post) {
@ -887,22 +888,21 @@
ReplyHiding = {
init: function() {
return g.callbacks.push(this.node);
},
node: function(post) {
var a, dd, id, reply;
if (post["class"]) return;
dd = $('.doubledash', post.root);
dd.className = 'replyhider';
a = $.el('a', {
this.a = $.el('a', {
textContent: '[ - ]',
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);
$.replace(dd.firstChild, a);
reply = dd.nextSibling;
id = reply.id;
if (id in g.hiddenReplies) return ReplyHiding.hide(reply);
if (post.id in g.hiddenReplies) return ReplyHiding.hide(post.el);
},
cb: {
hide: function() {
@ -2811,6 +2811,7 @@
},
node: function(post) {
var name, node;
if (post["class"] === 'inline') return;
name = $('.commentpostername, .postername', post.el);
name.textContent = 'Anonymous';
node = name.nextElementSibling;

View File

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