Skip to content

Instantly share code, notes, and snippets.

@dextergk
Created October 10, 2009 15:11
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/206899 to your computer and use it in GitHub Desktop.
Save dextergk/206899 to your computer and use it in GitHub Desktop.
India: Train Running Status
/* This is my first ubiq command. */
CmdUtils.CreateCommand({
names: ["TrainRunStat"],
icon: "http://www.erail.in/ico/erail.ico",
description: "Finds Train Running Status for Today.",
help: "<i>Type the command foll by train number</i><br/>for example TrainRunStat 2341.",
author: {name: "DexterGk", email: "dextergk@gmail.com"},
license: "GPL",
homepage: "http://dextergk.blogspot.com/",
arguments: [{role: 'object', nountype: noun_arb_text, label: 'train code'}],
preview: function preview(pblock, args) {
pblock.innerHTML = this.help;
},
execute: function(arguments) {
if(Utils.trim(arguments.object.text).length<4)
return;
var arg = Utils.trim(arguments.object.text);
var today = new Date();
var month = today.getMonth() + 1;
var sep = "%2f0";
if(month > 9)
sep = "%2f";
var date =
today.getDate() + sep +
month + "%2f" +
today.getFullYear();
var baseUrl = "http://www.trainenquiry.com/RunningTT_Display.aspx?drop_sel="+arg+"&date="+date;
Utils.openUrlInBrowser(baseUrl);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment