1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-23 00:15:46 +01:00

Whitespace fixes.

This commit is contained in:
Doug Kearns
2009-03-25 15:31:24 +11:00
parent 3ba37cf93a
commit d3642a67fa

View File

@@ -57,7 +57,7 @@ function Bookmarks() //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
const historyService = PlacesUtils.history; //Cc["@mozilla.org/browser/global-history;1"].getService(Ci.nsIGlobalHistory); const historyService = PlacesUtils.history; //Cc["@mozilla.org/browser/global-history;1"].getService(Ci.nsIGlobalHistory);
const bookmarksService = PlacesUtils.bookmarks //Cc["@songbirdnest.com/servicepane/bookmarks;1"].getService(Ci.sbIBookmarks); const bookmarksService = PlacesUtils.bookmarks //Cc["@songbirdnest.com/servicepane/bookmarks;1"].getService(Ci.sbIBookmarks);
const taggingService = PlacesUtils.tagging //Cc["@mozilla.org/browser/tagging-service;1"].getService(Ci.nsITaggingService); const taggingService = PlacesUtils.tagging //Cc["@mozilla.org/browser/tagging-service;1"].getService(Ci.nsITaggingService);
const faviconService = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService); const faviconService = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
@@ -571,14 +571,14 @@ function Bookmarks() //{{{
getSuggestions: function getSuggestions(engineName, query, callback) getSuggestions: function getSuggestions(engineName, query, callback)
{ {
const responseType = "application/x-suggestions+json"; const responseType = "application/x-suggestions+json";
let engine = services.get("browserSearch").getEngineByAlias(engineName); let engine = services.get("browserSearch").getEngineByAlias(engineName);
if (engine && engine.supportsResponseType(responseType)) if (engine && engine.supportsResponseType(responseType))
var queryURI = engine.getSubmission(query, responseType).uri.spec; var queryURI = engine.getSubmission(query, responseType).uri.spec;
if (!queryURI) if (!queryURI)
return []; return [];
function process(resp) function process(resp)
{ {
let results = []; let results = [];
@@ -594,7 +594,7 @@ function Bookmarks() //{{{
} }
let resp = util.httpGet(queryURI, callback && process); let resp = util.httpGet(queryURI, callback && process);
if (!callback) if (!callback)
return process(resp); return process(resp);
}, },
@@ -620,74 +620,74 @@ function Bookmarks() //{{{
// we need to make sure our custom alias have been set, even if the user // we need to make sure our custom alias have been set, even if the user
// did not :open <tab> once before // did not :open <tab> once before
this.getSearchEngines(); this.getSearchEngines();
function getShortcutOrURI(aURL, aPostDataRef)
{ function getShortcutOrURI(aURL, aPostDataRef)
var shortcutURL = null; {
var keyword = aURL; var shortcutURL = null;
var param = ""; var keyword = aURL;
var searchService = Cc['@mozilla.org/browser/search-service;1'].getService(Ci.nsIBrowserSearchService); var param = "";
var offset = aURL.indexOf(" "); var searchService = Cc['@mozilla.org/browser/search-service;1'].getService(Ci.nsIBrowserSearchService);
if (offset > 0) var offset = aURL.indexOf(" ");
{ if (offset > 0)
keyword = aURL.substr(0, offset); {
param = aURL.substr(offset + 1); keyword = aURL.substr(0, offset);
} param = aURL.substr(offset + 1);
if (!aPostDataRef)
{
aPostDataRef = {};
} }
var engine = searchService.getEngineByAlias(keyword); if (!aPostDataRef)
if (engine) {
{ aPostDataRef = {};
var submission = engine.getSubmission(param, null);
aPostDataRef.value = submission.postData;
return submission.uri.spec;
}
[shortcutURL, aPostDataRef.value] = PlacesUtils.getURLAndPostDataForKeyword(keyword);
if (!shortcutURL)
{
return aURL;
}
var postData = "";
if (aPostDataRef.value)
{
postData = unescape(aPostDataRef.value);
}
if (/%s/i.test(shortcutURL) || /%s/i.test(postData))
{
var charset = "";
const re = /^(.*)\&mozcharset=([a-zA-Z][_\-a-zA-Z0-9]+)\s*$/;
var matches = shortcutURL.match(re);
if (matches)
{
[, shortcutURL, charset] = matches;
}
else
{
try
{
charset = PlacesUtils.history.getCharsetForURI(makeURI(shortcutURL));
} catch (e) { }
}
var encodedParam = "";
if (charset)
{
encodedParam = escape(convertFromUnicode(charset, param));
} else {
encodedParam = encodeURIComponent(param);
}
shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);
if (/%s/i.test(postData))
{
aPostDataRef.value = getPostDataStream(postData, param, encodedParam, "application/x-www-form-urlencoded");
}
} else if (param) {
aPostDataRef.value = null;
return aURL;
} }
return shortcutURL; var engine = searchService.getEngineByAlias(keyword);
if (engine)
{
var submission = engine.getSubmission(param, null);
aPostDataRef.value = submission.postData;
return submission.uri.spec;
}
[shortcutURL, aPostDataRef.value] = PlacesUtils.getURLAndPostDataForKeyword(keyword);
if (!shortcutURL)
{
return aURL;
}
var postData = "";
if (aPostDataRef.value)
{
postData = unescape(aPostDataRef.value);
}
if (/%s/i.test(shortcutURL) || /%s/i.test(postData))
{
var charset = "";
const re = /^(.*)\&mozcharset=([a-zA-Z][_\-a-zA-Z0-9]+)\s*$/;
var matches = shortcutURL.match(re);
if (matches)
{
[, shortcutURL, charset] = matches;
}
else
{
try
{
charset = PlacesUtils.history.getCharsetForURI(makeURI(shortcutURL));
} catch (e) { }
}
var encodedParam = "";
if (charset)
{
encodedParam = escape(convertFromUnicode(charset, param));
} else {
encodedParam = encodeURIComponent(param);
}
shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);
if (/%s/i.test(postData))
{
aPostDataRef.value = getPostDataStream(postData, param, encodedParam, "application/x-www-form-urlencoded");
}
} else if (param) {
aPostDataRef.value = null;
return aURL;
}
return shortcutURL;
} }
url = getShortcutOrURI(searchString, aPostDataRef); url = getShortcutOrURI(searchString, aPostDataRef);
if (url == searchString) if (url == searchString)