Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubiquity: Google-bookmarks-tool
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<title>Ubiquity Google bookmarks tool</title>
</head>
<body>
<div id="google-bookmarks-search" style="display: none;">
<small>${tipsMessage}</small>
<br/>
<br/>
{for result in results}
<div class="gresult">
<div>
${result.key}: <a href="${jQuery('url',result).get(0).innerHTML}" accesskey="${result.key}">${jQuery('title',result).get(0).innerHTML}</a>
<div class="gresult-url">
{for label in result.labels}
${label.innerHTML}
{/for}
</div>
</div>
</div>
{forelse}
<b>${noResultsMessage}</b>
{/for}
</div>
<script class="commands"><![CDATA[
//Google bookmark
CmdUtils.makeSearchCommand({
names: "gbk",
url: "http://www.google.com/bookmarks/find?q={QUERY}",
icon: "chrome://ubiquity/skin/icons/google.ico",
description: "Searches Google bookmarks for your words.",
help: "You can use the keyboard shortcut ctrl /+ alt + number to open one " +
"of the Google bookmarks' results shown in the preview.",
preview: function(pblock, {object}) {
var searchTerm = object.text;
// Don't even display any text before fetching search results,
// since the results come back nearly instantaneously. In the
// future, we can display a throbber.
var params = {output: "xml"};
if(searchTerm.length > 0) {
params = {q:searchTerm, output: "xml",btnSMH: "Search+Bookmarks" };
}
var url = "http://www.google.com/bookmarks/find";
CmdUtils.previewGet( pblock, url, params, function(data) {
data = data.replace(/<\?[^>]*>/, '');
var results = jQuery("bookmark",data).get();
var nums = "123456789abcdefghijklmnopqrstuvwxyz";
var numToDisplay = nums.length;
if(results!=undefined){
results = results.splice(0,numToDisplay);
for(var i=0;i<results.length;i++){
var result = results[i];
result.key=nums.charAt(i);
result.labels = jQuery('label',result).get();
}
}else{
results = {};
}
var noResultsMessage = _("Your search - ${searchTerm} - did not match any bookmarks.",{searchTerm:searchTerm});
var tipsMessage = _("Tip: You can go to any result in this preview by pressing control, alt, and the result number at the same time.");
pblock.innerHTML = CmdUtils.renderTemplate(
jQuery("#google-bookmarks-search", feed.dom).html(),
{ results:results,
searchTerm:searchTerm,
noResultsMessage:noResultsMessage,
tipsMessage:tipsMessage,
});
}, "text");
}
});
]]></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.