Skip to content

Instantly share code, notes, and snippets.

@asafd1
Created May 1, 2010 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asafd1/386576 to your computer and use it in GitHub Desktop.
Save asafd1/386576 to your computer and use it in GitHub Desktop.
search-backup
function searchDomainPreview(pblock, domain, args) {
var txt = jQuery.trim( args.object.text );
var jsonURL = "http://ajax.googleapis.com/ajax/services/search/web?q=site:" + domain +" " + txt + "&v=1.0&rsz=large&callback=?";
pblock.innerHTML = "Searching for " + txt + ' on <a title="' + domain + '" target="_blank" href="' +domain+ '/">' + domain + '...</a>';
jQuery.getJSON(jsonURL,
function (data) {
if (data.responseData.results &&
data.responseData.results.length > 0) {
var results = data.responseData.results;
var text = "";
for (var i=0; i < results.length; i++) {
text += '<h3>' + (i+1) + '. ' + '<a href="' + results[i].unescapedUrl + '">' + results[i].titleNoFormatting + '</a><br></h3>';
text += results[i].content;
}
pblock.innerHTML = text;
}
});
}
function searchDomainExecute(domain, args) {
var txt = jQuery.trim( args.object.text );
var url = 'http://www.google.com/search?q=site:' + domain +' '+ txt;
Utils.openUrlInBrowser(url);
}
CmdUtils.CreateCommand({
names: ["seret", "google-search-seret", "סרט"],
arguments: [
{role: "object", label: 'what', nountype: noun_arb_text}
],
description: "seret.co.il חפש סרט באתר",
icon: "http://www.seret.co.il/favicon.ico",
homepage: "http://sites.google.com/site/ubiquityisrael",
author: { name: "Asaf David", email: "asafd1@gmail.com"},
license: "GPL",
execute: function( args ){
var domain = "seret.co.il"
searchDomainExecute(domain, args);
return true;
},
preview: function(pblock, args) {
var domain = "seret.co.il"
searchDomainPreview(pblock, domain, args);
}
});
CmdUtils.CreateCommand({
names: ["torec", "google-search-torec", "כתוביות"],
arguments: [
{role: "object", label: 'what', nountype: noun_arb_text}
],
description: "torec.co.il חפש סרט באתר",
icon: "http://www.torec.co.il/favicon.ico",
homepage: "http://sites.google.com/site/ubiquityisrael",
author: { name: "Asaf David", email: "asafd1@gmail.com"},
license: "GPL",
execute: function( args ){
var domain = "torec.co.il"
searchDomainExecute(domain, args);
return true;
},
preview: function(pblock, args) {
var domain = "torec.co.il"
searchDomainPreview(pblock, domain, args);
}
});
CmdUtils.CreateCommand({
names: ["rest", "google-search-rest", "מסעדות"],
arguments: [
{role: "object", label: 'what', nountype: noun_arb_text}
],
description: "rest.co.il חפש סרט באתר",
icon: "http://www.rest.co.il/favicon.ico",
homepage: "http://sites.google.com/site/ubiquityisrael",
author: { name: "Asaf David", email: "asafd1@gmail.com"},
license: "GPL",
execute: function( args ){
var domain = "rest.co.il"
searchDomainExecute(domain, args);
return true;
},
preview: function(pblock, args) {
var domain = "rest.co.il"
searchDomainPreview(pblock, domain, args);
}
});
CmdUtils.CreateCommand({
names: ["zap", "google-search-zap", "זאפ"],
arguments: [
{role: "object", label: 'what', nountype: noun_arb_text}
],
description: "zap.co.il חפש סרט באתר",
icon: "http://www.zap.co.il/favicon.ico",
homepage: "http://sites.google.com/site/ubiquityisrael",
author: { name: "Asaf David", email: "asafd1@gmail.com"},
license: "GPL",
execute: function( args ){
var domain = "zap.co.il"
searchDomainExecute(domain, args);
return true;
},
preview: function(pblock, args) {
var domain = "zap.co.il"
searchDomainPreview(pblock, domain, args);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment