Skip to content

Commit

Permalink
Option to disable suggestions (#516)
Browse files Browse the repository at this point in the history
* Option to disable suggestions

* fix logic for displaying search suggestions

* carify boolean expressions for  input suggestions

* add semicolons
  • Loading branch information
simonwjackson authored and brookhong committed Oct 11, 2017
1 parent 5068435 commit 5c167b1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ For example,
| settings.focusOnSaved | true | Whether to focus text input after quiting from vim editor. |
| settings.omnibarMaxResults | 10 | How many results will be listed out each page for Omnibar. |
| settings.omnibarPosition | "middle" | Where to position Omnibar. ["middle", "bottom"] |
| settings.omnibarSuggestion | false | Show suggestion URLs|
| settings.omnibarSuggestionTimeout | 200 | Timeout duration before Omnibar suggestion URLs are queried, in milliseconds. Helps prevent unnecessary HTTP requests and API rate-limiting. |
| settings.focusFirstCandidate | false | Whether to focus first candidate of matched result in Omnibar. |
| settings.tabsThreshold | 9 | When total of opened tabs exceeds the number, Omnibar will be used for choosing tabs. |
Expand Down
45 changes: 23 additions & 22 deletions content_scripts/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@ var runtime = window.runtime || (function() {
conf: {
lastKeys: "",
// local part from settings
useLocalMarkdownAPI: true,
blacklistPattern: undefined,
caseSensitive: false,
clickablePat: /(https?|thunder|magnet):\/\/\S+/ig,
clickableSelector: "",
cursorAtEndOfInput: true,
defaultSearchEngine: "g",
defaultVoice: "Daniel",
enableAutoFocus: true,
experiment: false,
focusFirstCandidate: false,
focusOnSaved: true,
hintAlign: "center",
historyMUOrder: true,
language: undefined,
lastQuery: "",
modeAfterYank: "",
nextLinkRegex: /(\b(next)\b)|||>>/i,
omnibarMaxResults: 10,
omnibarPosition: "middle",
omnibarSuggestion: true,
omnibarSuggestionTimeout: 200,
omnibarTabsQuery: {},
historyMUOrder: true,
tabsThreshold: 9,
smoothScroll: true,
modeAfterYank: "",
scrollStepSize: 70,
nextLinkRegex: /(\b(next)\b)|||>>/i,
prevLinkRegex: /(\b(prev|previous)\b)|||<</i,
pageUrlRegex: [],
clickablePat: /(https?|thunder|magnet):\/\/\S+/ig,
hintAlign: "center",
defaultSearchEngine: "g",
prevLinkRegex: /(\b(prev|previous)\b)|||<</i,
richHintsForKeystroke: 1000,
scrollStepSize: 70,
showModeStatus: false,
showProxyInStatusBar: false,
richHintsForKeystroke: 1000,
smartPageBoundary: false,
clickableSelector: "",
blacklistPattern: undefined,
smoothScroll: true,
startToShowEmoji: 2,
focusFirstCandidate: false,
language: undefined,
stealFocusOnLoad: true,
enableAutoFocus: true,
defaultVoice: "Daniel",
experiment: false,
caseSensitive: false,
cursorAtEndOfInput: true,
lastQuery: ""
tabsThreshold: 9,
useLocalMarkdownAPI: true,
},
runtime_handlers: {}
}, actions = {};
Expand Down
8 changes: 5 additions & 3 deletions pages/omnibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,11 @@ var SearchEngine = (function() {
return this.activeTab;
};
self.onInput = function() {
if (!self.suggestionURL || typeof(self.listSuggestion) !== "function") {
return;
}
const canSuggest = self.suggestionURL && typeof(self.listSuggestion) === "function";
const showSuggestions = canSuggest && runtime.conf.omnibarSuggestion;

if (!showSuggestions) return false;

var val = encodeURIComponent(Omnibar.input.val());
clearPendingRequest();
// Set a timeout before the request is dispatched so that it can be canceled if necessary.
Expand Down

0 comments on commit 5c167b1

Please sign in to comment.