Skip to content

Instantly share code, notes, and snippets.

@dextergk
Created October 11, 2009 18:09
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 dextergk/207772 to your computer and use it in GitHub Desktop.
Save dextergk/207772 to your computer and use it in GitHub Desktop.
/* Getting the train list from a given station pair any where in India. */
CmdUtils.CreateCommand({
names: ["TrainsList"],
icon: "http://www.erail.in/ico/erail.ico",
description: "Gets the train list for a given station pair any where in India, also displays weekly schedule.",
help: "<i>Type the command foll by source and destination station codes</i><br/>for example TrainList dli cstm.",
author: {name: "DexterGk", email: "dextergk@gmail.com"},
license: "GPL",
homepage: "http://dextergk.blogspot.com/",
arguments: [{role: 'source', nountype: noun_arb_text, label: 'city'},
{role: 'goal', nountype: noun_arb_text, label: 'city'}],
preview: function preview(pblock, {source, goal}) {
pblock.innerHTML = this.help;
},
execute: function({source, goal}) {
if(source.text) {
var temp = source.text;
var l = temp.indexOf(" ");
var src = temp.substr(0,l); var des = temp.substr(l+1,temp.length); }
var baseUrl = "http://erail.in?T="+src.toUpperCase()+"::"+des.toUpperCase()+":";
Utils.openUrlInBrowser(baseUrl);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment