Skip to content

Instantly share code, notes, and snippets.

@dado21780
Created October 26, 2009 08:12
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 dado21780/218507 to your computer and use it in GitHub Desktop.
Save dado21780/218507 to your computer and use it in GitHub Desktop.
/* This is a template command. */
CmdUtils.CreateCommand({
names: ["trenitalia"],
icon: "http://www.mozilla.com/favicon.ico",
description: "A short description of your command.",
help: "How to use your command.",
author: {name: "Your Name", email: "you@mozilla.com"},
license: "GPL",
homepage: "http://labs.mozilla.com/",
arguments: [{role: 'source', nountype: noun_arb_text}, {role: 'goal', nountype: noun_arb_text}, {role: 'time', nountype: noun_arb_text}, {role: 'object', nountype: noun_arb_text}],
preview: function preview(pblock, args) {
var data = args.time.text;
var giorno = data.substring(0, data.indexOf('/'));
var mese = data.substring(giorno.length + 1, data.lastIndexOf('/'));
var anno = data.substring(data.lastIndexOf('/') + 1);
// displayMessage("You selected: " + args.object.text, this);
pblock.innerHTML = "Viaggio da <b>" + args.source.text + " a " + args.goal.text + ", il " + args.time.text +". Treni dalle ore... "+ args.object.text +"</b>.";
},
execute: function execute(args) {
var data = args.time.text;
var giorno = data.substring(0, data.indexOf('/'));
var mese = data.substring(giorno.length + 1, data.lastIndexOf('/'));
var anno = data.substring(data.lastIndexOf('/') + 1);
Utils.openUrlInBrowser('http://orario.trenitalia.com/b2c/nppPriceTravelSolutions.do', {'car': '0', 'stazin': args.source.text, 'stazout': args.goal.text, 'datag': giorno, 'datam': mese, 'dataa': anno, 'timsh': args.object.text, 'stazin_r': 'Staz_DA', 'stazout_r': 'Staz_A', 'timsm': '00', 'timsm_r': '00', 'lang': 'it', 'nreq': '5', 'channel': 'tcom', 'npag': '1', 'lang_r': 'it', 'nreq_r': '5', 'channel_r': 'tcom','npag_r': '1'});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment