Skip to content

Instantly share code, notes, and snippets.

@smgt smgt/hitta.js
Created May 18, 2009

Embed
What would you like to do?
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
You can’t perform that action at this time.