Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Closes #181: Speak Words inteferes with quick keyword bookmark access
Browse files Browse the repository at this point in the history
Prefer keywords first as they've been specially selected and likely shorter than other words.
  • Loading branch information
Mardak committed May 30, 2011
1 parent 68b795d commit 6626940
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions speakWords/bootstrap.js
Expand Up @@ -271,16 +271,6 @@ function startup(data) AddonManager.getAddonByID(data.id, function(addon) {
// Add enter-selects functionality to all windows
watchWindows(addEnterSelects);

// Use input history to discover keywords from typed letters
let query = "SELECT * " +
"FROM moz_inputhistory " +
"JOIN moz_places " +
"ON id = place_id " +
"WHERE input NOT NULL " +
"ORDER BY frecency DESC";
let cols = ["input", "url", "title"];
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(query);

// Break a string into individual words separated by the splitter
function explode(text, splitter) {
return (text || "").toLowerCase().split(splitter).filter(function(word) {
Expand All @@ -306,6 +296,24 @@ function startup(data) AddonManager.getAddonByID(data.id, function(addon) {

// Keep a nested array of array of keywords -- 2 arrays per entry
let allKeywords = [];

// Add bookmark keywords to the list of potential keywords
let query = "SELECT * FROM moz_keywords";
let cols = ["keyword"];
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(query);
Utils.queryAsync(stmt, cols).forEach(function({keyword}) {
allKeywords.push([keyword]);
});

// Use input history to discover keywords from typed letters
let query = "SELECT * " +
"FROM moz_inputhistory " +
"JOIN moz_places " +
"ON id = place_id " +
"WHERE input NOT NULL " +
"ORDER BY frecency DESC";
let cols = ["input", "url", "title"];
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(query);
Utils.queryAsync(stmt, cols).forEach(function({input, url, title}) {
// Add keywords for word parts that start with the input word
let word = input.trim().toLowerCase().split(/\s+/)[0];
Expand Down Expand Up @@ -343,14 +351,6 @@ function startup(data) AddonManager.getAddonByID(data.id, function(addon) {
addDomains("ORDER BY visit_count DESC LIMIT 100");
addDomains("ORDER BY last_visit_date DESC LIMIT 100");

// Add bookmark keywords to the list of potential keywords
let query = "SELECT * FROM moz_keywords";
let stmt = PlacesUtils.history.DBConnection.createAsyncStatement(query);
let cols = ["keyword"];
Utils.queryAsync(stmt, cols).forEach(function({keyword}) {
allKeywords.push([keyword]);
});

// Do a breadth first traversal of the keywords
do {
// Remove any empty results and stop if there's no more
Expand Down

0 comments on commit 6626940

Please sign in to comment.