Skip to content

Instantly share code, notes, and snippets.

@andyed
Created February 1, 2009 19:44
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 andyed/55963 to your computer and use it in GitHub Desktop.
Save andyed/55963 to your computer and use it in GitHub Desktop.
var noun_type_gistpages = new CmdUtils.NounType( "Gist Page Name",
["Dashboard","People News", "Company News", "All News", "People List", "Company List"]
);
var noun_type_gistdomains = new CmdUtils.NounType( "Gist Domaisn",
["People","Companies"]
);
CmdUtils.CreateCommand({
name: "gist",
icon: "https://beta.gist.com/favicon.ico",
homepage: "http://bist.com/",
description: "Navigates aroung gist.com",
help: "help goes here",
takes: {"input": noun_arb_text},
modifiers: {go: noun_type_gistpages, in: noun_type_gistdomains},
preview: function( pblock, input ) {
pblock.innerHTML = "Navigate the beta.Gist.com application. Examples:<ul><li>gist go (dashboard | all news | people news | people list | company list) </li><li>gist searchterm <em>in</em> people</li><li>gist searchterm <em>in</em> companies</li></ul>";
},
execute: function(input, mods) {
// Sample URLs:
// https://beta.gist.com/companies#sort:Importance+query:gist+
// https://beta.gist.com/people#sort:Importance+query:gist+
// https://beta.gist.com/dashboard
// https://beta.gist.com/dashboard?news=companies
// https://beta.gist.com/dashboard?news=all
// https://beta.gist.com/accounts
var baseUrl = 'http://beta.gist.com/';
if(input && input.text && input.text.length) {
if(mods.in && mods.in.text && mods.in.text.length) {
switch (mods.in.text) {
case "People": Utils.openUrlInBrowser(baseUrl + 'people#sort:Importance+query:'+ input.text);break;
case "Comanies": Utils.openUrlInBrowser(baseUrl + 'companies#sort:Importance+query:'+ input.text);break;
}
} else {
Utils.openUrlInBrowser(baseUrl + 'people#sort:Importance+query:'+ input.text);
}
} else {
if(mods.go && mods.go.text && mods.go.text.length) {
switch (mods.go.text) {
case "Dashboard": Utils.openUrlInBrowser(baseUrl + 'dashboard?news=all'); break
case "People News": Utils.openUrlInBrowser(baseUrl + 'dashboard?news=people'); break;
case "Company News": Utils.openUrlInBrowser(baseUrl + 'dashboard?news=company'); break;
case "All News": Utils.openUrlInBrowser(baseUrl + 'dashboard?news=all'); break;
case "People List": Utils.openUrlInBrowser(baseUrl + 'people'); break;
case "Company List": Utils.openUrlInBrowser(baseUrl + 'companies'); break;
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment