Merge pull request #321 from MayhemYDG/master
Superior array manipulation
This commit is contained in:
commit
6fa93a7259
@ -539,45 +539,29 @@
|
||||
f = filter.match(/^\/(.+)\/(\w*)$/);
|
||||
this.regexps[key].push(RegExp(f[1], f[2]));
|
||||
}
|
||||
if (this.regexps[key].length) {
|
||||
this.callbacks.push(this[key]);
|
||||
}
|
||||
this.callbacks.push(this[key]);
|
||||
}
|
||||
return g.callbacks.push(this.node);
|
||||
},
|
||||
node: function(root) {
|
||||
var callback, _i, _j, _len, _len2, _ref, _ref2;
|
||||
if (root.className === 'op') {
|
||||
if (!g.REPLY && conf['Filter OPs']) {
|
||||
_ref = filter.callbacks;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
callback = _ref[_i];
|
||||
if (callback(root)) {
|
||||
threadHiding.hideHide(root.parentNode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!root.className) {
|
||||
if (filter.callbacks.some(function(callback) {
|
||||
return callback(root);
|
||||
})) {
|
||||
return replyHiding.hideHide($('td:not([nowrap])', root));
|
||||
}
|
||||
} else if (!root.classList.contains('inline')) {
|
||||
_ref2 = filter.callbacks;
|
||||
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
||||
callback = _ref2[_j];
|
||||
if (callback(root)) {
|
||||
replyHiding.hideHide($('td:not([nowrap])', root));
|
||||
return;
|
||||
}
|
||||
} else if (root.className === 'op' && !g.REPLY && conf['Filter OPs']) {
|
||||
if (filter.callbacks.some(function(callback) {
|
||||
return callback(root);
|
||||
})) {
|
||||
return threadHiding.hideHide(root.parentNode);
|
||||
}
|
||||
}
|
||||
},
|
||||
test: function(key, value) {
|
||||
var regexp, _i, _len, _ref;
|
||||
_ref = filter.regexps[key];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
regexp = _ref[_i];
|
||||
if (regexp.test(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return filter.regexps[key].some(function(regexp) {
|
||||
return regexp.test(value);
|
||||
});
|
||||
},
|
||||
name: function(root) {
|
||||
var name;
|
||||
@ -2448,7 +2432,7 @@
|
||||
_ref = $$('input', table);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
inlined = _ref[_i];
|
||||
if (hidden = $.id(inlined.name)) {
|
||||
if (!(hidden = $.id(inlined.name)).classList.contains('op')) {
|
||||
$.x('ancestor::table[1]', hidden).hidden = false;
|
||||
}
|
||||
}
|
||||
@ -2712,24 +2696,11 @@
|
||||
unreadSFW: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAN9JREFUOMtj+P//PwMlmIEqBkDBfxie2NdVVVFaMikzPXsuCIPYIDFkNWANSAb815t+GI5B/Jj8iQfjapafBWEQG5saDBegK0ja8Ok9EH/AJofXBTBFlUf+/wPi/7jkcYYBCLef/v9/9pX//+cAMYiNLo/uAgZQYMVVLzsLcnYF0GaQ5otv/v+/9BpiEEgMJAdSA1JLlAGXgAZcfoNswGfcBpQDowoW2vi8AFIDUothwOQJvVXIgYUrEEFsqFoGYqLxA7HRiNUAWEIiyQBkGpaUsclhMwCWFpBpvHJUyY0AmdYZKFRtAsoAAAAASUVORK5CYII%3D',
|
||||
unreadNSFW: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAOBJREFUOMtj+P//PwMlmIEqBkDBfxie2DWxqqykYlJ6dtZcEAaxQWLIasAakAz4n3bGGI5B/JiJ8QfjlsefBWEQG5saDBegKyj5lPQeiD9gk8PrApiinv+V/4D4Py55nGEAwrP+t/9f/X82EM8Bs9Hl0V3AAAqsuGXxZ0HO7vlf8Q+k+eb/i0B8CWwQSAwkB1IDUkuUAbeAmm/9v4ww4DMeA8pKyifBQhufF0BqQGoxDJjcO7kKObBwBSKIDVXLQEw0fiA2GrEaAEtIJBmATMOSMjY5bAbA0gIyjVeOKrkRAMefDK/b7ecEAAAAAElFTkSuQmCC',
|
||||
update: function() {
|
||||
var clone, favicon, href, l;
|
||||
var clone, favicon, l;
|
||||
l = unread.replies.length;
|
||||
if (g.dead) {
|
||||
if (l > 0) {
|
||||
href = Favicon.unreadDead;
|
||||
} else {
|
||||
href = Favicon.dead;
|
||||
}
|
||||
} else {
|
||||
if (l > 0) {
|
||||
href = Favicon.unread;
|
||||
} else {
|
||||
href = Favicon["default"];
|
||||
}
|
||||
}
|
||||
favicon = $('link[rel="shortcut icon"]', d.head);
|
||||
favicon.href = g.dead ? l ? Favicon.unreadDead : Favicon.dead : l ? Favicon.unread : Favicon["default"];
|
||||
clone = favicon.cloneNode(true);
|
||||
clone.href = href;
|
||||
return $.replace(favicon, clone);
|
||||
}
|
||||
};
|
||||
@ -2779,16 +2750,12 @@
|
||||
return location.href = url;
|
||||
};
|
||||
nodeInserted = function(e) {
|
||||
var callback, target, _i, _len, _ref, _results;
|
||||
var target;
|
||||
target = e.target;
|
||||
if (target.nodeName === 'TABLE') {
|
||||
_ref = g.callbacks;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
callback = _ref[_i];
|
||||
_results.push(callback(target));
|
||||
}
|
||||
return _results;
|
||||
return g.callbacks.forEach(function(callback) {
|
||||
return callback(target);
|
||||
});
|
||||
}
|
||||
};
|
||||
imgHover = {
|
||||
@ -3131,7 +3098,7 @@
|
||||
expandComment.init();
|
||||
}
|
||||
}
|
||||
nodes = $$('.op').concat($$('a + table'));
|
||||
nodes = $$('.op, a + table');
|
||||
g.callbacks.forEach(function(callback) {
|
||||
return nodes.forEach(callback);
|
||||
});
|
||||
@ -3408,6 +3375,6 @@
|
||||
if (d.body) {
|
||||
Main.init();
|
||||
} else {
|
||||
$.bind(document, 'DOMContentLoaded', Main.init);
|
||||
$.bind(d, 'DOMContentLoaded', Main.init);
|
||||
}
|
||||
}).call(this);
|
||||
|
||||
@ -393,25 +393,20 @@ filter =
|
||||
f = filter.match /^\/(.+)\/(\w*)$/
|
||||
@regexps[key].push RegExp f[1], f[2]
|
||||
#only execute what's filterable
|
||||
@callbacks.push @[key] if @regexps[key].length
|
||||
@callbacks.push @[key]
|
||||
|
||||
g.callbacks.push @node
|
||||
|
||||
node: (root) ->
|
||||
if root.className is 'op'
|
||||
if !g.REPLY and conf['Filter OPs']
|
||||
for callback in filter.callbacks
|
||||
if callback root
|
||||
threadHiding.hideHide root.parentNode
|
||||
return
|
||||
else unless root.classList.contains 'inline'
|
||||
for callback in filter.callbacks
|
||||
if callback root
|
||||
replyHiding.hideHide $ 'td:not([nowrap])', root
|
||||
return
|
||||
unless root.className
|
||||
if filter.callbacks.some((callback) -> callback root)
|
||||
replyHiding.hideHide $ 'td:not([nowrap])', root
|
||||
else if root.className is 'op' and not g.REPLY and conf['Filter OPs']
|
||||
if filter.callbacks.some((callback) -> callback root)
|
||||
threadHiding.hideHide root.parentNode
|
||||
|
||||
test: (key, value) ->
|
||||
for regexp in filter.regexps[key]
|
||||
return true if regexp.test value
|
||||
filter.regexps[key].some (regexp) -> regexp.test value
|
||||
|
||||
name: (root) ->
|
||||
name = if root.className is 'op' then $ '.postername', root else $ '.commentpostername', root
|
||||
@ -1821,7 +1816,7 @@ quoteInline =
|
||||
#select the corresponding table or loading td
|
||||
table = $.x "following::*[@id='i#{id}']", q
|
||||
for inlined in $$ 'input', table
|
||||
if hidden = $.id inlined.name
|
||||
unless (hidden = $.id inlined.name).classList.contains 'op'
|
||||
$.x('ancestor::table[1]', hidden).hidden = false
|
||||
$.rm table
|
||||
|
||||
@ -1992,6 +1987,7 @@ Favicon =
|
||||
{href} = favicon
|
||||
Favicon.default = href
|
||||
Favicon.unread = if /ws/.test href then Favicon.unreadSFW else Favicon.unreadNSFW
|
||||
|
||||
dead: 'data:image/gif;base64,R0lGODlhEAAQAKECAAAAAP8AAP///////yH5BAEKAAIALAAAAAAQABAAAAIvlI+pq+D9DAgUoFkPDlbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
|
||||
empty: 'data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///9vb2////yH5BAEAAAMALAAAAAAQABAAAAIvnI+pq+D9DBAUoFkPFnbs7lFZKIJOJJ3MyraoB14jFpOcVMpzrnF3OKlZYsMWowAAOw=='
|
||||
unreadDead: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAANhJREFUOMutU0EKwjAQzEPFgyBFei209gOKINh6tL3qO3yAB9OHWPTeMZsmJaRpiNjAkE1mMt1stgwA+wdsFgM1oHE4FXmSpWUcRzWBYtozNfKAYdCHCrQuosX9tlk+CBS7NKMMbMF7vXoJtC7Om8HwhXzbCWCSn6qBJHd74FIBVS1jm7czYFSsq7gvpY0s6+ThJwc4743EHnGkIW2YAW+AphkMPj6DJE1LXW3fFUhD2pHBsTznLKCIFCstC3nGNvQZnQa6kX4yMGfdyi7OZaB7wZy93Cx/4xfgv/s+XYFMrAAAAABJRU5ErkJggg%3D%3D'
|
||||
@ -2000,21 +1996,22 @@ Favicon =
|
||||
|
||||
update: ->
|
||||
l = unread.replies.length
|
||||
if g.dead
|
||||
if l > 0
|
||||
href = Favicon.unreadDead
|
||||
|
||||
favicon = $ 'link[rel="shortcut icon"]', d.head
|
||||
favicon.href =
|
||||
if g.dead
|
||||
if l
|
||||
Favicon.unreadDead
|
||||
else
|
||||
Favicon.dead
|
||||
else
|
||||
href = Favicon.dead
|
||||
else
|
||||
if l > 0
|
||||
href = Favicon.unread
|
||||
else
|
||||
href = Favicon.default
|
||||
if l
|
||||
Favicon.unread
|
||||
else
|
||||
Favicon.default
|
||||
|
||||
#XXX `favicon.href = href` doesn't work on Firefox
|
||||
favicon = $ 'link[rel="shortcut icon"]', d.head
|
||||
clone = favicon.cloneNode true
|
||||
clone.href = href
|
||||
$.replace favicon, clone
|
||||
|
||||
redirect = ->
|
||||
@ -2034,8 +2031,7 @@ redirect = ->
|
||||
nodeInserted = (e) ->
|
||||
{target} = e
|
||||
if target.nodeName is 'TABLE'
|
||||
for callback in g.callbacks
|
||||
callback target
|
||||
g.callbacks.forEach (callback) -> callback target
|
||||
|
||||
imgHover =
|
||||
init: ->
|
||||
@ -2369,7 +2365,7 @@ Main =
|
||||
if conf['Comment Expansion']
|
||||
expandComment.init()
|
||||
|
||||
nodes = $$('.op').concat $$ 'a + table'
|
||||
nodes = $$ '.op, a + table'
|
||||
g.callbacks.forEach (callback) -> nodes.forEach callback
|
||||
$.bind $('form[name=delform]'), 'DOMNodeInserted', nodeInserted
|
||||
options.init()
|
||||
@ -2642,4 +2638,4 @@ Main =
|
||||
if d.body
|
||||
Main.init()
|
||||
else
|
||||
$.bind document, 'DOMContentLoaded', Main.init
|
||||
$.bind d, 'DOMContentLoaded', Main.init
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user