Include specificity in popup ordering algorithm (#47)
This commit is contained in:
@@ -154,8 +154,8 @@ function search(s) {
|
|||||||
);
|
);
|
||||||
candidates = recent.concat(remainingInCurrentDomain);
|
candidates = recent.concat(remainingInCurrentDomain);
|
||||||
}
|
}
|
||||||
candidates.sort(function(a, b) {
|
candidates.sort((a, b) => {
|
||||||
// sort most recent first
|
// show most recent first
|
||||||
if (a === mostRecent) {
|
if (a === mostRecent) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -163,12 +163,21 @@ function search(s) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort by count
|
// sort by frequency
|
||||||
var countDiff = b.recent.count - a.recent.count;
|
var countDiff = b.recent.count - a.recent.count;
|
||||||
if (countDiff) {
|
if (countDiff) {
|
||||||
return countDiff;
|
return countDiff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort by specificity, only if filtering for one domain
|
||||||
|
if (this.currentDomainOnly) {
|
||||||
|
var domainLevelsDiff =
|
||||||
|
(b.login.match(/\./g) || []).length - (a.login.match(/\./g) || []).length;
|
||||||
|
if (domainLevelsDiff) {
|
||||||
|
return domainLevelsDiff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// sort alphabetically
|
// sort alphabetically
|
||||||
return a.login.localeCompare(b.login);
|
return a.login.localeCompare(b.login);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user