Add button to remove domain filter (#7)

* Add button to remove domain filter

* Fix removing hint via backspace when search text is present

* Move trim & fuzzy-enabled into search function

* Simplify code

* Use a more descriptive name
This commit is contained in:
Erayd
2018-04-21 20:46:59 +12:00
committed by GitHub
parent 9c6b7237f5
commit 6efaa5ef36
5 changed files with 88 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ function Interface(settings, logins) {
this.settings = settings;
this.logins = logins;
this.results = [];
this.active = !settings.tab.url.match(/^chrome:\/\//);
this.currentDomainOnly = !settings.tab.url.match(/^chrome:\/\//);
this.searchPart = new SearchInterface(this);
// initialise with empty search
@@ -131,16 +131,17 @@ function view(ctl, params) {
* Run a search
*
* @param string s Search string
* @param bool fuzzyFirstWord Whether to use fuzzy search on the first word
* @return void
*/
function search(s, fuzzyFirstWord = true) {
function search(s) {
var self = this;
var fuzzyFirstWord = s.substr(0, 1) !== " ";
s = s.trim();
// get candidate list
var candidates = this.logins.map(result => Object.assign(result, { display: result.login }));
if (this.active) {
candidates = candidates.filter(login => login.active);
if (this.currentDomainOnly) {
candidates = candidates.filter(login => login.inCurrentDomain);
}
if (s.length) {