'+
+ '
'+
+ '' + utils.escapeHtml(this.prompt) + ' '+
+ '
'+
+ '
');
+ this.box.style.display = 'none';
document.body.appendChild(this.box);
+
+ this.input = document.getElementById("fuzzyboxInput");
+ this.completionList = document.getElementById("fuzzyboxCompletions");
},
}
--
cgit v1.2.3
From 99c19d210f4f7024585eb93d80967377c67fa44e Mon Sep 17 00:00:00 2001
From: Niklas Baumstark
Date: Wed, 25 Jan 2012 00:30:36 +0100
Subject: fix regression in 10a77d25c3
---
fuzzyMode.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fuzzyMode.js b/fuzzyMode.js
index 8b817883..1edb18f0 100644
--- a/fuzzyMode.js
+++ b/fuzzyMode.js
@@ -80,9 +80,8 @@ var fuzzyMode = (function() {
},
updateSelection: function() {
- this.completionList.childNodes.forEach(function(child, i) {
- child.className = (i == this.selection) ? 'selected' : '';
- });
+ for (var i = 0; i < this.completionList.children.length; ++i)
+ this.completionList.children[i].className = (i == this.selection) ? 'selected' : '';
},
onKeydown: function(event) {
--
cgit v1.2.3
From b226ddf11348660dc8e9f39dcf7346944082ff67 Mon Sep 17 00:00:00 2001
From: Niklas Baumstark
Date: Wed, 25 Jan 2012 00:41:47 +0100
Subject: move query length threshold from UI to logic
This enables to set threshold to 0 for tabs (so that tabs are shown before typing).
---
fuzzyMode.js | 19 +++++--------------
lib/completion.js | 13 +++++++++++--
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/fuzzyMode.js b/fuzzyMode.js
index 1edb18f0..cfa8656f 100644
--- a/fuzzyMode.js
+++ b/fuzzyMode.js
@@ -18,14 +18,14 @@ var fuzzyMode = (function() {
else if (name === 'tabs')
return new completion.FuzzyTabCompleter();
else if (name === 'tabsSorted')
- return new completion.MergingCompleter([getCompleter('tabs')]);
+ return new completion.MergingCompleter([getCompleter('tabs')], 0);
else if (name === 'all')
return new completion.MergingCompleter([
getCompleter('smart'),
getCompleter('bookmarks'),
getCompleter('history'),
getCompleter('tabs'),
- ]);
+ ], 1);
}
function getCompleter(name) {
if (!(name in completers))
@@ -49,7 +49,6 @@ var fuzzyMode = (function() {
this.maxResults = maxResults;
this.refreshInterval = refreshInterval;
this.initDom();
- this.reset();
}
FuzzyBox.prototype = {
setCompleter: function(completer) {
@@ -141,17 +140,7 @@ var fuzzyMode = (function() {
return true;
},
- updateInput: function() {
- this.query = this.query.replace(/^\s*/, '');
- this.input.textContent = this.query;
- },
-
updateCompletions: function() {
- if (this.query.length == 0) {
- this.completionList.style.display = 'none';
- return;
- }
-
var self = this;
this.completer.filter(this.query, function(completions) {
self.completions = completions.slice(0, self.maxResults);
@@ -168,7 +157,9 @@ var fuzzyMode = (function() {
update: function(sync) {
sync = sync || false; // explicitely default to asynchronous updating
- this.updateInput();
+
+ this.query = this.query.replace(/^\s*/, '');
+ this.input.textContent = this.query;
if (sync) {
this.updateCompletions();
diff --git a/lib/completion.js b/lib/completion.js
index d36dc2e5..b5793437 100644
--- a/lib/completion.js
+++ b/lib/completion.js
@@ -449,9 +449,13 @@ var completion = (function() {
}
/** A meta-completer that delegates queries and merges and sorts the results of a collection of other
- * completer instances. */
- var MergingCompleter = function(sources) {
+ * completer instances given in :sources. The optional argument :queryThreshold determines how long a
+ * query has to be to trigger a refresh. */
+ var MergingCompleter = function(sources, queryThreshold) {
+ if (queryThreshold === undefined)
+ queryThreshold = 1; // default
this.sources = sources;
+ this.queryThreshold = queryThreshold;
}
MergingCompleter.prototype = {
refresh: function() {
@@ -459,6 +463,11 @@ var completion = (function() {
},
filter: function(query, callback) {
+ if (query.length < this.queryThreshold) {
+ callback([]);
+ return;
+ }
+
var all = [];
var counter = this.sources.length;
--
cgit v1.2.3
From c397fffc94f563f1475f37c90eefa154ac78a6e0 Mon Sep 17 00:00:00 2001
From: Niklas Baumstark
Date: Wed, 25 Jan 2012 00:47:39 +0100
Subject: prevent duplicate history items
---
background_page.html | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/background_page.html b/background_page.html
index f220d76c..e248043c 100644
--- a/background_page.html
+++ b/background_page.html
@@ -332,7 +332,9 @@
chrome.history.onVisited.addListener(function(item) {
if (cachedHistory === null) return;
- cachedHistory.push(item);
+ // only cache newly visited sites
+ if (item.visitCount === 1)
+ cachedHistory.push(item);
});
function getHistory(args, port) {
--
cgit v1.2.3
From ff8e8aa0e22a474b950b551259d330a7705514c3 Mon Sep 17 00:00:00 2001
From: Niklas Baumstark
Date: Wed, 25 Jan 2012 00:54:53 +0100
Subject: make refresh interval configurable
For example, tab completion can happen instantly while history completion shouldn't.
---
fuzzyMode.js | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/fuzzyMode.js b/fuzzyMode.js
index cfa8656f..87b4470a 100644
--- a/fuzzyMode.js
+++ b/fuzzyMode.js
@@ -34,20 +34,21 @@ var fuzzyMode = (function() {
}
/** Trigger the fuzzy mode dialog */
- function start(name, reverseAction) {
+ function start(name, reverseAction, refreshInterval) {
var completer = getCompleter(name);
if (!fuzzyBox)
- fuzzyBox = new FuzzyBox(10, 300);
+ fuzzyBox = new FuzzyBox(10);
completer.refresh();
fuzzyBox.setCompleter(completer);
+ fuzzyBox.setRefreshInterval(refreshInterval);
fuzzyBox.show(reverseAction);
}
/** User interface for fuzzy completion */
- var FuzzyBox = function(maxResults, refreshInterval) {
+ var FuzzyBox = function(maxResults) {
this.prompt = '>';
this.maxResults = maxResults;
- this.refreshInterval = refreshInterval;
+ this.refreshInterval = 0;
this.initDom();
}
FuzzyBox.prototype = {
@@ -56,6 +57,10 @@ var fuzzyMode = (function() {
this.reset();
},
+ setRefreshInterval: function(refreshInterval) {
+ this.refreshInterval = refreshInterval;
+ },
+
show: function(reverseAction) {
this.reverseAction = reverseAction;
this.box.style.display = 'block';
@@ -193,9 +198,9 @@ var fuzzyMode = (function() {
// public interface
return {
- activateAll: function() { start('all', false); },
- activateAllNewTab: function() { start('all', true); },
- activateTabs: function() { start('tabsSorted', false); },
+ activateAll: function() { start('all', false, 300); },
+ activateAllNewTab: function() { start('all', true, 300); },
+ activateTabs: function() { start('tabsSorted', false, 0); },
}
})();
--
cgit v1.2.3
From a0d0d8ecfe40a1b802f72dff100185875ee63e2f Mon Sep 17 00:00:00 2001
From: Niklas Baumstark
Date: Wed, 25 Jan 2012 01:21:56 +0100
Subject: make refresh