1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 16:24:12 +01:00

added google suggestions to tab completion

This commit is contained in:
Martin Stubenschrott
2008-03-31 13:22:47 +00:00
parent 2750f36032
commit 19059a46cb
5 changed files with 25 additions and 3 deletions

View File

@@ -177,6 +177,23 @@ liberator.Completion = function () //{{{
});
return [0, buildLongestCommonSubstring(mapped, filter)];
},
googleSuggest: function(filter)
{
const endPoint = "http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl=" +
liberator.options.getPref("font.language.group", "en") + "&qu=";
var xhr = new XMLHttpRequest();
var completions = [];
xhr.open("GET", endPoint + encodeURIComponent(filter), false);
xhr.send(null);
var response = window.eval(xhr.responseText)[1];
for each (var item in response)
completions.push([item, "Google Suggestion"]);
return [0, completions];
},
// filter a list of urls
//
// may consist of search engines, filenames, bookmarks and history,
@@ -207,6 +224,8 @@ liberator.Completion = function () //{{{
completions = completions.concat(liberator.bookmarks.get(filter));
else if (cpt[i] == "h")
completions = completions.concat(liberator.history.get(filter));
else if (cpt[i] == "g")
completions = completions.concat(this.googleSuggest(filter)[1]);
}
return [start, completions];

View File

@@ -903,8 +903,9 @@ liberator.Events = function () //{{{
// dump("=+++++++++=\n" + liberator.util.objectToString(event.target) + "\n")
// dump (elem + ": " + win + "\n");//" - target: " + event.target + " - origtarget: " + event.originalTarget + " - expltarget: " + event.explicitOriginalTarget + "\n");
if (elem && elem instanceof HTMLInputElement &&
(elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password"))
if (win == window.content && // don't store it if e.g. the command line has focus
elem && elem instanceof HTMLInputElement &&
(elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password"))
{
this.wantsModeReset = false;
liberator.mode = liberator.modes.INSERT;

View File

@@ -286,7 +286,7 @@ liberator.CommandLine = function () //{{{
"Items which are completed at the :[tab]open prompt",
"charlist", "sfbh",
{
validator: function (value) { return !/[^sfbh]/.test(value); }
validator: function (value) { return !/[^sfbhg]/.test(value); }
});
liberator.options.add(["showmode", "smd"],