-
-
Save dado21780/218595 to your computer and use it in GitHub Desktop.
This file contains 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
/* This is a template command. */ | |
var airports = ['AAR','ABZ','AGA','AHO','ALC','LEI','AOC','LBC','AOI','ANG','BAR','BRI','BSL','BHD','EGC','SXF','BZR','BIQ','BLL','BHX','BLQ','BOH','BTS','BRE','WRO','BES','BDS','BRS','BRQ','CRL','BUD','BZG','CAG','CCF','CND','ORK','COR','CUF','LDY','DNR','DSA','DUB','MME','NRN','EMA','EDI','EIN','FAO','FEZ','FSC','HHN','FDH','GDN','GOA','GRO','PIK','GSE','LPA','GRX','GRZ','GNB','HAU','IBZ','XRY','FKB','KTW','KUN','KIR','KLU','NOC','KRK','LRH','SUF','ACE','LBA','LIL','LIG','LNZ','LPL','LCJ','LGW','LTN','STN','LDE','MST','MAD','AGP','MLA','MAN','RAK','MRS','FMM','BGY','MPL','MUN','MJV','NDR','NTE','NCL','NQY','NCE','FNI','OLB','OSI','RYG','TRF','PMO','PMI','BVA','PMF','PUF','PGF','PEG','PSR','PSA','PIS','OPO','POZ','PRG','PUY','REU','RIX','RMI','RDZ','CIA','RZE','SZG','SDR','SCQ','ZAZ','SNN','SVQ','VXO','EBU','NYO','VST','SZZ','TMP','TNG','TFS','TRN','TLN','TUF','TPS','TRS','VLC','VLL','TSF','VBS','ZAD']; | |
CmdUtils.CreateCommand({ | |
names: ["ryanair"], | |
icon: "http://ryanair.com/favicon.ico", | |
description: "Flight 'from' an airport 'to' another 'with' how many people 'on' a date and return date just following that.", | |
help: "ex.: ryanair from CIA to MAD on 2/11/2009 11/11/2009 with 2", | |
author: {name: "Daniele Mazzoni", email: "mazzoni.daniele@gmail.com"}, | |
license: "GPL", | |
homepage: "http://www.google.com/profiles/mazzoni.daniele", | |
arguments: [{role: 'source', nountype: airports, label: "departure airport"}, | |
{role: 'goal', nountype: airports, label: "arrival airport"}, | |
{role: 'time', nountype: noun_arb_text, label: "departure date (dd/mm/yyyy)"}, | |
{role: 'object', nountype: noun_arb_text, label: "arrival date (dd/mm/yyyy)"}, | |
{role: 'instrument', nountype: noun_arb_text, label: "how many adults?"}], | |
preview: function preview(pblock, args) { | |
pblock.innerHTML = "<b>if you entered 'from', 'to', 'on' (with 2 dates dd/mm/yyyy) and 'with' how many people (including yourself), hit enter!</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); | |
var ret_data = args.object.text; | |
var ret_giorno = ret_data.substring(0, ret_data.indexOf('/')); | |
var ret_mese = ret_data.substring(ret_giorno.length + 1, ret_data.lastIndexOf('/')); | |
var ret_anno = ret_data.substring(ret_data.lastIndexOf('/') + 1); | |
Utils.openUrlInBrowser("http://www.bookryanair.com/SkySales/FRSearchRedirect.aspx?culture=IT-IT&lc=IT-IT", {'travel_type' : '0', 'sector1_o' : args.source.text, 'sector1_d' : args.goal.text, 'sector_1_d' : giorno, 'sector_1_m' : mese+anno, 'sector_2_d' : ret_giorno, 'sector_2_m': ret_mese+ ret_anno, 'ADULT' : args.instrument.text, 'CHILD' : '0', 'INFANT': '0'}); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment