-oO (op, not op) working, HORRIBLY unoptimized

This commit is contained in:
James Campos 2010-04-29 05:03:33 -07:00
parent 6b5d403368
commit ed539a008c
2 changed files with 47 additions and 17 deletions

View File

@ -154,7 +154,7 @@ filterThread: (thread, filter) ->
s: $('blockquote', thread).textContent
when 'File'
s: x('./span[@class="filesize"]', thread)?.textContent || ''
for regex in filter[field]
for regex in filter[field].all.concat(filter[field].op)
if regex.test(s)
return true
@ -176,7 +176,7 @@ filterReply: (table, filter) ->
s: $('blockquote', table).textContent
when 'File'
s: $('span.filesize', table)?.textContent || ''
for regex in filter[field]
for regex in filter[field].all.concat(filter[field].reply)
if regex.test(s)
return true
@ -195,11 +195,25 @@ filterAll: ->
trimmed: el.trimLeft() for el in split
filtered: trimmed.filter((el)-> el.length)
if filtered.length
regexes: new RegExp(el, 'i') for el in filtered
compiled[filter][field]: regexes
obj: {
all: []
op: []
reply: []
}
for el in filtered
if /\ -\w+$/.test(el)
[nop, el, match]: el.match(/(.+) -(\w+)$/)
switch match
when 'o' then key: 'op'
when 'O' then key: 'reply'
else
key: 'all'
regex: new RegExp(el, 'i')
obj[key].push(regex)
compiled[filter][field]: obj
[replies, threads]: reset()
num: if threads.length then replies.length + threads.length else $$('blockquote', form).length
num: if threads.length then replies.length + threads.length else $$('blockquote').length
#these loops look combinable
for reply in replies

View File

@ -183,7 +183,7 @@ display: none; \
} else if (field === 'File') {
s = ((_e = x('./span[@class="filesize"]', thread)) == undefined ? undefined : _e.textContent) || '';
}
_g = filter[field];
_g = filter[field].all.concat(filter[field].op);
for (_f = 0, _h = _g.length; _f < _h; _f++) {
regex = _g[_f];
if (regex.test(s)) {
@ -211,7 +211,7 @@ display: none; \
} else if (field === 'File') {
s = ((_e = $('span.filesize', table)) == undefined ? undefined : _e.textContent) || '';
}
_g = filter[field];
_g = filter[field].all.concat(filter[field].reply);
for (_f = 0, _h = _g.length; _f < _h; _f++) {
regex = _g[_f];
if (regex.test(s)) {
@ -229,7 +229,7 @@ display: none; \
_a = filters;
for (filter in _a) { if (__hasProp.call(_a, filter)) {
(function() {
var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, el, field, filtered, regexes, s, split, trimmed;
var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, el, field, filtered, key, match, nop, obj, regex, s, split, trimmed;
compiled[filter] = {};
_b = []; _c = filters[filter];
for (field in _c) { if (__hasProp.call(_c, field)) {
@ -248,15 +248,31 @@ display: none; \
return el.length;
});
if (filtered.length) {
regexes = (function() {
_h = []; _j = filtered;
for (_i = 0, _k = _j.length; _i < _k; _i++) {
el = _j[_i];
_h.push(new RegExp(el, 'i'));
obj = {
all: [],
op: [],
reply: []
};
_i = filtered;
for (_h = 0, _j = _i.length; _h < _j; _h++) {
el = _i[_h];
if (/\ -\w+$/.test(el)) {
_k = el.match(/(.+) -(\w+)$/);
nop = _k[0];
el = _k[1];
match = _k[2];
if (match === 'o') {
key = 'op';
} else if (match === 'O') {
key = 'reply';
}
} else {
key = 'all';
}
return _h;
})();
compiled[filter][field] = regexes;
regex = new RegExp(el, 'i');
obj[key].push(regex);
}
compiled[filter][field] = obj;
return compiled[filter][field];
}
})());
@ -267,7 +283,7 @@ display: none; \
_b = reset();
replies = _b[0];
threads = _b[1];
num = threads.length ? replies.length + threads.length : $$('blockquote', form).length;
num = threads.length ? replies.length + threads.length : $$('blockquote').length;
//these loops look combinable
_d = replies;
for (_c = 0, _e = _d.length; _c < _e; _c++) {