Skip to content

Instantly share code, notes, and snippets.

@morozowski morozowski/lyrics.js
Created Feb 17, 2009

Embed
What would you like to do?
Ubiquity Command "lyrics" or "letra(s)"
CmdUtils.makeSearchCommand({
name: "lyrics",
description: "Searches lyrics at letras.mus.br (powered by Google).",
url: "http://www.google.com/search?q=site:letras.terra.com.br+{QUERY}",
icon: "http://letras.terra.com.br/favicon.ico",
homepage: "http://gist.github.com/65907",
author: { name: "Morozowski", email: "morozowski+ubiquity [at] gmail [dot] com"},
license: "GPL",
synonyms: ["letra", "letras"],
preview: function(pblock, directObject) {
var searchTerm = directObject.text;
if(searchTerm.length < 1) {
pblock.innerHTML = "Searches lyrics at letras.mus.br.";
return;
}
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = { v: "1.0", q: "site:letras.terra.com.br " + searchTerm };
CmdUtils.previewGet( pblock, url, params, function(data) {
var numToDisplay = 10;
var results = data.responseData.results;
var html = '';
for(var i=0;i<results.length && i<numToDisplay;i++){
html += "<p>"+(i+1)+": <u><a href=\""+results[i].url+"\" accesskey=\""+(i+1)+"\">"+results[i].title+"</a></u></p>";
}
html += "<small>Tip: You can go to any result in this preview by using its number as an access key. (Linux and Windows: alt-number, Mac: control-number)</small>\n";
pblock.innerHTML = html;
}, "json");
}
});
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.