-
-
Save karlbohlmark/144447 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Uppdatering till Parser 2 API av command skriven av Simon Gate, [email protected] | |
CmdUtils.CreateCommand({ | |
names: ["hitta"], | |
icon: "http://www.hitta.se/favicon.ico", | |
description: "Sök på hitta.se.", | |
help: "hitta [NAMN] i [STAD].", | |
author: {name: "Karl Böhlmark", email: "[email protected]"}, | |
license: "GPL", | |
arguments: [{role: 'object', nountype: noun_arb_text}], | |
preview: function preview(pblock, args) { | |
var split = args.object.html.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 (args.object.html.length > 0){ | |
pblock.innerHTML = "Sök efter <b>" + args.object.html + "</b>."; | |
} | |
}, | |
execute: function execute(args) { | |
var split = args.object.html.match(/^(.+)(?:\si\s|,)(.+)/i); | |
if (split != null) { | |
var what = split[1]; | |
var where = split[2]; | |
} else | |
{ | |
var what = args.object.html; | |
} | |
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