Skip to content

Instantly share code, notes, and snippets.

@smgt
Created May 18, 2009 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save smgt/113738 to your computer and use it in GitHub Desktop.
Save smgt/113738 to your computer and use it in GitHub Desktop.
Hitta.se ubiquity command
CmdUtils.CreateCommand({
name: "hitta",
icon: "http://www.hitta.se/favicon.ico",
homepage: "http://hitta.se/",
author: {name: "Simon Gate", email: "simon@noona.se"},
license: "GPL",
description: "Sök på hitta.se",
takes: {"input": /.*/},
preview: function(pblock, input) {
var split = input.text.match(/^(.+)(?:\si\s|,|\såp\s)(.+)/i);
if(split != null) {
pblock.innerHTML = "Sök efter <b>" + split[1] + "</b> som bor i <b>" + split[2] + "</b>.";
} else if (input.text.length > 0){
pblock.innerHTML = "Sök efter <b>" + input.text + "</b>.";
}
},
execute: function(input) {
var split = input.text.match(/^(.+)(?:\si\s|,)(.+)/i);
if (split != null) {
var what = split[1];
var where = split[2];
} else {
var what = input.text;
}
if (what != "" && where != "") {
Utils.openUrlInBrowser("http://www.hitta.se/SearchMixed.aspx?vad="+what+"&var="+where);
} else {
Utils.openUrlInBrowser("http://www.hitta.se/SearchMixed.aspx?vad="+what);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment