Fix Filter
This commit is contained in:
parent
b848007865
commit
1bafa6ef47
@ -115,7 +115,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, Connection, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, ShimSet, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
|
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, Connection, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Labels, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, ShimSet, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
|
||||||
__slice = [].slice,
|
__slice = [].slice,
|
||||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||||
__hasProp = {}.hasOwnProperty,
|
__hasProp = {}.hasOwnProperty,
|
||||||
@ -3671,7 +3671,8 @@
|
|||||||
return delete this.nodes.stub;
|
return delete this.nodes.stub;
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.prototype.highlight = function(highlight, top) {
|
Post.prototype.highlight = function(label, highlight, top) {
|
||||||
|
this.labels.push(label);
|
||||||
if (__indexOf.call(this.highlights, highlight) < 0) {
|
if (__indexOf.call(this.highlights, highlight) < 0) {
|
||||||
this.highlights.push(highlight);
|
this.highlights.push(highlight);
|
||||||
$.addClass(this.nodes.root, highlight);
|
$.addClass(this.nodes.root, highlight);
|
||||||
@ -7512,7 +7513,11 @@
|
|||||||
},
|
},
|
||||||
createFilter: function(regexp, op, stub, hl, top) {
|
createFilter: function(regexp, op, stub, hl, top) {
|
||||||
var settings, test;
|
var settings, test;
|
||||||
test = typeof regexp === 'string' ? Filter.stringTest : Filter.regexpTest;
|
test = typeof regexp === 'string' ? function(value) {
|
||||||
|
return regexp === value;
|
||||||
|
} : function(value) {
|
||||||
|
return regexp.test(value);
|
||||||
|
};
|
||||||
settings = {
|
settings = {
|
||||||
hide: !hl,
|
hide: !hl,
|
||||||
stub: stub,
|
stub: stub,
|
||||||
@ -7520,9 +7525,13 @@
|
|||||||
top: top
|
top: top
|
||||||
};
|
};
|
||||||
return function(value, isReply) {
|
return function(value, isReply) {
|
||||||
if (Filter.test(test, value, isReply)) {
|
if (isReply && op === 'only' || !isReply && op === 'no') {
|
||||||
return settings;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!test(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return settings;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
@ -7550,23 +7559,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stringTest: function(string, value) {
|
|
||||||
return string === value;
|
|
||||||
},
|
|
||||||
regexpTest: function(regexp, value) {
|
|
||||||
return regexp.test(value);
|
|
||||||
},
|
|
||||||
test: function(_arg, value, isReply) {
|
|
||||||
var match, op, test;
|
|
||||||
test = _arg.test, match = _arg.match, op = _arg.op;
|
|
||||||
if (isReply && op === 'only' || !isReply && op === 'no') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!test(match, value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
name: function(post) {
|
name: function(post) {
|
||||||
if ('name' in post.info) {
|
if ('name' in post.info) {
|
||||||
return post.info.name;
|
return post.info.name;
|
||||||
@ -13436,6 +13428,38 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Labels = {
|
||||||
|
init: function() {
|
||||||
|
if (!Conf['Menu']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return Menu.menu.addEntry({
|
||||||
|
el: $.el('div', {
|
||||||
|
textContent: 'Labels'
|
||||||
|
}),
|
||||||
|
order: 60,
|
||||||
|
open: function(post, addSubEntry) {
|
||||||
|
var label, labels, _i, _len;
|
||||||
|
labels = (post.origin || post).labels;
|
||||||
|
if (!labels.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.subEntries.length = 0;
|
||||||
|
for (_i = 0, _len = labels.length; _i < _len; _i++) {
|
||||||
|
label = labels[_i];
|
||||||
|
addSubEntry({
|
||||||
|
el: $.el('div', {
|
||||||
|
textContent: label
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
subEntries: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Menu = {
|
Menu = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var _ref;
|
var _ref;
|
||||||
|
|||||||
@ -88,7 +88,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, Connection, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, ShimSet, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
|
var $, $$, Anonymize, AntiAutoplay, ArchiveLink, Banner, Board, Build, Callbacks, Captcha, CatalogLinks, CatalogThread, Clone, Color, Conf, Config, Connection, CrossOrigin, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, E, Embedding, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Flash, Fourchan, Gallery, Get, GlobalMessage, Header, IDColor, IDHighlight, ImageCommon, ImageExpand, ImageHover, ImageLoader, Index, JSColor, Keybinds, Labels, Linkify, Main, MarkNewIPs, MascotTools, Mascots, Menu, Nav, Navigate, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteInline, QuoteMarkers, QuotePreview, QuoteStrikeThrough, QuoteThreading, Quotify, RandomAccessList, Recursive, Redirect, RelativeDates, RemoveSpoilers, ReportLink, RevealSpoilers, Rice, Sauce, Settings, ShimSet, SimpleDict, Style, ThemeTools, Themes, Thread, ThreadExcerpt, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, editMascot, editTheme, g, userNavigation,
|
||||||
__slice = [].slice,
|
__slice = [].slice,
|
||||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||||
__hasProp = {}.hasOwnProperty,
|
__hasProp = {}.hasOwnProperty,
|
||||||
@ -3689,7 +3689,8 @@
|
|||||||
return delete this.nodes.stub;
|
return delete this.nodes.stub;
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.prototype.highlight = function(highlight, top) {
|
Post.prototype.highlight = function(label, highlight, top) {
|
||||||
|
this.labels.push(label);
|
||||||
if (__indexOf.call(this.highlights, highlight) < 0) {
|
if (__indexOf.call(this.highlights, highlight) < 0) {
|
||||||
this.highlights.push(highlight);
|
this.highlights.push(highlight);
|
||||||
$.addClass(this.nodes.root, highlight);
|
$.addClass(this.nodes.root, highlight);
|
||||||
@ -7546,7 +7547,11 @@
|
|||||||
},
|
},
|
||||||
createFilter: function(regexp, op, stub, hl, top) {
|
createFilter: function(regexp, op, stub, hl, top) {
|
||||||
var settings, test;
|
var settings, test;
|
||||||
test = typeof regexp === 'string' ? Filter.stringTest : Filter.regexpTest;
|
test = typeof regexp === 'string' ? function(value) {
|
||||||
|
return regexp === value;
|
||||||
|
} : function(value) {
|
||||||
|
return regexp.test(value);
|
||||||
|
};
|
||||||
settings = {
|
settings = {
|
||||||
hide: !hl,
|
hide: !hl,
|
||||||
stub: stub,
|
stub: stub,
|
||||||
@ -7554,9 +7559,13 @@
|
|||||||
top: top
|
top: top
|
||||||
};
|
};
|
||||||
return function(value, isReply) {
|
return function(value, isReply) {
|
||||||
if (Filter.test(test, value, isReply)) {
|
if (isReply && op === 'only' || !isReply && op === 'no') {
|
||||||
return settings;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!test(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return settings;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
@ -7584,23 +7593,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
stringTest: function(string, value) {
|
|
||||||
return string === value;
|
|
||||||
},
|
|
||||||
regexpTest: function(regexp, value) {
|
|
||||||
return regexp.test(value);
|
|
||||||
},
|
|
||||||
test: function(_arg, value, isReply) {
|
|
||||||
var match, op, test;
|
|
||||||
test = _arg.test, match = _arg.match, op = _arg.op;
|
|
||||||
if (isReply && op === 'only' || !isReply && op === 'no') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!test(match, value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
name: function(post) {
|
name: function(post) {
|
||||||
if ('name' in post.info) {
|
if ('name' in post.info) {
|
||||||
return post.info.name;
|
return post.info.name;
|
||||||
@ -13452,6 +13444,38 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Labels = {
|
||||||
|
init: function() {
|
||||||
|
if (!Conf['Menu']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return Menu.menu.addEntry({
|
||||||
|
el: $.el('div', {
|
||||||
|
textContent: 'Labels'
|
||||||
|
}),
|
||||||
|
order: 60,
|
||||||
|
open: function(post, addSubEntry) {
|
||||||
|
var label, labels, _i, _len;
|
||||||
|
labels = (post.origin || post).labels;
|
||||||
|
if (!labels.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.subEntries.length = 0;
|
||||||
|
for (_i = 0, _len = labels.length; _i < _len; _i++) {
|
||||||
|
label = labels[_i];
|
||||||
|
addSubEntry({
|
||||||
|
el: $.el('div', {
|
||||||
|
textContent: label
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
subEntries: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Menu = {
|
Menu = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var _ref;
|
var _ref;
|
||||||
|
|||||||
@ -79,9 +79,9 @@ Filter =
|
|||||||
test =
|
test =
|
||||||
if typeof regexp is 'string'
|
if typeof regexp is 'string'
|
||||||
# MD5 checking
|
# MD5 checking
|
||||||
Filter.stringTest
|
(value) -> regexp is value
|
||||||
else
|
else
|
||||||
Filter.regexpTest
|
(value) -> regexp.test value
|
||||||
|
|
||||||
settings =
|
settings =
|
||||||
hide: !hl
|
hide: !hl
|
||||||
@ -89,7 +89,12 @@ Filter =
|
|||||||
class: hl
|
class: hl
|
||||||
top: top
|
top: top
|
||||||
|
|
||||||
(value, isReply) -> return settings if Filter.test(test, value, isReply)
|
(value, isReply) ->
|
||||||
|
if isReply and op is 'only' or !isReply and op is 'no'
|
||||||
|
return false
|
||||||
|
unless test value
|
||||||
|
return false
|
||||||
|
settings
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
return if @isClone or @isFetchedQuote
|
return if @isClone or @isFetchedQuote
|
||||||
@ -106,17 +111,6 @@ Filter =
|
|||||||
# Highlight
|
# Highlight
|
||||||
@highlight "Highlighted by filtering the #{key}: #{result.match}", result.class, result.top
|
@highlight "Highlighted by filtering the #{key}: #{result.match}", result.class, result.top
|
||||||
|
|
||||||
stringTest: (string, value) ->
|
|
||||||
string is value
|
|
||||||
regexpTest: (regexp, value) ->
|
|
||||||
regexp.test value
|
|
||||||
test: ({test, match, op}, value, isReply) ->
|
|
||||||
if isReply and op is 'only' or !isReply and op is 'no'
|
|
||||||
return false
|
|
||||||
unless test match, value
|
|
||||||
return false
|
|
||||||
true
|
|
||||||
|
|
||||||
name: (post) ->
|
name: (post) ->
|
||||||
if 'name' of post.info
|
if 'name' of post.info
|
||||||
return post.info.name
|
return post.info.name
|
||||||
|
|||||||
@ -233,7 +233,9 @@ class Post
|
|||||||
@nodes.post.previousElementSibling.hidden = false
|
@nodes.post.previousElementSibling.hidden = false
|
||||||
$.rm @nodes.stub
|
$.rm @nodes.stub
|
||||||
delete @nodes.stub
|
delete @nodes.stub
|
||||||
highlight: (highlight, top) ->
|
|
||||||
|
highlight: (label, highlight, top) ->
|
||||||
|
@labels.push label
|
||||||
unless highlight in @highlights
|
unless highlight in @highlights
|
||||||
@highlights.push highlight
|
@highlights.push highlight
|
||||||
$.addClass @nodes.root, highlight
|
$.addClass @nodes.root, highlight
|
||||||
|
|||||||
16
src/Menu/Labels.coffee
Normal file
16
src/Menu/Labels.coffee
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Labels =
|
||||||
|
init: ->
|
||||||
|
return if !Conf['Menu']
|
||||||
|
|
||||||
|
Menu.menu.addEntry
|
||||||
|
el: $.el 'div', textContent: 'Labels'
|
||||||
|
order: 60
|
||||||
|
open: (post, addSubEntry) ->
|
||||||
|
{labels} = post.origin or post
|
||||||
|
return false unless labels.length
|
||||||
|
@subEntries.length = 0
|
||||||
|
for label in labels
|
||||||
|
addSubEntry el: $.el 'div', textContent: label
|
||||||
|
true
|
||||||
|
subEntries: []
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user