Created
May 15, 2009 13:04
-
-
Save diegof79/112202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.makeSearchCommand({ | |
name: 'epiwiki', | |
url: 'http://www.google.com/cse?cx=008924722976592217197:xk650kh_mvy&ie=UTF-8&sa=Buscar&q={QUERY}', | |
icon: 'http://www.epidataconsulting.com/favicon.ico', | |
license: 'GPL', | |
homepage: "http://www.epidataconsulting.com/", | |
author: { name: "Diego Fernandez", email: "diegof@epidataconsulting.com"}, | |
description: 'Busca terminos en la wiki de EpiData', | |
preview: function(pblock, directObject) { | |
// NOTA: Este codigo esta basado en el codigo fuente de Ubiquity para la busqueda de Google | |
var searchTerm = directObject.text; | |
if(searchTerm.length < 1) { | |
pblock.innerHTML = "Busca en la base de conocimiento de Epidata Consulting."; | |
return; | |
} | |
var url = "http://ajax.googleapis.com/ajax/services/search/web"; | |
var params = { v: "1.0", q: searchTerm, cx: "008924722976592217197:xk650kh_mvy" }; | |
CmdUtils.previewGet( pblock, url, params, function(data) { | |
var numToDisplay = 3; | |
var results = data.responseData.results.splice( 0, numToDisplay ); | |
//for access keys | |
for(var i=0;i<results.length;i++){ | |
var result = results[i]; | |
result.key = i+1; | |
} | |
var previewTemplate = '{for result in results}<div class="gresult"><div>${result.key}: <a href="${result.unescapedUrl}" accesskey="${result.key}">${result.title}</a></div<xul:description class="gresult-content">${result.content}</xul:description><div class="gresult-url">${result.visibleUrl}</div></div>{forelse}<b>Your search - ${searchTerm} - did not match any documents.</b>{/for}<small>Tip: You can go to any result in this preview by pressing control, alt, and the result number at the same time.</small>'; | |
pblock.innerHTML = CmdUtils.renderTemplate( previewTemplate, | |
{results:results, searchTerm:searchTerm} | |
); | |
}, "json"); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment