code review, polishing

This commit is contained in:
gorhill 2015-03-06 00:36:45 -05:00
parent d376c69e2f
commit aa955ebe09
2 changed files with 9 additions and 4 deletions

View file

@ -483,14 +483,15 @@ var userFilterFromCandidate = function() {
} }
// Cosmetic filter? // Cosmetic filter?
if ( v.slice(0, 2) === '##' ) { if ( v.lastIndexOf('##', 0) === 0 ) {
return window.location.hostname + v; return window.location.hostname + v;
} }
// If domain included in filter, no need for domain option // If domain included in filter, no need for domain option
if ( v.slice(0, 2) === '||' ) { if ( v.lastIndexOf('||', 0) === 0 ) {
return v; return v;
} }
// Assume net filter // Assume net filter
return v + '$domain=' + window.location.hostname; return v + '$domain=' + window.location.hostname;
}; };
@ -560,7 +561,11 @@ var onDialogClicked = function(ev) {
else if ( ev.target.id === 'create' ) { else if ( ev.target.id === 'create' ) {
var filter = userFilterFromCandidate(); var filter = userFilterFromCandidate();
if ( filter ) { if ( filter ) {
localMessager.send({ what: 'createUserFilter', filters: filter }); var d = new Date();
localMessager.send({
what: 'createUserFilter',
filters: '# ' + d.toLocaleString() + ' ' + window.location.href + '\n' + filter,
});
removeElements(elementsFromFilter(taCandidate.value)); removeElements(elementsFromFilter(taCandidate.value));
stopPicker(); stopPicker();
} }

View file

@ -129,7 +129,7 @@
if ( details.content.indexOf(content.trim()) !== -1 ) { if ( details.content.indexOf(content.trim()) !== -1 ) {
return; return;
} }
µb.saveUserFilters(details.content.trim() + '\n' + content.trim(), onSaved); µb.saveUserFilters(details.content.trim() + '\n\n' + content.trim(), onSaved);
}; };
this.loadUserFilters(onLoaded); this.loadUserFilters(onLoaded);