Created
May 18, 2009 20:53
-
-
Save smgt/113738 to your computer and use it in GitHub Desktop.
Hitta.se ubiquity command
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.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